I'm having trouble coding my bot for people who have MANAGE_MESSAGES to be able to say 'badword'. Here is my code:
const Discord = require('discord.js')
const bot = new Discord.Client()
const token = process.env.DISCORD_TOKEN
let set = new Set(['badword'])
bot.on('message', msg => {
if (msg.author.bot) {
return
}
let wordArray = msg.content.split(' ')
if (!msg.member.hasPermission('MANAGE_MESSAGES')) {
for(var i = 0; i < wordArray.length; i++) {
if(set.has(wordArray[i].toLowerCase())) {
msg.delete()
msg.channel.send(`${msg.author.username}, you said a bad word.`)
break
}
console.log('message filtered')
}
}
})
bot.login(token)
The .permissions.has() is not working as according to this website https://discordjs.guide/additional-info/changes-in-v12.html#permissions-haspermission-s, it says that .hasPermission() / .hasPermissions() is now completely removed from v11 and added permissions.has(). Yes, my bot is upgraded to v12 so please help.