Skip to content
← Back to Community
pls help me. how do i make a clean message command for my discord bot using node.js
Profile icon
Johnplayz1123

so i started making a bot for my discord server, i done all of the respond commands now i need is how to delete multiple messages for my bot, Pls help me

Voters
Profile icon
AlessandroStrac
Profile icon
Johnplayz1123
Comments
hotnewtop
Profile icon
alanchen12

You can use the bulk delete function that discord.js provides here.

Just fetch messages from a channel and bulk delete them.
Ex:

message.channel.messages.fetch({limit: AMOUNT OF MESSAGES}).then((messages) => {message.channel.bulkDelete(messages).catch(console.error)});
Profile icon
cookieisgud

try this link

please mark as correct answer, thanks!

Profile icon
Whacko
client.on('message', msg => { if (msg.content == "ping") { msg.channel.send("Pong!"); } });