Fix permissions fetching for User Installable Bots (#6457)

Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
Kowlin 2024-12-24 15:16:03 +01:00 committed by GitHub
parent 9392077434
commit bd26e7d5af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -886,7 +886,12 @@ class Red(
if ctx.channel.type is not discord.ChannelType.private:
raise TypeError("Can't check permissions for non-private PartialMessageable.")
is_private = True
perms = ctx.channel.permissions_for(author)
if isinstance(ctx, discord.Message):
perms = ctx.channel.permissions_for(author)
else:
# `permissions` attribute will use permissions from the interaction when possible,
# or `ctx.channel.permissions_for(author)` for non-interaction contexts.
perms = ctx.permissions
surpass_ignore = (
is_private
or perms.manage_guild