How to delete a discord msg with a bot

I was wondering how to delete a command msg
So if I did the command
(Prefix)hello
It would delete the msg I sent
Also how would I randomise a message so say I said (prefix)random
It would say either A B or C

Hey @oPANDAHUBo,

You can use message.delete() to delete a message.

Hope this helps in some way!

Hmm ty how would I make it delete the command msg

message.channel.send(“hello”).then(m=>m.delete({timeout:500}).catch(e=>{}))

500 milliseconds to prevent bugs, and catch if theres an error (message is deleted before bot can delete it)

this is on version 12.x

if on 11.x, everything is the same except remove the {timeout} and have m.delete(500)

1 Like

Ok thanks :smiley:

and for the A B or C

im assuming you are on discord.js anyways

let letters = [“a”,“b”,“c”]
let randomletters = letters[Math.floor(Math.random() * letters.length)]

message.channel.send(randomletters)

google “arrays in javascript” to help you understand this

1 Like

I really suggest you use async/await as it will de-clutter your code.