-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathoreo.py
More file actions
71 lines (62 loc) · 2.02 KB
/
oreo.py
File metadata and controls
71 lines (62 loc) · 2.02 KB
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
import os
import discord
from dotenv import load_dotenv
from sqlitedict import SqliteDict
from fuzzywuzzy import process
mydict = SqliteDict('./my_db.sqlite', autocommit=True)
load_dotenv()
lwe = {}
TOKEN = os.getenv('DISCORD_TOKEN')
client = discord.Client()
@client.event
async def on_ready():
print(f'{client.user} has connected to Discord!')
@client.event
async def on_message(message):
cnt = 1
if message.content.startswith("!coreo "):
if len(message.content) < 8:
return
xo = message.content[7:]
elif message.content.startswith("!coreo"):
if len(message.content) < 7:
return
xo = message.content[6:]
else:
return
author_id = message.author.id
x = '**Channel List**\n'
channelList = []
channelmention = {}
for channel in message.guild.channels:
if type(channel) != discord.channel.TextChannel:
continue
channelList.append(channel.name)
channelmention[channel.name] = channel.mention
for channel, weight in process.extract(xo, channelList):
if weight > 0:
x += (
f"> {channelmention[channel]}\n")
cnt += 1
if len(x) > 0:
x += f"**Hit like to create channel '*{xo}*'**"
sent = await message.channel.send(x)
await sent.add_reaction('\N{THUMBS UP SIGN}')
mydict[sent.id] = [xo, author_id, False]
else:
sent = await message.channel.send(f"**No results. Hit like to create channel '*{xo}*'.**")
await sent.add_reaction('\N{THUMBS UP SIGN}')
mydict[sent.id] = [xo, author_id, False]
@client.event
async def on_reaction_add(reaction, user):
if user.bot:
return
if reaction.message.id not in mydict:
return
if user.id != mydict[reaction.message.id][1]:
return
if mydict[reaction.message.id][2] is True:
return
mydict[reaction.message.id][2] = True
await reaction.message.guild.create_text_channel(mydict[reaction.message.id][0])
client.run(TOKEN)