Port TiV changes applied to voice channels to stage channels (#6109)

This commit is contained in:
Jakub Kuczys 2023-05-03 01:05:44 +02:00 committed by GitHub
parent f1439a37c8
commit 2fe251ecf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 213 additions and 95 deletions

View File

@ -1173,7 +1173,7 @@ embedset channel
.. code-block:: none .. code-block:: none
[p]embedset channel [enabled] [p]embedset channel <channel> [enabled]
**Description** **Description**
@ -1187,10 +1187,12 @@ If enabled is left blank, the setting will be unset and the guild default will b
To see full evaluation order of embed settings, run ``[p]help embedset``. To see full evaluation order of embed settings, run ``[p]help embedset``.
**Examples:** **Examples:**
- ``[p]embedset channel False`` - Disables embeds in this channel. - ``[p]embedset channel #text-channel False`` - Disables embeds in the #text-channel.
- ``[p]embedset channel`` - Resets value to use guild default. - ``[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.
**Arguments:** **Arguments:**
- ``<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. - ``[enabled]`` - Whether to use embeds in this channel. Leave blank to reset to default.
.. _core-command-embedset-command: .. _core-command-embedset-command:

View File

@ -115,11 +115,12 @@ Add words to the filter.
Use double quotes to add sentences. Use double quotes to add sentences.
Examples: Examples:
- ``[p]filter channel add word1 word2 word3`` - ``[p]filter channel add #channel word1 word2 word3``
- ``[p]filter channel add "This is a sentence"`` - ``[p]filter channel add #channel "This is a sentence"``
**Arguments:** **Arguments:**
- ``<channel>`` The text, voice, stage, or forum channel to add filtered words to.
- ``[words...]`` The words or sentences to filter. - ``[words...]`` The words or sentences to filter.
.. _filter-command-filter-channel-clear: .. _filter-command-filter-channel-clear:
@ -164,7 +165,7 @@ filter channel remove
.. code-block:: none .. code-block:: none
[p]filter channel remove [words...] [p]filter channel remove <channel> [words...]
**Description** **Description**
@ -173,11 +174,12 @@ Remove words from the filter.
Use double quotes to remove sentences. Use double quotes to remove sentences.
Examples: Examples:
- ``[p]filter channel remove word1 word2 word3`` - ``[p]filter channel remove #channel word1 word2 word3``
- ``[p]filter channel remove "This is a sentence"`` - ``[p]filter channel remove #channel "This is a sentence"``
**Arguments:** **Arguments:**
- ``<channel>`` The text, voice, stage, or forum channel to add filtered words to.
- ``[words...]`` The words or sentences to no longer filter. - ``[words...]`` The words or sentences to no longer filter.
.. _filter-command-filter-clear: .. _filter-command-filter-clear:

View File

@ -31,7 +31,7 @@ In terms of scope, global rules will be checked first, then server rules.
For each of those, the first rule pertaining to one of the following models will be used: For each of those, the first rule pertaining to one of the following models will be used:
1. User 1. User
2. Voice channel a user is connected to 2. Voice/stage channel a user is connected to
3. The channel command was issued in (parent channel in case of invocations in threads) 3. The channel command was issued in (parent channel in case of invocations in threads)
4. Channel category 4. Channel category
5. Roles, highest to lowest 5. Roles, highest to lowest

View File

@ -325,19 +325,19 @@ Here's an example of a list of versions sorted using the new order (oldest versi
- 3.5.0.post1 - 3.5.0.post1
- 3.5.1 - 3.5.1
``Red.get_owner_notification_destinations()`` may return a ``discord.VoiceChannel`` instance now ``Red.get_owner_notification_destinations()`` may now return instances of ``discord.Voice/StageChannel``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With the introduction of Text in Voice feature, we added the ability to add a voice channel With the introduction of Text in Voice feature, we added the ability to add a voice/stage channel
as an owner notifications destination. This means that `redbot.core.modlog.get_modlog_channel()` as an owner notifications destination. This means that `redbot.core.modlog.get_modlog_channel()`
may now return an instance of `discord.VoiceChannel`. may now return instances of `discord.VoiceChannel` and `discord.StageChannel`.
``modlog.get_modlog_channel()`` may return a ``discord.VoiceChannel`` instance now ``modlog.get_modlog_channel()`` may now return instances of ``discord.Voice/StageChannel``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With the introduction of Text in Voice feature, we added the ability to set a modlog With the introduction of Text in Voice feature, we added the ability to set a modlog
channel to a voice channel. This means that `redbot.core.modlog.get_modlog_channel()` channel to a voice/stage channel. This means that `redbot.core.modlog.get_modlog_channel()`
may now return an instance of `discord.VoiceChannel`. may now return instances of `discord.VoiceChannel` and `discord.StageChannel`.
``menus.DEFAULT_CONTROLS`` and ``ReactionPredicate.*_EMOJIS`` use immutable types now ``menus.DEFAULT_CONTROLS`` and ``ReactionPredicate.*_EMOJIS`` use immutable types now
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -357,7 +357,10 @@ class Admin(commands.Cog):
@announceset.command(name="channel") @announceset.command(name="channel")
async def announceset_channel( async def announceset_channel(
self, ctx, *, channel: Union[discord.TextChannel, discord.VoiceChannel] self,
ctx,
*,
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
): ):
"""Change the channel where the bot will send announcements.""" """Change the channel where the bot will send announcements."""
await self.config.guild(ctx.guild).announce_channel.set(channel.id) await self.config.guild(ctx.guild).announce_channel.set(channel.id)

View File

@ -197,7 +197,13 @@ class MixinMeta(ABC):
self, self,
config: Config, config: Config,
ctx_or_channel: Optional[ ctx_or_channel: Optional[
Union[Context, discord.TextChannel, discord.VoiceChannel, discord.Thread] Union[
Context,
discord.TextChannel,
discord.VoiceChannel,
discord.StageChannel,
discord.Thread,
]
], ],
query: str, query: str,
query_obj: Query, query_obj: Query,
@ -253,7 +259,10 @@ class MixinMeta(ABC):
@abstractmethod @abstractmethod
def _has_notify_perms( def _has_notify_perms(
self, channel: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread] self,
channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
],
) -> bool: ) -> bool:
raise NotImplementedError() raise NotImplementedError()

