Hello,I am currently working on some code for my Discord Bot, and was wondering if anyone could help. Right now, if I do an unknown command, the right thing will pop up, but when I do a valid command, it will show the unknown command prompt, and the valid command's prompt. My guess is I have code that I would like to use, but right now, it is space insensitive, meaning it will not react with spaces. If the command is one word, it will work perfectly fine, but if the command is two words, it will not react, and will make a duplication glitch. Below is my code.client.on("message", message => { if(!message.content.startsWith(PREFIX)) return; const unknowncommand = new Discord.MessageEmbed() .setColor('GREEN') .setTitle('SCOTT') .setDescription('You\'ve entered an unknown command. \nUse **!help** to see all available commands.') let validCommands = ["eat cookies", "eat ice cream", "eat choice", "eat candy", "eat lollipops", "eat fudge", "eat donuts", "eat gum"]; const args = message.content.split(" "); const command = args.shift(); const isValid = validCommands.includes(command); if(!isValid){ if(message.author.bot) return; return message.channel.send(unknowncommand), console.log(`[SCOTT] ${message.author.username} entered an unknown command in "${message.guild.name}".`); } }); I do not know if this is the right place to ask, because in Stack Overflow, the community was very rude and unhelpful, so I hope to get better responses here, and for someone to tell me what I am doing wrong! Thank you!
Submitted July 29, 2020 at 01:15AM by Rockstarsong
No comments:
Post a Comment