1
votes

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

2
At least start with something that doesn't work, then come for advice & help. No one is going to discuss Discord bot making in it's entirety here.x1n13y84issmd42

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()
    }

}


});
-1
votes

if(!message.content.startsWith('word')) return msg.delete().then(msg => msg.channel.send("It does not contain the starting word"))