View File

@ -100,7 +100,10 @@ class MiscellaneousUtilities(MixinMeta, metaclass=CompositeMetaClass):
return await ctx.send(embed=embed) return await ctx.send(embed=embed)
def _has_notify_perms( def _has_notify_perms(
self, channel: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread] self,
channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
],
) -> bool: ) -> bool:
perms = channel.permissions_for(channel.guild.me) perms = channel.permissions_for(channel.guild.me)
return all((can_user_send_messages_in(channel.guild.me, channel), perms.embed_links)) return all((can_user_send_messages_in(channel.guild.me, channel), perms.embed_links))

View File

@ -61,7 +61,13 @@ class ValidationUtilities(MixinMeta, metaclass=CompositeMetaClass):
self, self,
config: Config, config: Config,
ctx_or_channel: Optional[ ctx_or_channel: Optional[
Union[Context, discord.TextChannel, discord.VoiceChannel, discord.Thread] Union[
Context,
discord.TextChannel,
discord.VoiceChannel,
discord.StageChannel,
discord.Thread,
]
], ],
query: str, query: str,
query_obj: Query, query_obj: Query,

View File

@ -76,7 +76,11 @@ class Cleanup(commands.Cog):
async def get_messages_for_deletion( async def get_messages_for_deletion(
*, *,
channel: Union[ channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.DMChannel, discord.Thread discord.TextChannel,
discord.VoiceChannel,
discord.StageChannel,
discord.DMChannel,
discord.Thread,
], ],
number: Optional[int] = None, number: Optional[int] = None,
check: Callable[[discord.Message], bool] = lambda x: True, check: Callable[[discord.Message], bool] = lambda x: True,
@ -132,7 +136,11 @@ class Cleanup(commands.Cog):
self, self,
num: int, num: int,
channel: Union[ channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.DMChannel, discord.Thread discord.TextChannel,
discord.VoiceChannel,
discord.StageChannel,
discord.DMChannel,
discord.Thread,
], ],
*, *,
subtract_invoking: bool = False, subtract_invoking: bool = False,
@ -153,7 +161,9 @@ class Cleanup(commands.Cog):
@staticmethod @staticmethod
async def get_message_from_reference( async def get_message_from_reference(
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread], channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
],
reference: discord.MessageReference, reference: discord.MessageReference,
) -> Optional[discord.Message]: ) -> Optional[discord.Message]:
message = None message = None

