From 192cd1d2c50893adcc1c46af7b9b916b433321ad Mon Sep 17 00:00:00 2001 From: kry008 Date: Thu, 23 May 2024 13:57:03 +0200 Subject: [PATCH] Undo some change --- commands/argsTest.js | 8 --- commands/ban.js | 8 --- commands/cat.js | 1 - commands/catFacts.js | 1 - commands/chuck.js | 1 - commands/colorrgb.js | 20 ------- commands/dns.js | 8 --- commands/dog.js | 1 - commands/fox.js | 1 - commands/guessNumber.js | 8 --- commands/help.js | 108 ++++++++++++++++++++++++++++++++++++- commands/kick.js | 14 ----- commands/pokemon.js | 14 ----- commands/profilePicture.js | 8 --- commands/template | 8 --- commands/waifu.js | 8 --- 16 files changed, 107 insertions(+), 110 deletions(-) diff --git a/commands/argsTest.js b/commands/argsTest.js index 6db0b2a..4576d96 100644 --- a/commands/argsTest.js +++ b/commands/argsTest.js @@ -2,14 +2,6 @@ module.exports = { name: 'argumentstest', description: 'Test command for args', help: 'This command is used to test the arguments of a command', - arguments: [ - { - name: 'ANY', - type: 'ANY', - description: 'Any type of argument', - required: false, - }, - ], options: [ { name: 'type3', diff --git a/commands/ban.js b/commands/ban.js index 0d34e85..f238ca9 100644 --- a/commands/ban.js +++ b/commands/ban.js @@ -2,14 +2,6 @@ module.exports = { name: 'ban', description: 'Bans a user from the server', help: 'This command is used to ban a user from the server. Requires the user to have the "Ban Members" permission. Requires the bot to have the "Ban Members" permission.', - arguments: [ - { - name: 'user', - type: 'USER', - description: 'The user to ban', - required: true, - }, - ], options: [ { name: 'user', diff --git a/commands/cat.js b/commands/cat.js index aaf750c..201f43f 100644 --- a/commands/cat.js +++ b/commands/cat.js @@ -8,7 +8,6 @@ module.exports = { name: 'cat', description: 'Get a random cat picture', help: 'Get a random cat picture', - arguments: [], options: [], slash: true, text: true, diff --git a/commands/catFacts.js b/commands/catFacts.js index dadc30b..383bab1 100644 --- a/commands/catFacts.js +++ b/commands/catFacts.js @@ -8,7 +8,6 @@ module.exports = { name: 'catfact', description: 'Get a random cat fact', help: 'Get a random cat fact', - arguments: [], options: [], slash: true, text: true, diff --git a/commands/chuck.js b/commands/chuck.js index 1031032..53dc94e 100644 --- a/commands/chuck.js +++ b/commands/chuck.js @@ -8,7 +8,6 @@ module.exports = { name: 'chuck', description: 'Get a random Chuck Norris joke', help: 'Get a random Chuck Norris joke', - arguments: [], options: [], slash: true, text: true, diff --git a/commands/colorrgb.js b/commands/colorrgb.js index 9f3b67d..89f533e 100644 --- a/commands/colorrgb.js +++ b/commands/colorrgb.js @@ -49,26 +49,6 @@ module.exports = { name: 'colorrgb', description: 'converts a RGB color to HEX, HSL, and CMYK', help: 'This command converts a RGB color to HEX, HSL, and CMYK', - arguments: [ - { - name: 'r', - type: 'INTEGER', - description: 'The red value (0-255)', - required: true, - }, - { - name: 'g', - type: 'INTEGER', - description: 'The green value (0-255)', - required: true, - }, - { - name: 'b', - type: 'INTEGER', - description: 'The blue value (0-255)', - required: true, - }, - ], slash: true, text: true, admin: false, diff --git a/commands/dns.js b/commands/dns.js index 8c04a00..7bdc678 100644 --- a/commands/dns.js +++ b/commands/dns.js @@ -4,14 +4,6 @@ module.exports = { name: 'dns', description: 'Look what is the IP of a domain. Requires a domain as argument.', help: 'Look what is the IP of a domain. Requires a domain as argument.', - arguments: [ - { - name: 'domain', - type: 'STRING', - description: 'The domain to look up', - required: true, - }, - ], options: [ { name: 'domain', diff --git a/commands/dog.js b/commands/dog.js index a4d590d..7b066df 100644 --- a/commands/dog.js +++ b/commands/dog.js @@ -8,7 +8,6 @@ module.exports = { name: 'dog', description: 'Get a random dog picture', help: 'Get a random dog picture', - arguments: [], options: [], slash: true, text: true, diff --git a/commands/fox.js b/commands/fox.js index 81bdccc..b1ef8c9 100644 --- a/commands/fox.js +++ b/commands/fox.js @@ -8,7 +8,6 @@ module.exports = { name: 'fox', description: 'Get a random fox picture', help: 'Get a random fox picture', - arguments: [], options: [], slash: true, text: true, diff --git a/commands/guessNumber.js b/commands/guessNumber.js index 00b78d8..5e4a52f 100644 --- a/commands/guessNumber.js +++ b/commands/guessNumber.js @@ -8,14 +8,6 @@ module.exports = { name: 'guessnumber', description: 'Guess a number between 1 and 100', help: 'Guess a number between 1 and 100', - arguments: [ - { - name: 'number', - type: 'INTEGER', - description: 'Your guess', - required: true, - }, - ], options: [ { name: 'number', diff --git a/commands/help.js b/commands/help.js index 58403b8..d2bcef9 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1 +1,107 @@ -//optiona name of the command \ No newline at end of file +//optiona name of the command +var fs = require('fs'); +function getAllCommands(client) { + const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); + const allCommands = []; + for (const file of commandFiles) { + const command = require(`./${file}`); + allCommands.push(command); + } + return allCommands; +} +function allCommandsNames(guild = true) +{ + //check if it is in dm or guild + if(guild) + { + const commands = getAllCommands(); + let str = ''; + for(const command of commands) + { + if(command.admin === false) + str += command.name + '\n'; + } + return str; + } + else + { + const commands = getAllCommands(); + let str = ''; + for(const command of commands) + { + if(command.canBeUsedInDm) + if(command.admin === false) + str += command.name + '\n'; + } + return str; + } +} +function getCommand(name, guild = true) +{ + //check if it is in dm or guild + if(guild) + { + const commands = getAllCommands(); + for(const command of commands) + { + if(command.name === name) + return command; + } + } + else + { + const commands = getAllCommands(); + for(const command of commands) + { + if(command.name === name && command.canBeUsedInDm) + return command; + } + } + return null; +} +module.exports = { + name: 'help', + description: 'Get a list of all commands or information about a specific command', + help: 'Get a list of all commands or information about a specific command', + options: [ + { + name: 'command', + description: 'Command to get information about', + type: 3, + required: false, + }, + ], + slash: true, + text: true, + admin: false, + requireKick: false, + premium: false, + requireBan: false, + canBeUsedInDm: true, + contexts: ['GUILD_TEXT', 'GUID_VOICE', 'DM'], + integration_types: [0,1], + execute: async (message, args) => { + if(args.length === 0) + { + const commands = allCommandsNames(); + message.channel.send(commands); + return; + } + const command = getCommand(args[0]); + if(command === null) + { + message.channel.send('Command not found'); + return; + } + message.channel.send('Name: ' + command.name + '\nDescription: ' + command.description + '\nHelp: ' + command.help); + }, + executeSlash: async interaction => { + const command = getCommand(interaction.options.getString('command')); + if(command === null) + { + interaction.reply('Command not found'); + return; + } + interaction.reply('Name: ' + command.name + '\nDescription: ' + command.description + '\nHelp: ' + command.help); + }, +}; diff --git a/commands/kick.js b/commands/kick.js index c89cc1d..c4d9ea5 100644 --- a/commands/kick.js +++ b/commands/kick.js @@ -2,20 +2,6 @@ module.exports = { name: 'kick', description: 'Kicks a user from the server', help: 'Kicks a user from the server with a reason if provided. Requires the user to have the "Kick Members" permission. Requires the bot to have the "Kick Members" permission.', - arguments: [ - { - name: 'user', - type: 'USER', - description: 'The user to kick', - required: true, - }, - { - name: 'reason', - type: 'STRING', - description: 'The reason for the kick', - required: false, - }, - ], options: [ { name: 'user', diff --git a/commands/pokemon.js b/commands/pokemon.js index a9134e8..dc8a0a7 100644 --- a/commands/pokemon.js +++ b/commands/pokemon.js @@ -71,20 +71,6 @@ module.exports = { name: 'pokemon', description: 'Get a random pokemon. **FUNCTION NOT FINISHED**', help: 'Get a random pokemon. **FUNCTION NOT FINISHED**', - arguments: [ - { - name: 'pokemonname', - type: 'STRING', - description: 'Name of the pokemon you want to get information about', - required: false, - }, - { - name: 'pokemonnumber', - type: 'INTEGER', - description: 'Number of the pokemon you want to get information about', - required: false, - }, - ], options: [ { name: 'pokemonname', diff --git a/commands/profilePicture.js b/commands/profilePicture.js index 556c0e7..a232338 100644 --- a/commands/profilePicture.js +++ b/commands/profilePicture.js @@ -2,14 +2,6 @@ module.exports = { name: 'profilepicture', description: 'Get the profile picture of a user.', help: 'Get the profile picture of a user.', - arguments: [ - { - name: 'user', - type: 'User', - description: 'The user to get the profile picture', - required: false - } - ], options: [ { name: 'user', diff --git a/commands/template b/commands/template index 903bf7b..76b2739 100644 --- a/commands/template +++ b/commands/template @@ -2,14 +2,6 @@ module.exports = { name: '', description: '', help: '', - arguments: [ - { - name: '', - description: '', - type: 3, - required: false, - } - ], options: [], slash: true, text: true, diff --git a/commands/waifu.js b/commands/waifu.js index 89a1809..93295eb 100644 --- a/commands/waifu.js +++ b/commands/waifu.js @@ -15,14 +15,6 @@ module.exports = { name: 'waifu', description: 'Get a random waifu picture', help: 'Get a random waifu picture with the type you want', - arguments: [ - { - name: 'type', - type: 'STRING', - description: 'The type of waifu picture you want', - required: true, - }, - ], options: [ { name: 'type',