Files
brahmos/utils/funcs.py
T
2024-03-08 23:17:48 +05:30

33 lines
824 B
Python

import asyncio
import base64
import os
from typing import List, Union
import aiohttp
import discord
TESTID = 356099868638445578
ID = int(base64.b64decode(os.getenv("TOKEN").split(".")[0]))
async def get_webhook(
channel: Union[discord.TextChannel, discord.ForumChannel, discord.VoiceChannel]
) -> discord.Webhook:
"""Get a webhook created by bot in the channel"""
if ID != TESTID:
wname = "ゼロ"
else:
wname = "ゼロ~"
hooks: List[discord.Webhook] = await channel.webhooks()
for hook in hooks:
if hook.name == wname:
return hook
# if it doesn't exist create one
hook = await channel.create_webhook(name=wname)
return hook
def discord_bg_embed(desc: str = "\u200b") -> discord.Embed:
return discord.Embed(color=0x36393E, description=desc)