View File

@ -254,7 +254,9 @@ class Filter(commands.Cog):
async def filter_channel_add( async def filter_channel_add(
self, self,
ctx: commands.Context, ctx: commands.Context,
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.ForumChannel], channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.ForumChannel
],
*words: str, *words: str,
): ):
"""Add words to the filter. """Add words to the filter.
@ -267,7 +269,7 @@ class Filter(commands.Cog):
**Arguments:** **Arguments:**
- `<channel>` The text, voice, or forum channel to add filtered words to. - `<channel>` The text, voice, stage, or forum channel to add filtered words to.
- `[words...]` The words or sentences to filter. - `[words...]` The words or sentences to filter.
""" """
added = await self.add_to_filter(channel, words) added = await self.add_to_filter(channel, words)
@ -281,7 +283,9 @@ class Filter(commands.Cog):
async def filter_channel_remove( async def filter_channel_remove(
self, self,
ctx: commands.Context, ctx: commands.Context,
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.ForumChannel], channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.ForumChannel
],
*words: str, *words: str,
): ):
"""Remove words from the filter. """Remove words from the filter.
@ -294,7 +298,7 @@ class Filter(commands.Cog):
**Arguments:** **Arguments:**
- `<channel>` The text, voice, or forum channel to add filtered words to. - `<channel>` The text, voice, stage, or forum channel to add filtered words to.
- `[words...]` The words or sentences to no longer filter. - `[words...]` The words or sentences to no longer filter.
""" """
removed = await self.remove_from_filter(channel, words) removed = await self.remove_from_filter(channel, words)
@ -368,7 +372,12 @@ class Filter(commands.Cog):
self, self,
guild: discord.Guild, guild: discord.Guild,
channel: Optional[ channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.ForumChannel] Union[
discord.TextChannel,
discord.VoiceChannel,
discord.StageChannel,
discord.ForumChannel,
]
] = None, ] = None,
) -> None: ) -> None:
"""Invalidate a cached pattern""" """Invalidate a cached pattern"""
@ -381,7 +390,11 @@ class Filter(commands.Cog):
async def add_to_filter( async def add_to_filter(
self, self,
server_or_channel: Union[ server_or_channel: Union[
discord.Guild, discord.TextChannel, discord.VoiceChannel, discord.ForumChannel discord.Guild,
discord.TextChannel,
discord.VoiceChannel,
discord.StageChannel,
discord.ForumChannel,
], ],
words: list, words: list,
) -> bool: ) -> bool:
@ -405,7 +418,11 @@ class Filter(commands.Cog):
async def remove_from_filter( async def remove_from_filter(
self, self,
server_or_channel: Union[ server_or_channel: Union[
discord.Guild, discord.TextChannel, discord.VoiceChannel, discord.ForumChannel discord.Guild,
discord.TextChannel,
discord.VoiceChannel,
discord.StageChannel,
discord.ForumChannel,
], ],
words: list, words: list,
) -> bool: ) -> bool:
@ -430,7 +447,11 @@ class Filter(commands.Cog):
self, self,
text: str, text: str,
server_or_channel: Union[ server_or_channel: Union[
discord.Guild, discord.TextChannel, discord.VoiceChannel, discord.Thread discord.Guild,
discord.TextChannel,
discord.VoiceChannel,
discord.StageChannel,
discord.Thread,
], ],
) -> Set[str]: ) -> Set[str]:
if isinstance(server_or_channel, discord.Guild): if isinstance(server_or_channel, discord.Guild):

