Skip to content

Commit

Permalink
Handle UIB interactions for ignoring channels.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kowlin committed Jan 6, 2025
1 parent cd0e875 commit b1e8631
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion redbot/core/_settings_caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,18 @@ async def get_ignored_channel(
discord.StageChannel,
discord.ForumChannel,
discord.Thread,
discord.Object, # This is solely here for the purpose of User Installed Bots,
# See Red#6501 & ignored_channel_or_guild in redbot/core/bot.py for more details.
],
check_category: bool = True,
) -> bool:
ret: bool

cid: int = channel.id
cat_id: Optional[int] = (
channel.category.id if check_category and channel.category else None
channel.category.id
if check_category and hasattr(channel, "category") and channel.category is not None
else None
)
if cid in self._cached_channels:
chan_ret = self._cached_channels[cid]
Expand Down
13 changes: 12 additions & 1 deletion redbot/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,18 @@ async def ignored_channel_or_guild(
return True

if isinstance(ctx.channel, discord.Thread):
channel = ctx.channel.parent
if isinstance(ctx, discord.Interaction) and ctx.is_user_integration():
ctx: discord.Interaction
# This is a user installed interaction, and thus... We're doomed!
# We must mock an object because we don't have the channel cached,
# and we are unable to fetch a full channel from the interaction
# #BlameDiscord, See Red#6501 for more details.

# LIMITATIONS: Due the fact that we don't know the categories either as they aren't...
# communicated in the interaction, we can't check for category ignores.
channel = discord.Object(id=ctx.channel.parent_id)
else:
channel = ctx.channel.parent
thread = ctx.channel
else:
channel = ctx.channel
Expand Down

0 comments on commit b1e8631

Please # to comment.