Fix typing for python 3.8

This commit is contained in:
Michel Roux 2022-05-08 16:25:25 +02:00
parent c1c5767075
commit 532d1bd944

7
bot.py
View File

@ -1,6 +1,7 @@
from asyncio import new_event_loop
from datetime import timedelta
from os import environ
from typing import Optional, Union
from disnake import Client, Guild, Member
from dotenv import load_dotenv
@ -30,21 +31,21 @@ client = Discord()
app = Quart(__name__)
def get_guild_by_id(guild_id: int | str) -> Guild | None:
def get_guild_by_id(guild_id: Union[int, str]) -> Optional[Guild]:
for guild in client.guilds:
if guild.id == int(guild_id) or guild.vanity_url_code == str(guild_id):
return guild
return None
def get_bot_member(guild: Guild) -> Member | None:
def get_bot_member(guild: Guild) -> Optional[Member]:
for member in guild.members:
if member.id == client.user.id:
return member
return None
async def get_guild_tag(member: Member) -> str | None:
async def get_guild_tag(member: Member) -> Optional[str]:
if member.guild_permissions.manage_guild:
if member.guild.vanity_url_code:
return member.guild.vanity_url_code