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
28 changed files with 213 additions and 95 deletions

View File

@@ -357,7 +357,10 @@ class Admin(commands.Cog):
@announceset.command(name="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."""
await self.config.guild(ctx.guild).announce_channel.set(channel.id)

View File

@@ -197,7 +197,13 @@ class MixinMeta(ABC):
self,
config: Config,
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_obj: Query,
@@ -253,7 +259,10 @@ class MixinMeta(ABC):
@abstractmethod
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:
raise NotImplementedError()

View File

@@ -100,7 +100,10 @@ class MiscellaneousUtilities(MixinMeta, metaclass=CompositeMetaClass):
return await ctx.send(embed=embed)
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:
perms = channel.permissions_for(channel.guild.me)
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,
config: Config,
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_obj: Query,

View File

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

View File

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

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 "
"multiple global or server rules apply to the case, the order they are checked in is:\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"
" 4. Rules about a role the user has (The highest role they have with a rule will be "
"used).\n"

View File

@@ -107,7 +107,9 @@ class Reports(commands.Cog):
@commands.admin_or_permissions(manage_guild=True)
@reportset.command(name="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."""
await self.config.guild(ctx.guild).output_channel.set(channel.id)

View File

@@ -316,7 +316,7 @@ class Streams(commands.Cog):
ctx: commands.Context,
channel_name: str,
discord_channel: Union[
discord.TextChannel, discord.VoiceChannel
discord.TextChannel, discord.VoiceChannel, discord.StageChannel
] = commands.CurrentChannel,
):
"""Manage Twitch stream notifications."""
@@ -328,7 +328,7 @@ class Streams(commands.Cog):
ctx: commands.Context,
channel_name: str,
discord_channel: Union[
discord.TextChannel, discord.VoiceChannel
discord.TextChannel, discord.VoiceChannel, discord.StageChannel
] = commands.CurrentChannel,
):
"""Toggle alerts in this or the given channel for a Twitch stream."""
@@ -345,7 +345,7 @@ class Streams(commands.Cog):
ctx: commands.Context,
channel_name_or_id: str,
discord_channel: Union[
discord.TextChannel, discord.VoiceChannel
discord.TextChannel, discord.VoiceChannel, discord.StageChannel
] = commands.CurrentChannel,
):
"""Toggle alerts in this channel for a YouTube stream."""
@@ -357,7 +357,7 @@ class Streams(commands.Cog):
ctx: commands.Context,
channel_name: str,
discord_channel: Union[
discord.TextChannel, discord.VoiceChannel
discord.TextChannel, discord.VoiceChannel, discord.StageChannel
] = commands.CurrentChannel,
):
"""Toggle alerts in this channel for a Picarto stream."""
@@ -794,7 +794,7 @@ class Streams(commands.Cog):
async def _send_stream_alert(
self,
stream,
channel: Union[discord.TextChannel, discord.VoiceChannel],
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
embed: discord.Embed,
content: str = None,
*,
@@ -954,7 +954,7 @@ class Streams(commands.Cog):
async def _get_mention_str(
self,
guild: discord.Guild,
channel: Union[discord.TextChannel, discord.VoiceChannel],
channel: Union[discord.TextChannel, discord.VoiceChannel, discord.StageChannel],
guild_data: dict,
) -> Tuple[str, List[discord.Role]]:
"""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
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:
filtered = []
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))
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:
return next(
(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(
self,
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.