runabot/Christmas/Cogs/Commands_Util.py

32 lines
1.4 KiB
Python
Raw Normal View History

2023-11-26 04:27:34 +00:00
from discord import ApplicationContext, DiscordException, slash_command
from discord.ext.commands import Cog, cooldown, BucketType, has_permissions, guild_only, Context
2023-11-25 17:28:48 +00:00
2023-11-26 04:27:34 +00:00
from Christmas.UI.Embed import Default_Embed
from Christmas.Database import database
2023-12-02 06:03:50 +00:00
from Christmas.Module import get_gpuserver_status, Get_Backend_latency
2023-11-25 17:28:48 +00:00
class CUtil(Cog):
def __init__(self, bot):
self.bot = bot
2023-11-26 04:27:34 +00:00
@guild_only()
@has_permissions(administrator=True)
@cooldown(1, 10, BucketType.user)
@slash_command(name="서버가입", description="서버에 가입합니다.")
async def _join(self, ctx: Context):
try:
2023-12-02 06:03:50 +00:00
if await database.get_guild(ctx.guild.id): return await ctx.respond(embed=Default_Embed.already_register(), ephemeral=True)
2023-11-26 04:27:34 +00:00
await database.register_guild(ctx.guild.id)
await ctx.respond(embed=Default_Embed.register_sucess())
except Exception as e:
await ctx.respond(embed=Default_Embed.register_failed())
2023-12-02 06:03:50 +00:00
@guild_only()
@cooldown(1, 10, BucketType.user)
@slash_command(name="봇정보", description="봇의 정보를 확인합니다.")
async def _info(self, ctx: Context):
data = await get_gpuserver_status(url=None)
data2 = await Get_Backend_latency()
await ctx.respond(embed=Default_Embed.BotInfo(data, bot=self.bot, APIlatency=data2))
2023-11-25 17:28:48 +00:00
def setup(bot):
bot.add_cog(CUtil(bot))