Is there any way to store in a variable what a user writes after a command for a discord bot? (discord js)

Viewed 31

I want to create a 'prefix changer' command. I want the bot to store whatever the user writes after the command into a variable.

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
 
client.on('ready', () => {
  console.log('Bot Online');
});

var prefix = "!"

client.on(`message`, message => {
  if (message.content === prefix + `ping`) {
    message.channel.send("Pong! ");
  }
  if (message.content === prefix + `help`) {
    message.channel.send('COMMANDS LIST:\n**' + prefix + 'ping** - Pong!');
  }
  if (message.mentions.has(client.user.id)) {
        message.channel.send("Why you ping me??");
    }
  if(message.content.startsWith(prefix + `prefix`))
  {
    prefix = //message after '!prefix'
    message.channel.send("Prefix has now been updated to " + prefix)
  }
});
 
client.login('BOT-TOKEN');
0 Answers
Related