mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-07 09:52:30 -05:00
discord.py 2.0 update (3d914e08->2.0.1) (#5709)
This commit is contained in:
@@ -303,14 +303,19 @@ class Streams(commands.Cog):
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
channel_name: str,
|
||||
discord_channel: discord.TextChannel = None,
|
||||
discord_channel: Union[discord.TextChannel, discord.VoiceChannel] = None,
|
||||
):
|
||||
"""Manage Twitch stream notifications."""
|
||||
await ctx.invoke(self.twitch_alert_channel, channel_name, discord_channel)
|
||||
|
||||
@_twitch.command(name="channel")
|
||||
async def twitch_alert_channel(
|
||||
self, ctx: commands.Context, channel_name: str, discord_channel: discord.TextChannel = None
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
channel_name: str,
|
||||
discord_channel: Union[
|
||||
discord.TextChannel, discord.VoiceChannel
|
||||
] = commands.CurrentChannel,
|
||||
):
|
||||
"""Toggle alerts in this or the given channel for a Twitch stream."""
|
||||
if re.fullmatch(r"<#\d+>", channel_name):
|
||||
@@ -325,14 +330,21 @@ class Streams(commands.Cog):
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
channel_name_or_id: str,
|
||||
discord_channel: discord.TextChannel = None,
|
||||
discord_channel: Union[
|
||||
discord.TextChannel, discord.VoiceChannel
|
||||
] = commands.CurrentChannel,
|
||||
):
|
||||
"""Toggle alerts in this channel for a YouTube stream."""
|
||||
await self.stream_alert(ctx, YoutubeStream, channel_name_or_id, discord_channel)
|
||||
|
||||
@streamalert.command(name="picarto")
|
||||
async def picarto_alert(
|
||||
self, ctx: commands.Context, channel_name: str, discord_channel: discord.TextChannel = None
|
||||
self,
|
||||
ctx: commands.Context,
|
||||
channel_name: str,
|
||||
discord_channel: Union[
|
||||
discord.TextChannel, discord.VoiceChannel
|
||||
] = commands.CurrentChannel,
|
||||
):
|
||||
"""Toggle alerts in this channel for a Picarto stream."""
|
||||
await self.stream_alert(ctx, PicartoStream, channel_name, discord_channel)
|
||||
@@ -401,8 +413,6 @@ class Streams(commands.Cog):
|
||||
await ctx.send(page)
|
||||
|
||||
async def stream_alert(self, ctx: commands.Context, _class, channel_name, discord_channel):
|
||||
if discord_channel is None:
|
||||
discord_channel = ctx.channel
|
||||
if isinstance(discord_channel, discord.Thread):
|
||||
await ctx.send("Stream alerts cannot be set up in threads.")
|
||||
return
|
||||
@@ -757,7 +767,7 @@ class Streams(commands.Cog):
|
||||
async def _send_stream_alert(
|
||||
self,
|
||||
stream,
|
||||
channel: discord.TextChannel,
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel],
|
||||
embed: discord.Embed,
|
||||
content: str = None,
|
||||
*,
|
||||
@@ -904,7 +914,10 @@ class Streams(commands.Cog):
|
||||
await self.save_streams()
|
||||
|
||||
async def _get_mention_str(
|
||||
self, guild: discord.Guild, channel: discord.TextChannel, guild_data: dict
|
||||
self,
|
||||
guild: discord.Guild,
|
||||
channel: Union[discord.TextChannel, discord.VoiceChannel],
|
||||
guild_data: dict,
|
||||
) -> Tuple[str, List[discord.Role]]:
|
||||
"""Returns a 2-tuple with the string containing the mentions, and a list of
|
||||
all roles which need to have their `mentionable` property set back to False.
|
||||
@@ -930,7 +943,9 @@ class Streams(commands.Cog):
|
||||
mentions.append(role.mention)
|
||||
return " ".join(mentions), edited_roles
|
||||
|
||||
async def filter_streams(self, streams: list, channel: discord.TextChannel) -> list:
|
||||
async def filter_streams(
|
||||
self, streams: list, channel: Union[discord.TextChannel, discord.VoiceChannel]
|
||||
) -> list:
|
||||
filtered = []
|
||||
for stream in streams:
|
||||
tw_id = str(stream["channel"]["_id"])
|
||||
|
||||
Reference in New Issue
Block a user