Fix typing for python 3.8
This commit is contained in:
parent
c1c5767075
commit
532d1bd944
7
bot.py
7
bot.py
@ -1,6 +1,7 @@
|
|||||||
from asyncio import new_event_loop
|
from asyncio import new_event_loop
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from os import environ
|
from os import environ
|
||||||
|
from typing import Optional, Union
|
||||||
|
|
||||||
from disnake import Client, Guild, Member
|
from disnake import Client, Guild, Member
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
@ -30,21 +31,21 @@ client = Discord()
|
|||||||
app = Quart(__name__)
|
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:
|
for guild in client.guilds:
|
||||||
if guild.id == int(guild_id) or guild.vanity_url_code == str(guild_id):
|
if guild.id == int(guild_id) or guild.vanity_url_code == str(guild_id):
|
||||||
return guild
|
return guild
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_bot_member(guild: Guild) -> Member | None:
|
def get_bot_member(guild: Guild) -> Optional[Member]:
|
||||||
for member in guild.members:
|
for member in guild.members:
|
||||||
if member.id == client.user.id:
|
if member.id == client.user.id:
|
||||||
return member
|
return member
|
||||||
return None
|
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_permissions.manage_guild:
|
||||||
if member.guild.vanity_url_code:
|
if member.guild.vanity_url_code:
|
||||||
return member.guild.vanity_url_code
|
return member.guild.vanity_url_code
|
||||||
|
Loading…
Reference in New Issue
Block a user