Discord utils: fixed to_string function to work correctly with channels objects

This commit is contained in:
Elnath 2021-04-20 17:55:17 +02:00
parent 4a656685c0
commit f474205462
1 changed files with 4 additions and 1 deletions

View File

@ -59,6 +59,9 @@ def _(guild) -> str:
return f"{guild.name}({guild.id})"
@to_string.register(discord.abc.GuildChannel)
# Even though these types are all subclasses of discord.abc.GuildChannel, it does not work if we register that class directly
@to_string.register(discord.TextChannel)
@to_string.register(discord.VoiceChannel)
@to_string.register(discord.CategoryChannel)
def _(channel) -> str:
return f"{channel.name}({channel.id})"