I made a lock command for my bot which runs on a framework called, discord.js-commando. This command locks a channel by not letting users send messages. The error is at line if(perms.deny.has('SEND_MESSAGES')
. The error is Cannot read property 'deny' of undefined
.
- MY CODE
async run(msg, args){
// For Text Channel
if(args.channel.type === 'text'){
const perms = args.channel.permissionOverwrites.get(msg.guild.id);
if(perms.deny.has(`SEND_MESSAGES`)){
return msg.reply(
new MessageEmbed()
.setDescription(`⚠️ | Channel is already locked`)
.setColor('BLUE')
)
} else {
args.channel.updateOverwrite(msg.guild.roles.everyone, {
SEND_MESSAGES: false
}).catch(err => {
return msg.channel.send(new MessageEmbed()
.setDescription(`<:xmarkxl:870951478913806396> | Failed to lock channel, \`${err}\``)
.setColor('RED')
)
})
await msg.channel.send(
new MessageEmbed()
.setDescription(`<:checkmarkxl:870951478829936710> | Successfully Locked <#${args.channel.id}>`)
.setColor("GREEN")
)
}
}
I want to know if there's an easy way to check if @everyone have permission to send messages in the channel to lock.