View File

@ -860,7 +860,9 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
async def notification_channel_set( async def notification_channel_set(
self, self,
ctx: commands.Context, ctx: commands.Context,
channel: Optional[Union[discord.TextChannel, discord.VoiceChannel]] = None, channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel]
] = None,
): ):
""" """
Set the notification channel for automatic unmute issues. Set the notification channel for automatic unmute issues.

View File

@ -221,7 +221,7 @@ class Permissions(commands.Cog):
"Global rules (set by the owner) are checked first, then rules set for servers. If " "Global rules (set by the owner) are checked first, then rules set for servers. If "
"multiple global or server rules apply to the case, the order they are checked in is:\n" "multiple global or server rules apply to the case, the order they are checked in is:\n"
" 1. Rules about a user.\n" " 1. Rules about a user.\n"
" 2. Rules about the voice channel a user is connected to.\n" " 2. Rules about the voice/stage channel a user is connected to.\n"
" 3. Rules about the channel or a parent of the thread a command was issued in.\n" " 3. Rules about the channel or a parent of the thread a command was issued in.\n"
" 4. Rules about a role the user has (The highest role they have with a rule will be " " 4. Rules about a role the user has (The highest role they have with a rule will be "
"used).\n" "used).\n"

View File

@ -107,7 +107,9 @@ class Reports(commands.Cog):
@commands.admin_or_permissions(manage_guild=True) @commands.admin_or_permissions(manage_guild=True)
@reportset.command(name="output") @reportset.command(name="output")
async def reportset_output( async def reportset_output(
self, ctx: commands.Context, channel: Union[discord.TextChannel, discord.VoiceChannel] self,
ctx: commands.Context,
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
): ):
"""Set the channel where reports will be sent.""" """Set the channel where reports will be sent."""
await self.config.guild(ctx.guild).output_channel.set(channel.id) await self.config.guild(ctx.guild).output_channel.set(channel.id)

View File

