Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

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

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');
about 4 years ago ยท Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!