In my discord server, I have a suggestion channel for members to give suggestions. So, I want my bot to delete message sent in that channel unless it begins with the word "suggestion". I'm new to JavaScript and discord bot making so I was wondering if anyone could help me out
1
votes
2 Answers
0
votes
This should work for you. I would suggest maybe attempting to code what you want, if you cannot figure out how to do it then ask for help.
Other than that, Have a good day chief.
client.on('message', message => {
const channelID = "CHANNELID" // change this to the channels id
const requiredWord = "!suggestion" // what the message should start with
// check if the message.channel.id is the same as the channelID for suggestion page
if (message.channel.id == channelID) {
// check if it starts with requiredWord
if (message.content.startsWith(requiredWord) {
// console.log suggestion allowed
console.log("Suggestion Allowed")
} else {
// else delete the message.
message.delete()
}
}
});