I'm trying to make my bot delete the 4 messages after 15 seconds, but I don't know how to make it do that.
const mando = require('discord.js-mando');
class HitOrMissCommand extends mando.Command
{
constructor(client)
{
super(client,{
name: 'hitormiss',
group: 'simple',
memberName: 'hitormiss',
description: 'i bet he doesnt kiss yah!'
});
}
async run(message, args)
{
message.reply("I guess they never miss, huh?")
message.reply("you got a boyfriend i bet he doesnt kiss yah!, MWAH!")
message.reply("He gon find another girl and he wont miss yah")
message.reply("He gon skirt and hit the dab like wiz khalifa")
}
}
module.exports = HitOrMissCommand;
I'm trying to make my bot delete the 4 messages after 15 seconds, but I don't know how to make it do that.
const mando = require('discord.js-mando');
class HitOrMissCommand extends mando.Command
{
constructor(client)
{
super(client,{
name: 'hitormiss',
group: 'simple',
memberName: 'hitormiss',
description: 'i bet he doesnt kiss yah!'
});
}
async run(message, args)
{
message.reply("I guess they never miss, huh?")
message.reply("you got a boyfriend i bet he doesnt kiss yah!, MWAH!")
message.reply("He gon find another girl and he wont miss yah")
message.reply("He gon skirt and hit the dab like wiz khalifa")
}
}
module.exports = HitOrMissCommand;
Share
Improve this question
edited Jan 8, 2019 at 15:34
Federico Grandi
6,7865 gold badges33 silver badges51 bronze badges
asked Jan 8, 2019 at 3:00
CIACIA
671 gold badge2 silver badges9 bronze badges
1
- 3 Possible duplicate of Discord.js: Send message and shortly delete it – makertech81 Commented Jan 8, 2019 at 3:07
4 Answers
Reset to default 3if (message.content.startsWith(`!test`)) {
await message.channel.send('Hello').then(r => r.delete({ timeout: 5000 }))
console.log("test");
}
Might want to check out this question here.
As answered in that post the best way to do that is by deleting the message after x amount of seconds.
message.reply('Hit or miss.')
.then(msg => {
msg.delete(10000)
})
.catch(); /*Used for error handling*/
Proper credit should go to user LW001 who answered the question on the post I referred to.
Since this question is similar, you could use the same technique - adding a deletion timout. After you reply, .then()
delete the message with your 15 second timer (15000 milliseconds):
message.reply("I guess they never miss, huh?").then(message => message.delete(15000)).catch(err => throw err);
Or if you can't use arrow syntax:
message.reply("I guess they never miss, huh?").then(function(message) {
message.delete(15000);
}).catch(function(err) {
throw err;
});
It could be done like this.
var replyM = message.reply("I guess they never miss, huh?")
setTimeout(function(){
replyM.delete
}, 1000);