mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 09:52:30 -05:00
Port TiV changes applied to voice channels to stage channels (#6109)
This commit is contained in:
@@ -38,7 +38,9 @@ class IssueDiagnoserBase:
|
||||
self,
|
||||
bot: Red,
|
||||
original_ctx: commands.Context,
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread],
|
||||
channel: Union[
|
||||
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
|
||||
],
|
||||
author: discord.Member,
|
||||
command: commands.Command,
|
||||
) -> None:
|
||||
|
||||
@@ -156,7 +156,11 @@ class IgnoreManager:
|
||||
async def get_ignored_channel(
|
||||
self,
|
||||
channel: Union[
|
||||
discord.TextChannel, discord.VoiceChannel, discord.ForumChannel, discord.Thread
|
||||
discord.TextChannel,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
discord.ForumChannel,
|
||||
discord.Thread,
|
||||
],
|
||||
check_category: bool = True,
|
||||
) -> bool:
|
||||
@@ -188,6 +192,7 @@ class IgnoreManager:
|
||||
channel: Union[
|
||||
discord.TextChannel,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
discord.Thread,
|
||||
discord.ForumChannel,
|
||||
discord.CategoryChannel,
|
||||
|
||||
@@ -837,7 +837,10 @@ class Red(
|
||||
return False
|
||||
|
||||
if guild:
|
||||
assert isinstance(channel, (discord.TextChannel, discord.VoiceChannel, discord.Thread))
|
||||
assert isinstance(
|
||||
channel,
|
||||
(discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread),
|
||||
)
|
||||
if not can_user_send_messages_in(guild.me, channel):
|
||||
return False
|
||||
if not (await self.ignored_channel_or_guild(message)):
|
||||
@@ -1291,6 +1294,7 @@ class Red(
|
||||
channel: Union[
|
||||
discord.TextChannel,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
commands.Context,
|
||||
discord.User,
|
||||
discord.Member,
|
||||
@@ -1305,7 +1309,7 @@ class Red(
|
||||
|
||||
Arguments
|
||||
---------
|
||||
channel : Union[`discord.TextChannel`, `discord.VoiceChannel`, `commands.Context`, `discord.User`, `discord.Member`, `discord.Thread`]
|
||||
channel : Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.StageChannel`, `commands.Context`, `discord.User`, `discord.Member`, `discord.Thread`]
|
||||
The target messageable object to check embed settings for.
|
||||
|
||||
Keyword Arguments
|
||||
@@ -1352,7 +1356,10 @@ class Red(
|
||||
"You cannot pass a GroupChannel, DMChannel, or PartialMessageable to this method."
|
||||
)
|
||||
|
||||
if isinstance(channel, (discord.TextChannel, discord.VoiceChannel, discord.Thread)):
|
||||
if isinstance(
|
||||
channel,
|
||||
(discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread),
|
||||
):
|
||||
channel_id = channel.parent_id if isinstance(channel, discord.Thread) else channel.id
|
||||
|
||||
if check_permissions and not channel.permissions_for(channel.guild.me).embed_links:
|
||||
@@ -2075,7 +2082,9 @@ class Red(
|
||||
|
||||
async def get_owner_notification_destinations(
|
||||
self,
|
||||
) -> List[Union[discord.TextChannel, discord.VoiceChannel, discord.User]]:
|
||||
) -> List[
|
||||
Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.User]
|
||||
]:
|
||||
"""
|
||||
Gets the users and channels to send to
|
||||
"""
|
||||
|
||||
@@ -315,7 +315,11 @@ if TYPE_CHECKING or os.getenv("BUILDING_DOCS", False):
|
||||
...
|
||||
|
||||
@property
|
||||
def channel(self) -> Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]:
|
||||
def channel(
|
||||
self,
|
||||
) -> Union[
|
||||
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
|
||||
]:
|
||||
...
|
||||
|
||||
@property
|
||||
|
||||
@@ -889,7 +889,12 @@ class RedHelpFormatter(HelpFormatterABC):
|
||||
# We need to wrap this in a task to not block after-sending-help interactions.
|
||||
# The channel has to be TextChannel or Thread as we can't bulk-delete from DMs
|
||||
async def _delete_delay_help(
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread],
|
||||
channel: Union[
|
||||
discord.TextChannel,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
discord.Thread,
|
||||
],
|
||||
messages: List[discord.Message],
|
||||
delay: int,
|
||||
):
|
||||
|
||||
@@ -73,6 +73,7 @@ _T = TypeVar("_T")
|
||||
GlobalPermissionModel = Union[
|
||||
discord.User,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
discord.TextChannel,
|
||||
discord.ForumChannel,
|
||||
discord.CategoryChannel,
|
||||
@@ -82,6 +83,7 @@ GlobalPermissionModel = Union[
|
||||
GuildPermissionModel = Union[
|
||||
discord.Member,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
discord.TextChannel,
|
||||
discord.ForumChannel,
|
||||
discord.CategoryChannel,
|
||||
|
||||
@@ -1371,7 +1371,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
async def embedset_channel(
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.ForumChannel],
|
||||
channel: Union[
|
||||
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.ForumChannel
|
||||
],
|
||||
enabled: bool = None,
|
||||
):
|
||||
"""
|
||||
@@ -1387,10 +1389,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
**Examples:**
|
||||
- `[p]embedset channel #text-channel False` - Disables embeds in the #text-channel.
|
||||
- `[p]embedset channel #forum-channel disable` - Disables embeds in the #forum-channel.
|
||||
- `[p]embedset channel #text-channel` - Resets value to use guild default in the #text-channel .
|
||||
- `[p]embedset channel #text-channel` - Resets value to use guild default in the #text-channel.
|
||||
|
||||
**Arguments:**
|
||||
- `<channel>` - The text, voice, or forum channel to set embed setting for.
|
||||
- `<channel>` - The text, voice, stage, or forum channel to set embed setting for.
|
||||
- `[enabled]` - Whether to use embeds in this channel. Leave blank to reset to default.
|
||||
"""
|
||||
if enabled is None:
|
||||
@@ -2709,7 +2711,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
async def modlogset_modlog(
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel] = None,
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel] = None,
|
||||
):
|
||||
"""Set a channel as the modlog.
|
||||
|
||||
@@ -3713,7 +3715,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
|
||||
@_set_ownernotifications.command(name="adddestination")
|
||||
async def _set_ownernotifications_adddestination(
|
||||
self, ctx: commands.Context, *, channel: Union[discord.TextChannel, discord.VoiceChannel]
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
*,
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
|
||||
):
|
||||
"""
|
||||
Adds a destination text channel to receive owner notifications.
|
||||
@@ -3738,7 +3743,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
*,
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel, int],
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, int],
|
||||
):
|
||||
"""
|
||||
Removes a destination text channel from receiving owner notifications.
|
||||
@@ -4692,7 +4697,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
channel: Optional[
|
||||
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]
|
||||
Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread]
|
||||
] = commands.CurrentChannel,
|
||||
# avoid non-default argument following default argument by using empty param()
|
||||
member: Union[discord.Member, discord.User] = commands.param(),
|
||||
@@ -4716,7 +4721,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
if ctx.guild is None:
|
||||
await ctx.send(
|
||||
_(
|
||||
"A text channel, voice channel, or thread needs to be passed"
|
||||
"A text channel, voice channel, stage channel, or thread needs to be passed"
|
||||
" when using this command in DMs."
|
||||
)
|
||||
)
|
||||
@@ -5683,6 +5688,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
channel: Union[
|
||||
discord.TextChannel,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
discord.ForumChannel,
|
||||
discord.CategoryChannel,
|
||||
discord.Thread,
|
||||
@@ -5741,6 +5747,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
channel: Union[
|
||||
discord.TextChannel,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
discord.ForumChannel,
|
||||
discord.CategoryChannel,
|
||||
discord.Thread,
|
||||
@@ -5784,23 +5791,23 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
||||
|
||||
async def count_ignored(self, ctx: commands.Context):
|
||||
category_channels: List[discord.CategoryChannel] = []
|
||||
channels: List[Union[discord.TextChannel, discord.VoiceChannel, discord.ForumChannel]] = []
|
||||
channels: List[
|
||||
Union[
|
||||
discord.TextChannel,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
discord.ForumChannel,
|
||||
]
|
||||
] = []
|
||||
threads: List[discord.Thread] = []
|
||||
if await self.bot._ignored_cache.get_ignored_guild(ctx.guild):
|
||||
return _("This server is currently being ignored.")
|
||||
for channel in ctx.guild.text_channels:
|
||||
if channel.category and channel.category not in category_channels:
|
||||
if await self.bot._ignored_cache.get_ignored_channel(channel.category):
|
||||
category_channels.append(channel.category)
|
||||
if await self.bot._ignored_cache.get_ignored_channel(channel, check_category=False):
|
||||
channels.append(channel)
|
||||
for channel in ctx.guild.voice_channels:
|
||||
if channel.category and channel.category not in category_channels:
|
||||
if await self.bot._ignored_cache.get_ignored_channel(channel.category):
|
||||
category_channels.append(channel.category)
|
||||
if await self.bot._ignored_cache.get_ignored_channel(channel, check_category=False):
|
||||
channels.append(channel)
|
||||
for channel in ctx.guild.forums:
|
||||
for channel in itertools.chain(
|
||||
ctx.guild.text_channels,
|
||||
ctx.guild.voice_channels,
|
||||
ctx.guild.stage_channels,
|
||||
ctx.guild.forums,
|
||||
):
|
||||
if channel.category and channel.category not in category_channels:
|
||||
if await self.bot._ignored_cache.get_ignored_channel(channel.category):
|
||||
category_channels.append(channel.category)
|
||||
|
||||
@@ -649,7 +649,7 @@ class Case:
|
||||
@classmethod
|
||||
async def from_json(
|
||||
cls,
|
||||
mod_channel: Union[discord.TextChannel, discord.VoiceChannel],
|
||||
mod_channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
|
||||
bot: Red,
|
||||
case_number: int,
|
||||
data: dict,
|
||||
@@ -659,7 +659,7 @@ class Case:
|
||||
|
||||
Parameters
|
||||
----------
|
||||
mod_channel: `discord.TextChannel` or `discord.VoiceChannel`
|
||||
mod_channel: `discord.TextChannel` or `discord.VoiceChannel`, `discord.StageChannel`
|
||||
The mod log channel for the guild
|
||||
bot: Red
|
||||
The bot's instance. Needed to get the target user
|
||||
@@ -1252,7 +1252,7 @@ async def register_casetypes(new_types: List[dict]) -> List[CaseType]:
|
||||
|
||||
async def get_modlog_channel(
|
||||
guild: discord.Guild,
|
||||
) -> Union[discord.TextChannel, discord.VoiceChannel]:
|
||||
) -> Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel]:
|
||||
"""
|
||||
Get the current modlog channel.
|
||||
|
||||
@@ -1263,7 +1263,7 @@ async def get_modlog_channel(
|
||||
|
||||
Returns
|
||||
-------
|
||||
`discord.TextChannel` or `discord.VoiceChannel`
|
||||
`discord.TextChannel`, `discord.VoiceChannel`, or `discord.StageChannel`
|
||||
The channel object representing the modlog channel.
|
||||
|
||||
Raises
|
||||
@@ -1283,7 +1283,8 @@ async def get_modlog_channel(
|
||||
|
||||
|
||||
async def set_modlog_channel(
|
||||
guild: discord.Guild, channel: Union[discord.TextChannel, discord.VoiceChannel, None]
|
||||
guild: discord.Guild,
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, None],
|
||||
) -> bool:
|
||||
"""
|
||||
Changes the modlog channel
|
||||
@@ -1292,7 +1293,7 @@ async def set_modlog_channel(
|
||||
----------
|
||||
guild: `discord.Guild`
|
||||
The guild to set a mod log channel for
|
||||
channel: `discord.TextChannel`, `discord.VoiceChannel`, or `None`
|
||||
channel: `discord.TextChannel`, `discord.VoiceChannel`, `discord.StageChannel`, or `None`
|
||||
The channel to be set as modlog channel
|
||||
|
||||
Returns
|
||||
|
||||
@@ -35,7 +35,11 @@ from redbot.core import commands
|
||||
|
||||
if TYPE_CHECKING:
|
||||
GuildMessageable = Union[
|
||||
commands.GuildContext, discord.TextChannel, discord.VoiceChannel, discord.Thread
|
||||
commands.GuildContext,
|
||||
discord.TextChannel,
|
||||
discord.VoiceChannel,
|
||||
discord.StageChannel,
|
||||
discord.Thread,
|
||||
]
|
||||
DMMessageable = Union[commands.DMContext, discord.Member, discord.User, discord.DMChannel]
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ __all__ = (
|
||||
|
||||
async def mass_purge(
|
||||
messages: List[discord.Message],
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread],
|
||||
channel: Union[
|
||||
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
|
||||
],
|
||||
*,
|
||||
reason: Optional[str] = None,
|
||||
):
|
||||
@@ -39,7 +41,7 @@ async def mass_purge(
|
||||
----------
|
||||
messages : `list` of `discord.Message`
|
||||
The messages to bulk delete.
|
||||
channel : `discord.TextChannel`, `discord.VoiceChannel`, or `discord.Thread`
|
||||
channel : `discord.TextChannel`, `discord.VoiceChannel`, `discord.StageChannel`, or `discord.Thread`
|
||||
The channel to delete messages from.
|
||||
reason : `str`, optional
|
||||
The reason for bulk deletion, which will appear in the audit log.
|
||||
|
||||
@@ -317,7 +317,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
||||
def valid_role(
|
||||
cls,
|
||||
ctx: Optional[commands.Context] = None,
|
||||
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]] = None,
|
||||
channel: Optional[
|
||||
Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread]
|
||||
] = None,
|
||||
user: Optional[discord.abc.User] = None,
|
||||
) -> "MessagePredicate":
|
||||
"""Match if the response refers to a role in the current guild.
|
||||
@@ -330,7 +332,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
||||
----------
|
||||
ctx : Optional[Context]
|
||||
Same as ``ctx`` in :meth:`same_context`.
|
||||
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`]]
|
||||
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.StageChannel`, `discord.Thread`]]
|
||||
Same as ``channel`` in :meth:`same_context`.
|
||||
user : Optional[discord.abc.User]
|
||||
Same as ``user`` in :meth:`same_context`.
|
||||
@@ -361,7 +363,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
||||
def valid_member(
|
||||
cls,
|
||||
ctx: Optional[commands.Context] = None,
|
||||
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]] = None,
|
||||
channel: Optional[
|
||||
Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread]
|
||||
] = None,
|
||||
user: Optional[discord.abc.User] = None,
|
||||
) -> "MessagePredicate":
|
||||
"""Match if the response refers to a member in the current guild.
|
||||
@@ -374,7 +378,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
||||
----------
|
||||
ctx : Optional[Context]
|
||||
Same as ``ctx`` in :meth:`same_context`.
|
||||
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`]]
|
||||
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.StageChannel`, `discord.Thread`]]
|
||||
Same as ``channel`` in :meth:`same_context`.
|
||||
user : Optional[discord.abc.User]
|
||||
Same as ``user`` in :meth:`same_context`.
|
||||
@@ -409,7 +413,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
||||
def valid_text_channel(
|
||||
cls,
|
||||
ctx: Optional[commands.Context] = None,
|
||||
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]] = None,
|
||||
channel: Optional[
|
||||
Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread]
|
||||
] = None,
|
||||
user: Optional[discord.abc.User] = None,
|
||||
) -> "MessagePredicate":
|
||||
"""Match if the response refers to a text channel in the current guild.
|
||||
@@ -422,7 +428,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
||||
----------
|
||||
ctx : Optional[Context]
|
||||
Same as ``ctx`` in :meth:`same_context`.
|
||||
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`]]
|
||||
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.StageChannel`, `discord.Thread`]]
|
||||
Same as ``channel`` in :meth:`same_context`.
|
||||
user : Optional[discord.abc.User]
|
||||
Same as ``user`` in :meth:`same_context`.
|
||||
@@ -457,7 +463,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
||||
def has_role(
|
||||
cls,
|
||||
ctx: Optional[commands.Context] = None,
|
||||
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]] = None,
|
||||
channel: Optional[
|
||||
Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread]
|
||||
] = None,
|
||||
user: Optional[discord.abc.User] = None,
|
||||
) -> "MessagePredicate":
|
||||
"""Match if the response refers to a role which the author has.
|
||||
@@ -471,7 +479,7 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
||||
----------
|
||||
ctx : Optional[Context]
|
||||
Same as ``ctx`` in :meth:`same_context`.
|
||||
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.Thread`]]
|
||||
channel : Optional[Union[`discord.TextChannel`, `discord.VoiceChannel`, `discord.StageChannel`, `discord.Thread`]]
|
||||
Same as ``channel`` in :meth:`same_context`.
|
||||
user : Optional[discord.abc.User]
|
||||
Same as ``user`` in :meth:`same_context`.
|
||||
@@ -833,7 +841,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
|
||||
@staticmethod
|
||||
def _get_guild(
|
||||
ctx: Optional[commands.Context],
|
||||
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]],
|
||||
channel: Optional[
|
||||
Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread]
|
||||
],
|
||||
user: Optional[discord.Member],
|
||||
) -> discord.Guild:
|
||||
if ctx is not None:
|
||||
|
||||
@@ -59,7 +59,7 @@ class Tunnel(metaclass=TunnelMeta):
|
||||
----------
|
||||
sender: `discord.Member`
|
||||
The person who opened the tunnel
|
||||
origin: `discord.TextChannel`, `discord.VoiceChannel`, or `discord.Thread`
|
||||
origin: `discord.TextChannel`, `discord.VoiceChannel`, `discord.StageChannel`, or `discord.Thread`
|
||||
The channel in which it was opened
|
||||
recipient: `discord.User`
|
||||
The user on the other end of the tunnel
|
||||
@@ -69,7 +69,9 @@ class Tunnel(metaclass=TunnelMeta):
|
||||
self,
|
||||
*,
|
||||
sender: discord.Member,
|
||||
origin: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread],
|
||||
origin: Union[
|
||||
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
|
||||
],
|
||||
recipient: discord.User,
|
||||
):
|
||||
self.sender = sender
|
||||
|
||||
Reference in New Issue
Block a user