@ -316,7 +316,7 @@ class Streams(commands.Cog):
ctx: commands.Context, ctx: commands.Context,
channel_name: str, channel_name: str,
discord_channel: Union[ discord_channel: Union[
discord.TextChannel, discord.VoiceChannel discord.TextChannel, discord.VoiceChannel, discord.StageChannel
] = commands.CurrentChannel, ] = commands.CurrentChannel,
): ):
"""Manage Twitch stream notifications.""" """Manage Twitch stream notifications."""
@ -328,7 +328,7 @@ class Streams(commands.Cog):
ctx: commands.Context, ctx: commands.Context,
channel_name: str, channel_name: str,
discord_channel: Union[ discord_channel: Union[
discord.TextChannel, discord.VoiceChannel discord.TextChannel, discord.VoiceChannel, discord.StageChannel
] = commands.CurrentChannel, ] = commands.CurrentChannel,
): ):
"""Toggle alerts in this or the given channel for a Twitch stream.""" """Toggle alerts in this or the given channel for a Twitch stream."""
@ -345,7 +345,7 @@ class Streams(commands.Cog):
ctx: commands.Context, ctx: commands.Context,
channel_name_or_id: str, channel_name_or_id: str,
discord_channel: Union[ discord_channel: Union[
discord.TextChannel, discord.VoiceChannel discord.TextChannel, discord.VoiceChannel, discord.StageChannel
] = commands.CurrentChannel, ] = commands.CurrentChannel,
): ):
"""Toggle alerts in this channel for a YouTube stream.""" """Toggle alerts in this channel for a YouTube stream."""
@ -357,7 +357,7 @@ class Streams(commands.Cog):
ctx: commands.Context, ctx: commands.Context,
channel_name: str, channel_name: str,
discord_channel: Union[ discord_channel: Union[
discord.TextChannel, discord.VoiceChannel discord.TextChannel, discord.VoiceChannel, discord.StageChannel
] = commands.CurrentChannel, ] = commands.CurrentChannel,
): ):
"""Toggle alerts in this channel for a Picarto stream.""" """Toggle alerts in this channel for a Picarto stream."""
@ -794,7 +794,7 @@ class Streams(commands.Cog):
async def _send_stream_alert( async def _send_stream_alert(
self, self,
stream, stream,
channel: Union[discord.TextChannel, discord.VoiceChannel], channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
embed: discord.Embed, embed: discord.Embed,
content: str = None, content: str = None,
*, *,
@ -954,7 +954,7 @@ class Streams(commands.Cog):
async def _get_mention_str( async def _get_mention_str(
self, self,
guild: discord.Guild, guild: discord.Guild,
channel: Union[discord.TextChannel, discord.VoiceChannel], channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
guild_data: dict, guild_data: dict,
) -> Tuple[str, List[discord.Role]]: ) -> Tuple[str, List[discord.Role]]:
"""Returns a 2-tuple with the string containing the mentions, and a list of """Returns a 2-tuple with the string containing the mentions, and a list of
@ -982,7 +982,9 @@ class Streams(commands.Cog):
return " ".join(mentions), edited_roles return " ".join(mentions), edited_roles
async def filter_streams( async def filter_streams(
self, streams: list, channel: Union[discord.TextChannel, discord.VoiceChannel] self,
streams: list,
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
) -> list: ) -> list:
filtered = [] filtered = []
for stream in streams: for stream in streams:

View File

@ -705,7 +705,10 @@ class Trivia(commands.Cog):
await ctx.send(_("Saved Trivia list as {filename}.").format(filename=filename)) await ctx.send(_("Saved Trivia list as {filename}.").format(filename=filename))
def _get_trivia_session( def _get_trivia_session(
self, channel: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread] self,
channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
],
) -> TriviaSession: ) -> TriviaSession:
return next( return next(
(session for session in self.trivia_sessions if session.ctx.channel == channel), None (session for session in self.trivia_sessions if session.ctx.channel == channel), None

View File

@ -159,7 +159,7 @@ class Warnings(commands.Cog):
async def warnchannel( async def warnchannel(
self, self,
ctx: commands.Context, ctx: commands.Context,
channel: Union[discord.TextChannel, discord.VoiceChannel] = None, channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel] = None,
): ):
"""Set the channel where warnings should be sent to. """Set the channel where warnings should be sent to.

View File

@ -38,7 +38,9 @@ class IssueDiagnoserBase:
self, self,
bot: Red, bot: Red,
original_ctx: commands.Context, 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, author: discord.Member,
command: commands.Command, command: commands.Command,
) -> None: ) -> None:

View File

