I want my bot to respond once to a mand such as .on
. However, it responds multiple times per input:
The code is:
client.on('message', message =>{
if(message.content === '.on'){
message.channel.sendMessage('Testing Bot is now Online, Greetings, ' + message.author.username);
}
If anyone could point me in the right direction to make the bot respond once that would be great.
I want my bot to respond once to a mand such as .on
. However, it responds multiple times per input:
The code is:
client.on('message', message =>{
if(message.content === '.on'){
message.channel.sendMessage('Testing Bot is now Online, Greetings, ' + message.author.username);
}
If anyone could point me in the right direction to make the bot respond once that would be great.
Share Improve this question edited Mar 28, 2018 at 17:10 cxw 17.1k2 gold badges48 silver badges84 bronze badges asked May 4, 2017 at 1:12 AaronAaron 431 gold badge3 silver badges10 bronze badges 3- Here is the answer on Duplicated question - https://stackoverflow./questions/51064042/discord-bot-still-answering-multiple-times-on-one-event – Oysho Boy Commented Jun 27, 2018 at 13:37
- 1 Extra points for Trump bot – Blairg23 Commented Apr 8, 2019 at 3:21
- This question is similar to: Discord bot still answering multiple times on one event. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. – tevemadar Commented Jan 19 at 0:17
3 Answers
Reset to default 0sendMessage
is deprecated. Try using send
instead.
client.on('message', message => {
if(message.content === '.on') {
message.channel.send('Testing Bot is now Online, Greetings, ' + message.author.username);
}
}
Also, if this still causes issues consider checking the id/content of the message event as well as the returned promise to make sure you didn't make a mistake elsewhere. It'll be obvious very quickly what's going on. That'd be:
client.on('message', message => {
if(message.content === '.on') {
console.log('Received #' + message.id + ': ' + message.content);
message.channel.send('Testing Bot is now Online, Greetings, ' + message.author.username)
.then(message => console.log('Sent #' + message.id + ': ' + message.content))
.catch(console.error);
}
}
I'm late, but I think you had multiple instances of your bot running at the same time.
Try to change the token, so all bots will stop working and then make sure, you just starting one instance.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745589446a4634743.html
评论列表(0条)