-
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #487 from Faf4a/v6
v6
- Loading branch information
Showing
18 changed files
with
219 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = async (d) => { | ||
const data = d.util.aoiFunc(d); | ||
if (data.err) return d.error(data.err); | ||
let template; | ||
|
||
const [templateCode, property] = data.inside.splits; | ||
|
||
try { | ||
template = await d.client.fetchGuildTemplate(`https://discord.new/${templateCode}`); | ||
} catch (err) { | ||
return d.aoiError.fnError(d, "custom", { inside: data.inside }, "Template ID"); | ||
} | ||
|
||
data.result = property.split(".").reduce((obj, prop) => obj && obj[prop], template); | ||
|
||
return { | ||
code: d.util.setCode(data), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = async (d) => { | ||
const data = d.util.aoiFunc(d); | ||
if (data.err) return d.error(data.err); | ||
let templates; | ||
|
||
const [guildID = d.guild?.id, option = "code", separator = " , "] = data.inside.splits; | ||
|
||
try { | ||
const guild = await d.util.getGuild(d, guildID); | ||
templates = await guild.fetchTemplates(); | ||
} catch (err) { | ||
data.result = undefined; | ||
return; | ||
} | ||
|
||
data.result = templates.map(x => option.split(".").reduce((obj, prop) => obj && obj[prop], x)).join(separator); | ||
|
||
return { | ||
code: d.util.setCode(data), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,121 @@ | ||
const {SelectMenuBuilder} = require("discord.js"); | ||
const { StringSelectMenuBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, MentionableSelectMenuBuilder, ChannelSelectMenuBuilder } = require("discord.js"); | ||
|
||
module.exports = async (d) => { | ||
const {code} = d.command; | ||
const inside = d.unpack(); | ||
const err = d.inside(inside); | ||
if (err) return d.error(err); | ||
let [ | ||
index = 1, | ||
customId, | ||
placeHolder, | ||
minValues = 1, | ||
maxValues = 1, | ||
disabled = "false", | ||
...options | ||
] = inside.splits; | ||
const components = new SelectMenuBuilder(); | ||
index = Number(index) - 1; | ||
if (isNaN(index) || index < 0) | ||
d.aoiError.fnError(d, "custom", {inside}, "Invalid Index Provided In"); | ||
disabled = disabled === "true"; | ||
placeHolder = placeHolder?.addBrackets(); | ||
customId = customId?.addBrackets(); | ||
minValues = Number(minValues); | ||
maxValues = Number(maxValues); | ||
if (!options.length) | ||
d.aoiError.fnError(d, "custom", {inside}, "Options Are Not Provided In"); | ||
if (minValues > 25 || minValues < 0) | ||
return d.aoiError.fnError( | ||
d, | ||
"custom", | ||
{inside}, | ||
"minValues must be between 0 and 25 (both inclusive). Provided Invalid In", | ||
); | ||
if (maxValues > 25 || maxValues < 1) | ||
return d.aoiError.fnError( | ||
d, | ||
"custom", | ||
{inside}, | ||
"maxValues must be between 1 and 25 (both Inclusive). Provided Invalid In", | ||
); | ||
if (placeHolder.length > 100) | ||
return d.aoiError.fnError( | ||
d, | ||
"custom", | ||
{}, | ||
"Placeholder should be at most 100 char long", | ||
); | ||
d.components[index] = d.components[index] || {type: 1, components: []}; | ||
components | ||
.setCustomId(customId) | ||
.setPlaceholder(placeHolder) | ||
.setMaxValues(maxValues) | ||
.setMinValues(minValues) | ||
.setDisabled(disabled); | ||
for (let option of options) { | ||
option = option.split(":"); | ||
const label = option.shift().addBrackets(); | ||
const description = option.shift().addBrackets(); | ||
const value = option.shift().addBrackets(); | ||
const def = option.shift()?.addBrackets() === "true"; | ||
let emoji = option.join(":")?.addBrackets(); | ||
emoji = emoji === '' ? undefined : emoji; | ||
components.addOptions({label, description, value, default: def, emoji}); | ||
const data = d.util.aoiFunc(d); | ||
const { code } = d.command; | ||
if (data.err) return d.error(data.err); | ||
|
||
let [ index = 1, type, customId, placeHolder, minValues = 1, maxValues = 1, disabled = "false", ...options] = data.inside.splits; | ||
|
||
index = Number(index) - 1; | ||
|
||
if (isNaN(index) || index < 0) | ||
d.aoiError.fnError(d, "custom", { inside: data.inside }, "Invalid Index Provided In"); | ||
|
||
disabled = disabled === "true"; | ||
placeHolder = placeHolder?.addBrackets(); | ||
customId = customId?.addBrackets(); | ||
minValues = Number(minValues); | ||
maxValues = Number(maxValues); | ||
|
||
if (!options.length && type === "string") return d.aoiError.fnError(d, "custom", { inside: data.inside }, "Options Are Not Provided In"); | ||
|
||
if (minValues > 25 || minValues < 0) | ||
return d.aoiError.fnError( | ||
d, | ||
"custom", | ||
{ inside: data.inside }, | ||
"minValues must be between 0 and 25 (both inclusive). Provided Invalid In" | ||
); | ||
|
||
if (maxValues > 25 || maxValues < 1) | ||
return d.aoiError.fnError( | ||
d, | ||
"custom", | ||
{ inside: data.inside }, | ||
"maxValues must be between 1 and 25 (both Inclusive). Provided Invalid In" | ||
); | ||
|
||
if (placeHolder.length > 100) | ||
return d.aoiError.fnError( | ||
d, | ||
"custom", | ||
{}, | ||
"Placeholder should be at most 100 Characters long" | ||
); | ||
|
||
let selectBuilder; | ||
|
||
switch (type.toLowerCase()) { | ||
case "string": | ||
selectBuilder = new StringSelectMenuBuilder(); | ||
break; | ||
case "user": | ||
selectBuilder = new UserSelectMenuBuilder(); | ||
break; | ||
case "role": | ||
selectBuilder = new RoleSelectMenuBuilder(); | ||
break; | ||
case "mentionable": | ||
selectBuilder = new MentionableSelectMenuBuilder(); | ||
break; | ||
case "channel": | ||
selectBuilder = new ChannelSelectMenuBuilder(); | ||
break; | ||
default: | ||
return d.aoiError.fnError(d, "custom", { inside: data.inside }, "Invalid Select Menu Type"); | ||
} | ||
|
||
selectBuilder | ||
.setCustomId(customId) | ||
.setPlaceholder(placeHolder) | ||
.setMaxValues(maxValues) | ||
.setMinValues(minValues) | ||
.setDisabled(disabled); | ||
|
||
for (let option of options) { | ||
option = option.split(":"); | ||
const label = option[0].addBrackets(); | ||
const description = option[1].addBrackets(); | ||
const value = option[2].addBrackets(); | ||
const def = option[3]?.addBrackets() === "true"; | ||
let emoji = option[4]?.addBrackets(); | ||
emoji = emoji === "" ? undefined : emoji; | ||
|
||
switch (type.toLowerCase()) { | ||
case "string": | ||
selectBuilder.addOptions({ | ||
label, | ||
description, | ||
value, | ||
default: def, | ||
emoji, | ||
}); | ||
break; | ||
case "user": | ||
case "role": | ||
case "mentionable": | ||
case "channel": | ||
selectBuilder.addOption({ | ||
label, | ||
value, | ||
type: type.toUpperCase(), | ||
}); | ||
break; | ||
default: | ||
d.aoiError.fnError(d, "custom", { inside: data.inside }, "Invalid Select Menu Type"); | ||
} | ||
d.components[index].components.push(components); | ||
return { | ||
code: d.util.setCode({function: d.func, code, inside}), | ||
components: d.components, | ||
}; | ||
} | ||
|
||
d.components[index] = d.components[index] || { type: 1, components: [] }; | ||
d.components[index].components.push(selectBuilder); | ||
|
||
return { | ||
code: d.util.setCode({ function: d.func, code, inside: data.inside }), | ||
data: { | ||
...d.data, | ||
components: Object.assign({}, d.data.components, d.components), | ||
}, | ||
components: d.components, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module.exports = async (d) => { | ||
const data = d.util.aoiFunc(d); | ||
const { code } = d.command; | ||
|
||
const [objectName, property, propertyValue] = data.inside.splits; | ||
const properties = property.split('.'); | ||
|
||
if (!d.data.objects) return d.aoiError.fnError(d, "custom", {}, "Object"); | ||
|
||
let object = d.data.objects[objectName] || {}; | ||
|
||
let Object = object; | ||
for (let i = 0; i < properties.length - 1; i++) { | ||
const propertyName = properties[i]; | ||
Object[propertyName] = Object[propertyName] || {}; | ||
Object = Object[propertyName]; | ||
} | ||
|
||
try { | ||
Object[properties[properties.length - 1]] = JSON.parse(propertyValue); | ||
} catch (e){ | ||
Object[properties[properties.length - 1]] = propertyValue; | ||
} | ||
|
||
d.data.objects[objectName] = object; | ||
d.object = object; | ||
|
||
return { | ||
code: d.util.setCode({ function: d.func, code: code, inside: data.inside }), | ||
data: { ...d.data, objects: { ...d.data.objects } }, | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { UserFlags } = require('discord.js'); | ||
|
||
module.exports = async (d) => { | ||
const data = d.util.aoiFunc(d); | ||
|
||
const [userID = d.author?.id] = data.inside.splits; | ||
|
||
const user = await d.util.getUser(d, userID); | ||
if (!user) return d.aoiError.fnError(d, 'user', {inside: data.inside}); | ||
|
||
data.result = user.flags.has(UserFlags.VerifiedBot); | ||
|
||
return { | ||
code: d.util.setCode(data) | ||
} | ||
} |
File renamed without changes.
File renamed without changes.