@ -156,7 +156,11 @@ class IgnoreManager:
async def get_ignored_channel( async def get_ignored_channel(
self, self,
channel: Union[ channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.ForumChannel, discord.Thread discord.TextChannel,
discord.VoiceChannel,
discord.StageChannel,
discord.ForumChannel,
discord.Thread,
], ],
check_category: bool = True, check_category: bool = True,
) -> bool: ) -> bool:
@ -188,6 +192,7 @@ class IgnoreManager:
channel: Union[ channel: Union[
discord.TextChannel, discord.TextChannel,
discord.VoiceChannel, discord.VoiceChannel,
discord.StageChannel,
discord.Thread, discord.Thread,
discord.ForumChannel, discord.ForumChannel,
discord.CategoryChannel, discord.CategoryChannel,

View File

@ -837,7 +837,10 @@ class Red(
return False return False
if guild: 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): if not can_user_send_messages_in(guild.me, channel):
return False return False
if not (await self.ignored_channel_or_guild(message)): if not (await self.ignored_channel_or_guild(message)):
@ -1291,6 +1294,7 @@ class Red(
channel: Union[ channel: Union[
discord.TextChannel, discord.TextChannel,
discord.VoiceChannel, discord.VoiceChannel,
discord.StageChannel,
commands.Context, commands.Context,
discord.User, discord.User,
discord.Member, discord.Member,
@ -1305,7 +1309,7 @@ class Red(
Arguments 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. The target messageable object to check embed settings for.
Keyword Arguments Keyword Arguments
@ -1352,7 +1356,10 @@ class Red(
"You cannot pass a GroupChannel, DMChannel, or PartialMessageable to this method." "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 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: 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( async def get_owner_notification_destinations(
self, 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 Gets the users and channels to send to
""" """

View File

@ -315,7 +315,11 @@ if TYPE_CHECKING or os.getenv("BUILDING_DOCS", False):
... ...
@property @property
def channel(self) -> Union[discord.TextChannel, discord.VoiceChannel, discord.Thread]: def channel(
self,
) -> Union[
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
]:
... ...
@property @property

View File

@ -889,7 +889,12 @@ class RedHelpFormatter(HelpFormatterABC):
# We need to wrap this in a task to not block after-sending-help interactions. # 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 # The channel has to be TextChannel or Thread as we can't bulk-delete from DMs
async def _delete_delay_help( 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], messages: List[discord.Message],
delay: int, delay: int,
): ):

View File

@ -73,6 +73,7 @@ _T = TypeVar("_T")
GlobalPermissionModel = Union[ GlobalPermissionModel = Union[
discord.User, discord.User,
discord.VoiceChannel, discord.VoiceChannel,
discord.StageChannel,
discord.TextChannel, discord.TextChannel,
discord.ForumChannel, discord.ForumChannel,
discord.CategoryChannel, discord.CategoryChannel,
@ -82,6 +83,7 @@ GlobalPermissionModel = Union[
GuildPermissionModel = Union[ GuildPermissionModel = Union[
discord.Member, discord.Member,
discord.VoiceChannel, discord.VoiceChannel,
discord.StageChannel,
discord.TextChannel, discord.TextChannel,
discord.ForumChannel, discord.ForumChannel,
discord.CategoryChannel, discord.CategoryChannel,

View File

@ -1371,7 +1371,9 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
async def embedset_channel( async def embedset_channel(
self, self,
ctx: commands.Context, ctx: commands.Context,
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.ForumChannel], channel: Union[
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.ForumChannel
],
enabled: bool = None, enabled: bool = None,
): ):
""" """
@ -1387,10 +1389,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
**Examples:** **Examples:**
- `[p]embedset channel #text-channel False` - Disables embeds in the #text-channel. - `[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 #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:** **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. - `[enabled]` - Whether to use embeds in this channel. Leave blank to reset to default.
""" """
if enabled is None: if enabled is None:
@ -2709,7 +2711,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
async def modlogset_modlog( async def modlogset_modlog(
self, self,
ctx: commands.Context, 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. """Set a channel as the modlog.
@ -3713,7 +3715,10 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
@_set_ownernotifications.command(name="adddestination") @_set_ownernotifications.command(name="adddestination")
async def _set_ownernotifications_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. Adds a destination text channel to receive owner notifications.
@ -3738,7 +3743,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
self, self,
ctx: commands.Context, 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. Removes a destination text channel from receiving owner notifications.
@ -4692,7 +4697,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
self, self,
ctx: commands.Context, ctx: commands.Context,
channel: Optional[ channel: Optional[
Union[discord.TextChannel, discord.VoiceChannel, discord.Thread] Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread]
] = commands.CurrentChannel, ] = commands.CurrentChannel,
# avoid non-default argument following default argument by using empty param() # avoid non-default argument following default argument by using empty param()
member: Union[discord.Member, discord.User] = commands.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: if ctx.guild is None:
await ctx.send( 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." " when using this command in DMs."
) )
) )
@ -5683,6 +5688,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
channel: Union[ channel: Union[
discord.TextChannel, discord.TextChannel,
discord.VoiceChannel, discord.VoiceChannel,
discord.StageChannel,
discord.ForumChannel, discord.ForumChannel,
discord.CategoryChannel, discord.CategoryChannel,
discord.Thread, discord.Thread,
@ -5741,6 +5747,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
channel: Union[ channel: Union[
discord.TextChannel, discord.TextChannel,
discord.VoiceChannel, discord.VoiceChannel,
discord.StageChannel,
discord.ForumChannel, discord.ForumChannel,
discord.CategoryChannel, discord.CategoryChannel,
discord.Thread, discord.Thread,
@ -5784,23 +5791,23 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
async def count_ignored(self, ctx: commands.Context): async def count_ignored(self, ctx: commands.Context):
category_channels: List[discord.CategoryChannel] = [] 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] = [] threads: List[discord.Thread] = []
if await self.bot._ignored_cache.get_ignored_guild(ctx.guild): if await self.bot._ignored_cache.get_ignored_guild(ctx.guild):
return _("This server is currently being ignored.") return _("This server is currently being ignored.")
for channel in ctx.guild.text_channels: for channel in itertools.chain(
if channel.category and channel.category not in category_channels: ctx.guild.text_channels,
if await self.bot._ignored_cache.get_ignored_channel(channel.category): ctx.guild.voice_channels,
category_channels.append(channel.category) ctx.guild.stage_channels,
if await self.bot._ignored_cache.get_ignored_channel(channel, check_category=False): ctx.guild.forums,
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:
if channel.category and channel.category not in category_channels: if channel.category and channel.category not in category_channels:
if await self.bot._ignored_cache.get_ignored_channel(channel.category): if await self.bot._ignored_cache.get_ignored_channel(channel.category):
category_channels.append(channel.category) category_channels.append(channel.category)

View File

@ -649,7 +649,7 @@ class Case:
@classmethod @classmethod
async def from_json( async def from_json(
cls, cls,
mod_channel: Union[discord.TextChannel, discord.VoiceChannel], mod_channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
bot: Red, bot: Red,
case_number: int, case_number: int,
data: dict, data: dict,
@ -659,7 +659,7 @@ class Case:
Parameters Parameters
---------- ----------
mod_channel: `discord.TextChannel` or `discord.VoiceChannel` mod_channel: `discord.TextChannel` or `discord.VoiceChannel`, `discord.StageChannel`
The mod log channel for the guild The mod log channel for the guild
bot: Red bot: Red
The bot's instance. Needed to get the target user 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( async def get_modlog_channel(
guild: discord.Guild, guild: discord.Guild,
) -> Union[discord.TextChannel, discord.VoiceChannel]: ) -> Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel]:
""" """
Get the current modlog channel. Get the current modlog channel.
@ -1263,7 +1263,7 @@ async def get_modlog_channel(
Returns Returns
------- -------
`discord.TextChannel` or `discord.VoiceChannel` `discord.TextChannel`, `discord.VoiceChannel`, or `discord.StageChannel`
The channel object representing the modlog channel. The channel object representing the modlog channel.
Raises Raises
@ -1283,7 +1283,8 @@ async def get_modlog_channel(
async def set_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: ) -> bool:
""" """
Changes the modlog channel Changes the modlog channel
@ -1292,7 +1293,7 @@ async def set_modlog_channel(
---------- ----------
guild: `discord.Guild` guild: `discord.Guild`
The guild to set a mod log channel for 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 The channel to be set as modlog channel
Returns Returns

View File

@ -35,7 +35,11 @@ from redbot.core import commands
if TYPE_CHECKING: if TYPE_CHECKING:
GuildMessageable = Union[ 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] DMMessageable = Union[commands.DMContext, discord.Member, discord.User, discord.DMChannel]

View File

@ -21,7 +21,9 @@ __all__ = (
async def mass_purge( async def mass_purge(
messages: List[discord.Message], 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, reason: Optional[str] = None,
): ):
@ -39,7 +41,7 @@ async def mass_purge(
---------- ----------
messages : `list` of `discord.Message` messages : `list` of `discord.Message`
The messages to bulk delete. 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. The channel to delete messages from.
reason : `str`, optional reason : `str`, optional
The reason for bulk deletion, which will appear in the audit log. The reason for bulk deletion, which will appear in the audit log.

View File

@ -317,7 +317,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def valid_role( def valid_role(
cls, cls,
ctx: Optional[commands.Context] = None, 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, user: Optional[discord.abc.User] = None,
) -> "MessagePredicate": ) -> "MessagePredicate":
"""Match if the response refers to a role in the current guild. """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] ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_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`. Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User] user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`. Same as ``user`` in :meth:`same_context`.
@ -361,7 +363,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def valid_member( def valid_member(
cls, cls,
ctx: Optional[commands.Context] = None, 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, user: Optional[discord.abc.User] = None,
) -> "MessagePredicate": ) -> "MessagePredicate":
"""Match if the response refers to a member in the current guild. """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] ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_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`. Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User] user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`. Same as ``user`` in :meth:`same_context`.
@ -409,7 +413,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def valid_text_channel( def valid_text_channel(
cls, cls,
ctx: Optional[commands.Context] = None, 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, user: Optional[discord.abc.User] = None,
) -> "MessagePredicate": ) -> "MessagePredicate":
"""Match if the response refers to a text channel in the current guild. """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] ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_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`. Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User] user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`. Same as ``user`` in :meth:`same_context`.
@ -457,7 +463,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
def has_role( def has_role(
cls, cls,
ctx: Optional[commands.Context] = None, 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, user: Optional[discord.abc.User] = None,
) -> "MessagePredicate": ) -> "MessagePredicate":
"""Match if the response refers to a role which the author has. """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] ctx : Optional[Context]
Same as ``ctx`` in :meth:`same_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`. Same as ``channel`` in :meth:`same_context`.
user : Optional[discord.abc.User] user : Optional[discord.abc.User]
Same as ``user`` in :meth:`same_context`. Same as ``user`` in :meth:`same_context`.
@ -833,7 +841,9 @@ class MessagePredicate(Callable[[discord.Message], bool]):
@staticmethod @staticmethod
def _get_guild( def _get_guild(
ctx: Optional[commands.Context], 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], user: Optional[discord.Member],
) -> discord.Guild: ) -> discord.Guild:
if ctx is not None: if ctx is not None:

View File

@ -59,7 +59,7 @@ class Tunnel(metaclass=TunnelMeta):
---------- ----------
sender: `discord.Member` sender: `discord.Member`
The person who opened the tunnel 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 The channel in which it was opened
recipient: `discord.User` recipient: `discord.User`
The user on the other end of the tunnel The user on the other end of the tunnel
@ -69,7 +69,9 @@ class Tunnel(metaclass=TunnelMeta):
self, self,
*, *,
sender: discord.Member, sender: discord.Member,
origin: Union[discord.TextChannel, discord.VoiceChannel, discord.Thread], origin: Union[
discord.TextChannel, discord.VoiceChannel, discord.StageChannel, discord.Thread
],
recipient: discord.User, recipient: discord.User,
): ):
self.sender = sender self.sender = sender