Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button denied code #44

Open
Greensky-gs opened this issue Feb 16, 2024 · 1 comment
Open

Button denied code #44

Greensky-gs opened this issue Feb 16, 2024 · 1 comment

Comments

@Greensky-gs
Copy link
Owner

Wrong code in button denietion (permissions) :

if (interaction.guild && handler.options?.clientPermissions?.length > 0) {
            const missing = [];
            for (const perm of handler.options.clientPermissions) {
                if (!interaction.guild.members.me.permissions.has(perm))
                    missing.push(perm);
            }
            if (missing.length > 0) {
                return interaction.client.emit('buttonDenied', {
                    button: interaction,
                    message: 'Client is missing permissions',
                    metadata: {
                        permissions: {
                            got: interaction.guild.members.me.permissions.toArray().filter((x) => !missing.includes(x)),
                            need: handler.options.clientPermissions,
                            missing
                        },
                        code: ButtonHandler_1.ButtonDeniedCode.ClientMissingPerms
                    },
                    user: interaction.user
                });
            }
        }
        if (interaction.guild && handler.options?.permissions?.length > 0) {
            const missing = [];
            const perms = interaction.member.permissions;
            for (const perm of handler.options.permissions) {
                if (!perms.has(perm))
                    missing.push(perm);
            }
            if (missing.length > 0) {
                return interaction.client.emit('buttonDenied', {
                    button: interaction,
                    message: 'Client is missing permissions',
                    metadata: {
                        permissions: {
                            got: perms.toArray().filter((x) => !missing.includes(x)),
                            need: handler.options.clientPermissions,
                            missing
                        },
                        code: ButtonHandler_1.ButtonDeniedCode.ClientMissingPerms // Here, we expect MissingPerms and not ClientMissingPerms
                    },
                    user: interaction.user
                });
            }
        }
@Greensky-gs
Copy link
Owner Author

Fixed in fa5e4fc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant