javascriptvisual-studio-codediscorddiscord.jsconfigurable

i don‘t know how to do configurable commands in discord.js


So I recently started creating a new Discord bot using discord.js. I just wanted to make a command to set up reaction roles, but I can‘t figure out how to implement the arguments from discord in the code without writing it in the js file manually. Can anyone please help me? I can‘t really show you an example code, I‘m sorry :D


Solution

  • assuming you have the default code provided in the guide

    if (!message.content.startsWith(prefix) || message.author.bot) return;
    
    const args = message.content.slice(prefix.length).split(/ +/);
    const command = args.shift().toLowerCase();
    

    you can get the arguments with

    firstArgument = args[0]
    firstArgument = args[1]