Check if my bot has perms in a channel?
Isn't this the correct way to do it?
I am on v14.3.0 though that was not an option for the tags.
// makes sure the bot can send messages in the channel this is ran in.
const channel = client.channels.cache.get(message.channel.id);
const botPermissionsIn = message.guild.me.permissionsIn(channel);
if(botPermissionsIn !== Discord.PermissionsBitField.Flags.SendMessages) return message.author.send('I can\'t send messages in that channel.');
const botPerms = [Discord.PermissionsBitField.Flags.SendMessages, Discord.PermissionsBitField.Flags.ViewChannel, Discord.PermissionsBitField.Flags.ReadMessageHistory, ]
let v = 0;
for(const i of botPerms) {
if(!message.guild.me.permissionsIn(channel).has(i)) {
v++
}
if(v == botPerms.length) {
message.react('❌');
return message.author.send('I do not have the necessary permissions for this channel. I need \`Read Message History, View Channel, and Send Messages.\`');
}
} // makes sure the bot can send messages in the channel this is ran in.
const channel = client.channels.cache.get(message.channel.id);
const botPermissionsIn = message.guild.me.permissionsIn(channel);
if(botPermissionsIn !== Discord.PermissionsBitField.Flags.SendMessages) return message.author.send('I can\'t send messages in that channel.');
const botPerms = [Discord.PermissionsBitField.Flags.SendMessages, Discord.PermissionsBitField.Flags.ViewChannel, Discord.PermissionsBitField.Flags.ReadMessageHistory, ]
let v = 0;
for(const i of botPerms) {
if(!message.guild.me.permissionsIn(channel).has(i)) {
v++
}
if(v == botPerms.length) {
message.react('❌');
return message.author.send('I do not have the necessary permissions for this channel. I need \`Read Message History, View Channel, and Send Messages.\`');
}
}