P
P
P4eLoVe4ek2022-02-03 20:23:33
Node.js
P4eLoVe4ek, 2022-02-03 20:23:33

I can't understand the bot prefix (code written in discord.js)?

I wanted to make a music bot but failed with discord.py so I wanted to try with discord.js and I did but I can't figure out the bot prefix. Here is the code:

const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
    const command = args.shift();
    let guildQueue = client.player.getQueue(message.guild.id);

I can't figure out what prefix the bot has? (in the config I wrote a prefix for the bot - !).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2022-02-05
@P4eLoVe4ek

config is just a data store.
therefore, by adding something there, you will not change anything until you use this data in the code.
if you want the bot to respond to a specific prefix from the config, you can do something like this:

if (message.content.startsWith(`${settings.prefix}название_команды1`)) {
    /* ... */
} else if (message.content.startsWith(`${settings.prefix}название_команды2`)) {
    /* ... */
} // и т.д

then if the message starts with
(prefix)your_team_name
...your code will run.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question