mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2026-03-07 04:38:35 -05:00
Handle UIB interactions for ignoring channels. (#6503)
Co-authored-by: Michael Oliveira <34169552+Flame442@users.noreply.github.com> Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
@@ -5,4 +5,7 @@ from . import commands
|
||||
def init_global_checks(bot):
|
||||
@bot.check_once
|
||||
async def check_message_is_eligible_as_command(ctx: commands.Context) -> bool:
|
||||
if ctx.interaction is not None:
|
||||
# equivalent checks are performed by `RedTree.interaction_check`
|
||||
return True
|
||||
return await ctx.bot.message_eligible_as_command(ctx.message)
|
||||
|
||||
@@ -161,6 +161,8 @@ class IgnoreManager:
|
||||
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:
|
||||
@@ -168,7 +170,9 @@ class IgnoreManager:
|
||||
|
||||
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]
|
||||
|
||||
@@ -819,6 +819,9 @@ class Red(
|
||||
Whether or not the message is eligible to be treated as a command.
|
||||
"""
|
||||
|
||||
# NOTE: any changes to implementation here may need to be made
|
||||
# in the `RedTree.interaction_check` as well
|
||||
|
||||
channel = message.channel
|
||||
guild = message.guild
|
||||
|
||||
@@ -911,7 +914,18 @@ class Red(
|
||||
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
|
||||
|
||||
@@ -5789,7 +5789,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
|
||||
The ignore list will prevent the bot from responding to commands in the configured locations.
|
||||
|
||||
Note: Owners and Admins override the ignore list.
|
||||
Notes:
|
||||
- Category ignores are ignored by user-installed commands
|
||||
- Owners, Admins, and those with Manage Channel permissions override ignored channels.
|
||||
"""
|
||||
|
||||
@ignore.command(name="list")
|
||||
@@ -5821,7 +5823,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
|
||||
Defaults to the current thread or channel.
|
||||
|
||||
Note: Owners, Admins, and those with Manage Channel permissions override ignored channels.
|
||||
Notes:
|
||||
- Category ignores are ignored by user-installed commands
|
||||
- Owners, Admins, and those with Manage Channel permissions override ignored channels.
|
||||
|
||||
**Examples:**
|
||||
- `[p]ignore channel #general` - Ignores commands in the #general channel.
|
||||
|
||||
Reference in New Issue
Block a user