58 lines
2.9 KiB
Python
58 lines
2.9 KiB
Python
from discord import ApplicationContext, DiscordException, slash_command, Color
|
|
from discord.ext.commands import Cog, cooldown, BucketType, has_permissions, guild_only, Context
|
|
|
|
from Christmas.UI.Embed import Default_Embed, ChristmasEmbed
|
|
from Christmas.UI.Buttons import Recommanded
|
|
from Christmas.Database import database
|
|
from Christmas.Module import get_gpuserver_status, Get_Backend_latency
|
|
from koreanbots import KoreanbotsRequester
|
|
class CUtil(Cog):
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
|
|
@guild_only()
|
|
@has_permissions(administrator=True)
|
|
@cooldown(1, 10, BucketType.user)
|
|
@slash_command(name="서버가입", description="서버에 가입합니다.")
|
|
async def _join(self, ctx: Context):
|
|
try:
|
|
if await database.get_guild(ctx.guild.id): return await ctx.respond(embed=Default_Embed.already_register(), ephemeral=True)
|
|
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())
|
|
|
|
@guild_only()
|
|
@has_permissions(administrator=True)
|
|
@cooldown(1, 10, BucketType.user)
|
|
@slash_command(name="서버탈퇴", description="서버에서 탈퇴합니다.")
|
|
async def _leave(self, ctx: Context):
|
|
try:
|
|
if not await database.get_guild(ctx.guild.id): return await ctx.respond(embed=Default_Embed.not_register(), ephemeral=True)
|
|
#await database.leave_guild(ctx.guild.id)
|
|
await ctx.respond(embed=Default_Embed.leave_sucess())
|
|
except Exception as e:
|
|
await ctx.respond(embed=Default_Embed.leave_failed())
|
|
|
|
|
|
@guild_only()
|
|
@cooldown(1, 10, BucketType.user)
|
|
@slash_command(name="봇정보", description="봇의 정보를 확인합니다.")
|
|
async def _info(self, ctx: Context):
|
|
if not await database.get_guild(ctx.guild.id): return await ctx.respond(embed=ChristmasEmbed(title="❌ 에러!", description="서버가 가입되어있지 않아요! 서버를 가입해주세요!", color=Color.red()),ephemeral=True)
|
|
data = await get_gpuserver_status(url=None)
|
|
await ctx.respond(embed=Default_Embed.BotInfo(data, bot=self.bot))
|
|
|
|
@cooldown(1, 10, BucketType.user)
|
|
@slash_command(name="도움말", description="도움말을 확인합니다.")
|
|
async def _help(self, ctx: Context):
|
|
await ctx.respond(embed=Default_Embed.help())
|
|
|
|
@cooldown(1, 10, BucketType.user)
|
|
@guild_only()
|
|
@slash_command(name="추천", description="한디리의 추천링크를 표시해요! 추천 갯수는 추후 크돌이를 통해 오픈될 게임에 영향을 줘요!")
|
|
async def _recommand(self, ctx: Context):
|
|
await ctx.respond(embed=Default_Embed.recommend(), view=Recommanded(), ephemeral=True)
|
|
|
|
def setup(bot):
|
|
bot.add_cog(CUtil(bot)) |