Compare commits
2 Commits
39b32de588
...
a49ab9f542
Author | SHA1 | Date | |
---|---|---|---|
a49ab9f542 | |||
532d1bd944 |
7
bot.py
7
bot.py
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user