discord.py 2.0 update (3d914e08->2.0.1) (#5709)

This commit is contained in:
Jakub Kuczys
2022-10-03 16:07:15 +02:00
committed by GitHub
parent d7d6ab46f4
commit f02528378f
44 changed files with 454 additions and 317 deletions

View File

@@ -349,12 +349,12 @@ class Case:
self.message = message
@property
def parent_channel(self) -> Optional[discord.TextChannel]:
def parent_channel(self) -> Optional[Union[discord.TextChannel, discord.ForumChannel]]:
"""
The parent text channel of the thread in `channel`.
The parent text/forum channel of the thread in `channel`.
This will be `None` if `channel` is not a thread
and when the parent text channel is not in cache (probably due to removal).
and when the parent text/forum channel is not in cache (probably due to removal).
"""
if self.parent_channel_id is None:
return None
@@ -645,13 +645,18 @@ class Case:
@classmethod
async def from_json(
cls, mod_channel: discord.TextChannel, bot: Red, case_number: int, data: dict, **kwargs
cls,
mod_channel: Union[discord.TextChannel, discord.VoiceChannel],
bot: Red,
case_number: int,
data: dict,
**kwargs,
):
"""Get a Case object from the provided information
Parameters
----------
mod_channel: discord.TextChannel
mod_channel: `discord.TextChannel` or `discord.VoiceChannel`
The mod log channel for the guild
bot: Red
The bot's instance. Needed to get the target user
@@ -1228,7 +1233,9 @@ async def register_casetypes(new_types: List[dict]) -> List[CaseType]:
return type_list
async def get_modlog_channel(guild: discord.Guild) -> discord.TextChannel:
async def get_modlog_channel(
guild: discord.Guild,
) -> Union[discord.TextChannel, discord.VoiceChannel]:
"""
Get the current modlog channel.
@@ -1239,7 +1246,7 @@ async def get_modlog_channel(guild: discord.Guild) -> discord.TextChannel:
Returns
-------
`discord.TextChannel`
`discord.TextChannel` or `discord.VoiceChannel`
The channel object representing the modlog channel.
Raises
@@ -1259,7 +1266,7 @@ async def get_modlog_channel(guild: discord.Guild) -> discord.TextChannel:
async def set_modlog_channel(
guild: discord.Guild, channel: Union[discord.TextChannel, None]
guild: discord.Guild, channel: Union[discord.TextChannel, discord.VoiceChannel, None]
) -> bool:
"""
Changes the modlog channel
@@ -1268,7 +1275,7 @@ async def set_modlog_channel(
----------
guild: `discord.Guild`
The guild to set a mod log channel for
channel: `discord.TextChannel` or `None`
channel: `discord.TextChannel`, `discord.VoiceChannel`, or `None`
The channel to be set as modlog channel
Returns