Finished Help w/ Options this time

pull/11/head
TheCodedProf 3 years ago
parent cd187ee3cb
commit 8c29523dc0

@ -96,11 +96,11 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
descriptionLocalized?: string; descriptionLocalized?: string;
})[] = []; })[] = [];
//options //options
if(subcommandRow.components[0]!.options.find(option => option.data.default)) { if(currentPath[1] !== "" && currentPath[1] !== "none" && currentPath[2] !== "" && currentPath[2] !== "none") {
let Op = current.options.find(option => option.name === currentPath[1])! as ApplicationCommandSubGroup let Op = current.options.find(option => option.name === currentPath[1])! as ApplicationCommandSubGroup
let Op2 = Op.options!.find(option => option.name === currentPath[2])! let Op2 = Op.options!.find(option => option.name === currentPath[2])!
options = Op2.options || [] options = Op2.options || []
} else if(subcommandGroupRow.components[0]!.options.find(option => option.data.default)) { } else if(currentPath[1] !== "" && currentPath[1] !== "none") {
let Op = current.options.find(option => option.name === currentPath[1])! let Op = current.options.find(option => option.name === currentPath[1])!
if(Op.type === ApplicationCommandOptionType.SubcommandGroup) { if(Op.type === ApplicationCommandOptionType.SubcommandGroup) {
options = [] options = []
@ -112,7 +112,7 @@ const callback = async (interaction: CommandInteraction): Promise<void> => {
options = current.options.filter(option => option.type !== ApplicationCommandOptionType.SubcommandGroup && option.type !== ApplicationCommandOptionType.Subcommand) || []; options = current.options.filter(option => option.type !== ApplicationCommandOptionType.SubcommandGroup && option.type !== ApplicationCommandOptionType.Subcommand) || [];
} }
for(const option of options) { for(const option of options) {
optionString += `> ${option.name} (${option.type})- ${option.description}\n` optionString += `> ${option.name} (${ApplicationCommandOptionType[option.type]})- ${option.description}\n`
} }
const APICommand = client.commands["commands/" + currentPath.filter(value => value !== "" && value !== "none").join("/")]![0] const APICommand = client.commands["commands/" + currentPath.filter(value => value !== "" && value !== "none").join("/")]![0]
let allowedToRun = true; let allowedToRun = true;

@ -171,7 +171,7 @@ async function registerCommandHandler() {
const fullCommandName = "commands/" + commandName + (subcommandGroupName ? `/${subcommandGroupName}` : "") + (subcommandName ? `/${subcommandName}` : ""); const fullCommandName = "commands/" + commandName + (subcommandGroupName ? `/${subcommandGroupName}` : "") + (subcommandName ? `/${subcommandName}` : "");
console.log(fullCommandName, client.commands[fullCommandName]) // console.log(fullCommandName, client.commands[fullCommandName])
const command = client.commands[fullCommandName]![0]; const command = client.commands[fullCommandName]![0];
const callback = command?.callback; const callback = command?.callback;
const check = command?.check; const check = command?.check;
@ -223,5 +223,5 @@ export default async function register() {
console.log( console.log(
(config.enableDevelopment ? `${colours.purple}Bot started in Development mode` : (config.enableDevelopment ? `${colours.purple}Bot started in Development mode` :
`${colours.blue}Bot started in Production mode`) + colours.none) `${colours.blue}Bot started in Production mode`) + colours.none)
console.log(client.commands) // console.log(client.commands)
}; };

@ -55,7 +55,7 @@ export async function command(
commandString = "commands/" + (commandString ?? path); commandString = "commands/" + (commandString ?? path);
const fetched = await getSubcommandsInFolder(config.commandsFolder + "/" + path); const fetched = await getSubcommandsInFolder(config.commandsFolder + "/" + path);
console.log(`│ ├─ ${fetched.errors ? colours.red : colours.green}Loaded ${fetched.subcommands.length} subcommands and ${fetched.subcommandGroups.length} subcommand groups for ${name} (${fetched.errors} failed)${colours.none}`) console.log(`│ ├─ ${fetched.errors ? colours.red : colours.green}Loaded ${fetched.subcommands.length} subcommands and ${fetched.subcommandGroups.length} subcommand groups for ${name} (${fetched.errors} failed)${colours.none}`)
console.log({name: name, description: description}) // console.log({name: name, description: description})
client.commands[commandString!] = [undefined, { name: name, description: description }] client.commands[commandString!] = [undefined, { name: name, description: description }]
return (command: SlashCommandBuilder) => { return (command: SlashCommandBuilder) => {
command.setName(name) command.setName(name)

@ -18,7 +18,7 @@ export const getCommandByName = (name: string): {name: string, description: stri
const split = name.replaceAll(" ", "/") const split = name.replaceAll(" ", "/")
const command = client.commands["commands/" + split]!; const command = client.commands["commands/" + split]!;
console.log(command) // console.log(command)
const mention = getCommandMentionByName(name); const mention = getCommandMentionByName(name);
return { return {
name: command[1].name, name: command[1].name,

Loading…
Cancel
Save