I have a command which allows users to make the bot to say a message, but I would like it to be able to check whether the user is able to send messages in that channel before it sends it. Currently, I just have it locked to the Manage Messages permission.
Here is the code:
if (message.member.hasPermission("MANAGE_MESSAGES")) {
let msg;
let textChannel = message.mentions.channels.first();
message.delete();
if (textChannel) {
msg = args.slice(1).join(" ");
if (msg === "") {
message.channel.send("Please input a valid sentence/word.")
} else {
textChannel.send(`**Message from ${message.author.tag}:** ${msg}`)
}
} else {
msg = args.join(" ");
if (msg === "") {
message.channel.send("Please input a valid sentence/word.")
} else {
message.channel.send(`**Message from ${message.author.tag}:** ${msg}`)
}
}
} else {
message.reply('You lack the required permissions to do that. (Required Permissions: ``MANAGE_MESSAGES``)')
}
I have searched and couldn't find much on this, any help is appreciated