This repository has been archived by the owner on Apr 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AddUser.py
62 lines (45 loc) · 2.12 KB
/
AddUser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#사용자등록
from discord.ext import commands
from discord.ext.commands import Context
from discord_slash import SlashContext, cog_ext
from typing import Union
from define import *
from define import _IsVaildUser
######################################################################################################################################################
@CommandExecutionTime
async def _AddUser_code(ctx: Union[Context, SlashContext]):
logger.info(f"[{type(ctx)}] {ctx.author.name}: {ctx.invoked_with}")
if ctx.guild is None:
logger.info("Guild is None")
return
elif _IsVaildUser(ctx):
logger.info("이미 등록되어 있는 사용자 입니다.")
await ctx.reply("이미 등록되어 있는 사용자 입니다.")
return
with setUserInformation() as data:
data.json_data[str(ctx.author.id)] = AddUser() #사용자 추가
logger.info("등록되었습니다.")
await ctx.reply("등록되었습니다.")
######################################################################################################################################################
class AddUser_SlashContext(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@cog_ext.cog_slash(
name="사용자등록",
description="데이터 베이스에 사용자를 등록합니다.",
guild_ids=guilds_id,
options=[]
)
async def _AddUser(self, ctx: SlashContext):
await _AddUser_code(ctx)
####################################################################################################
class AddUser_Context(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command(name="사용자등록", aliases=["등록"])
async def _AddUser(self, ctx: Context):
await _AddUser_code(ctx)
######################################################################################################################################################
def setup(bot: commands.Bot):
bot.add_cog(AddUser_Context(bot))
bot.add_cog(AddUser_SlashContext(bot))