(discord.js) Check if bot has permissions doesn't work

Many people have said to use message.member.guild.me.hasPermission("PERMISSION") {
to check if the bot has a permission. It used to work, but for some reason it stopped working which is really confusing to me because I am a new coder.

Edit – Here is my full code for more context:

module.exports = {
    name: "help",
    description: "Displays an embed with all the commands of the bot.",
    execute(client, message, args, Discord, msgAuthor) {
        const channel = message;
        
        if (message.member.guild.me.hasPermission("EMBED_LINKS" || "ADMINISTRATOR")) {
            if (!args[0]) {
                const newEmbed = new Discord.MessageEmbed()
                    .setColor('000000')
                    .setTitle('Esando Bot commands')
                    .setDescription('Remember to use the prefix at the start of any command!')
                    .addFields(
                        { name: 'help music', value: "Displays an embed for help regarding music." },
                        { name: 'invite', value: "Sends the invite link to the Esando Community server." },
                        { name: 'kick [@member]', value: 'Kicks a specified member from the server.' },
                        { name: 'ban [@member]', value: 'Bans a specified member from the server.' },
                        { name: 'slowmode [seconds]', value: "Sets the channels slowmode cooldown. You can use 'slowmode off' to turn off slowmode." },
                    )
                    .setFooter("Esando Bot", "https://cdn.discordapp.com/attachments/786845863787626517/791421970200657940/bot3.png")

                message.channel.send(newEmbed);
            } else if (args[0] == 'music') {
                const newEmbed = new Discord.MessageEmbed()
                    .setColor('000000')
                    .setTitle('Esando Bot music commands')
                    .setDescription('Remember to use the prefix at the start of any command!')
                    .addFields(
                        { name: 'play ', value: "Searches YouTube for that video and plays the first search result as audio. (You can also use URL's)" },
                        { name: 'leave', value: "Disconnects the bot from the voice channel (you must be in the same voice channel to execute this command)." },
                    )
                    .setFooter("Esando Bot", "https://cdn.discordapp.com/attachments/786845863787626517/791421970200657940/bot3.png")

                message.channel.send(newEmbed);
            }
        } else {
            message.channel.send(`${msgAuthor} I don't have sufficient permissions to send embeds in ${channel}! To change this, make sure me or my role have the 'Embed Links' permission for this channel.`);
        }
    }
}

25 thoughts on “(discord.js) Check if bot has permissions doesn't work”

Leave a Comment