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

fix(ClientPermissions): check app permissions when used with user apps #797

Merged
merged 3 commits into from
Nov 4, 2024

Conversation

yuansheng1549
Copy link
Contributor

interaction.channel will always be null when used with user-installable and since ClientPermissions always fetch the invoked interaction channel, it will throw an error causing "The application did not respond"

protected async fetchChannelFromInteraction(interaction: CommandInteraction): Promise<TextBasedChannel> {
const channel = (await interaction.client.channels.fetch(interaction.channelId, {
cache: false,
allowUnknownGuild: true
})) as TextBasedChannel;
return channel;
}

image

src/preconditions/ClientPermissions.ts Outdated Show resolved Hide resolved
@yuansheng1549 yuansheng1549 changed the title fix(ClientPermissions): always return this.ok when channel is null fix(ClientPermissions): check app permissions when used with user apps Nov 3, 2024
if (interaction.channel) {
if (interaction.channel.isDMBased()) return this.dmChannelPermissions;

const channel = await this.fetchChannelFromInteraction(interaction);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fetch feels redundant now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better safe than sorry and it's gonna come out of the cache anyway if it's there.

@favna favna merged commit ebdf0f7 into sapphiredev:main Nov 4, 2024
7 checks passed
@yuansheng1549 yuansheng1549 deleted the fix/fix-client-permissions branch November 5, 2024 06:40
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

Successfully merging this pull request may close these issues.

4 participants