User need to be authorized bug

Hey, so everytime my partner managers try to run /partner or /partner-category they can't run because of this if statement blocking them to use it. I am a bit confused how to fix it because I have read over several stack overflow post that other users had similar bugs like me.

This is my code below, and the role id is stored in a database

        const roleId = interaction.guild.roles.fetch(yourGuildData.partnerRoleId);
        const memberRoles = await interaction.member.fetch(interaction.user.id);
        const userIsAuthorized = interaction.user.id === interaction.guild.ownerId || yourGuildData.managers?.includes(interaction.user.id) || memberRoles.roles.cache.has(roleId.id);
        if (!userIsAuthorized) {
            await interaction.reply("Only the server owner or authorized users can use this command.");
            return;
        }
Was this page helpful?