-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
164 lines (129 loc) · 5.93 KB
/
bot.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import discord
from discord.ext import commands
import os
from asyncio.windows_events import NULL
from dotenv import load_dotenv
from typing import Union
import sqlite3
client = discord.Client(intents=discord.Intents.default())
bot = commands.Bot(
command_prefix='',
intents=discord.Intents.all()
)
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command()
async def ping(ctx):
await ctx.send('pong')
@bot.command(name="1234")
async def _1234(ctx):
await ctx.send("5678")
#설명서
@bot.command(name='!명령어')
async def howTodo(ctx):
embed = discord.Embed(title = '짭니쿠다 설명서', color=0xFFE08C)
embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/659428348883107870/873425790744805406/img.png')
embed.add_field(name='!이모지추가 이모지이름 [원하는 이모지]', value='원하는 이모지를 원하는 명령어로 등록할 수 있어요.', inline=False)
embed.add_field(name='!사진추가 이모지이름 (같이 사진파일 업로드)', value='원하는 사진도 원하는 명령어로 등록할 수 있어요.', inline=False)
embed.add_field(name='!이모지목록 [검색어]', value='이모지 목록을 볼 수 있어요.(전체 목록은 검색어에 전체를 넣어주세요)', inline=False)
embed.add_field(name='!이모지정보 이모지이름', value='등록된 이모지의 정보를 볼 수 있어요.', inline=False)
embed.add_field(name='~ 이모지이름', value='등록한 이모지를 불러오세요.', inline=False)
embed.set_footer(text='AngryBired', icon_url='https://cdn.discordapp.com/attachments/659428348883107870/873425519490773052/icon_10.png')
msg = await ctx.send(embed=embed)
#이모지추가
@bot.command(name='!이모지추가')
async def add_emoji(ctx, arg, emoji: Union[discord.Emoji, discord.PartialEmoji]):
if not emoji:
return #await ctx.invoke(self.bot.get_command("help"), entity="emoji")
try:
print(emoji.url)
conn = sqlite3.connect("d:/Code/Discord/Minikuda2/data/emoji_H.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO TABLE1(Emoji_name, link, user) VALUES(?,?,?)", (arg, str(emoji.url), str(ctx.message.author)))
conn.commit()
conn.close()
await ctx.send(f"이모지 목록에 ~{arg} 이모지가 추가되었습니다.")
except discord.NotFound :
return await ctx.send("오류!")
except sqlite3.IntegrityError :
return await ctx.send("같은 이름의 이모지를 추가할 수 없습니다.")
@bot.command(name='!사진추가')
async def add_picture(ctx, arg):
if ctx.message.attachments == NULL:
return await ctx.send("사진 파일을 같이 올려주세요.")
try:
pic = ctx.message.attachments
print(pic[0].url)
conn = sqlite3.connect("d:/Code/Discord/Minikuda2/data/emoji_H.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO TABLE1(Emoji_name, link, user) VALUES(?,?,?)", (arg, str(pic[0].url), str(ctx.message.author)))
conn.commit()
conn.close()
await ctx.send(f"이모지 목록에 ~{arg} 이모지가 추가되었습니다.")
except discord.NotFound :
return await ctx.send("오류!")
except sqlite3.IntegrityError :
return await ctx.send("같은 이름의 이모지를 추가할 수 없습니다.")
@bot.command(name='!이모지목록')
async def arrays(ctx, arg):
conn = sqlite3.connect("d:/Code/Discord/Minikuda2/data/emoji_H.db")
cursor = conn.cursor()
if arg == '전체':
search = ''
else :
search = arg
cursor.execute('SELECT Emoji_name FROM table1 WHERE Emoji_name LIKE ?', ('%' + search + '%', ))
results = cursor.fetchall()
if len(results) == 0 :
await ctx.send('아무 이모지도 검색되지 않았습니다.')
return
embed = discord.Embed(title='이모지 목록', description=str(', '.join(map(lambda x: x[0], results))) )
msg = await ctx.send(embed=embed)
conn.close()
@bot.command(name='!이모지정보')
async def emojiInfo(ctx, *, arg):
conn = sqlite3.connect("d:/Code/Discord/Minikuda2/data/emoji_H.db")
cursor = conn.cursor()
cursor.execute('SELECT * FROM table1 WHERE Emoji_name=?', (arg,))
temp = []
temp = cursor.fetchall()
#print(temp)
if len(temp) == 0:
msg = await ctx.send('이모지가 존재하지 않습니다.')
return
cursor.execute('SELECT link FROM table1 WHERE Emoji_name=?', (arg,))
#print(cursor.fetchone())
#msg = await ctx.send(str(cursor.fetchone()[0]))
embed = discord.Embed(title='~'+arg)
embed.set_image(url=str(cursor.fetchone()[0]))
cursor.execute('SELECT user FROM table1 WHERE Emoji_name=?', (arg,))
embed.set_footer(text='Added By '+str(cursor.fetchone()[0]))
msg = await ctx.send(embed=embed)
conn.close()
@bot.command(name='~')
async def emojiloader(ctx, *,arg):
conn = sqlite3.connect("d:/Code/Discord/Minikuda2/data/emoji_H.db")
cursor = conn.cursor()
cursor.execute('SELECT * FROM table1 WHERE Emoji_name=?', (arg,))
temp = []
temp = cursor.fetchall()
#print(temp)
if len(temp) == 0:
msg = await ctx.send('이모지가 존재하지 않습니다.')
return
cursor.execute('SELECT link FROM table1 WHERE Emoji_name=?', (arg,))
#print(cursor.fetchone())
#msg = await message.channel.send(str(cursor.fetchone()[0]))
embed = discord.Embed()
embed.set_image(url=str(cursor.fetchone()[0]))
embed.set_author(name=str(ctx.message.author), icon_url=ctx.message.author.avatar)
await ctx.message.delete()
msg = await ctx.send(embed=embed)
conn.close()
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
bot.run(TOKEN)