-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
169 lines (134 loc) · 4.38 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
165
166
167
168
169
#!/usr/bin/python3
import discord
from discord.ext import commands as cmds
import os
bot = cmds.Bot(command_prefix="%", intents=discord.Intents.all())
bot.help_command = None
def make_directories():
from os.path import isdir
if not isdir("data"):
os.mkdir("data")
if not isdir("data/custom_words"):
os.mkdir("data/custom_words")
if not isdir("data/guild_familys"):
os.mkdir("data/guild_familys")
if not isdir("data/user_familys"):
os.mkdir("data/user_familys")
@bot.listen("on_raw_reaction_add")
async def delete_awnser(payload):
from commands.admincmds import paused
if paused:
return
if payload.emoji.name != "🗑️️":
return
guild = discord.utils.get(bot.guilds, id=payload.guild_id)
channel = discord.utils.get(await guild.fetch_channels(), id=payload.channel_id)
message = channel.fetch_message(payload.message_id)
if message.author.id != bot.user.id:
return
from embeds import create_custom_embed
from discord import Colour
await channel.send(
embed=create_custom_embed(
embed_title="Successfully completed",
embed_message=f"This message will be deleted in 5 seconds. To cancel this process, react with a \"❌\".",
user=message.author,
colour=Colour.green()
)
)
from utils import get_confirmation, ReturnCodes
confirmation = await get_confirmation(message, message.author, bot)
if confirmation == ReturnCodes.SUCCESS:
await message.delete()
elif confirmation == ReturnCodes.CANCELLED:
await message.delete()
elif confirmation == ReturnCodes.TIMEOUT_ERROR:
await message.delete()
elif confirmation == ReturnCodes.OTHER_ERROR:
from embeds import handle_error
await message.channel.send(embed=handle_error(confirmation, message.author))
@bot.listen("on_message")
async def send_link(message):
from commands.admincmds import paused
if paused:
return
if "{" not in message.content or message.author.bot:
return
from search import manage_search
links = manage_search(message)
if len(links[0]) > 2000:
await message.channel.send("You included too many links in this message!")
return
if links[1] is True:
await message.channel.send(
links[0] +
"\nYou have not yet set a default URL!\n"
"For help, type `%help default url`."
)
else:
await message.channel.send(links[0])
@bot.command()
async def help(ctx, *args):
from commands.admincmds import paused
if paused:
return
from commands import help
await help.manage_request(ctx, *args)
@bot.event
async def on_ready():
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name="%help"
)
)
print("Logged on as", bot.user)
@bot.command()
async def userwords(ctx, *args):
from commands.admincmds import paused
if paused:
return
from commands.custom_words_user import manage_request
await manage_request(ctx, *args, client=bot)
@bot.command()
async def op(ctx, *args):
from commands.admincmds import paused
if paused:
return
from commands.manage_operators import manage_request
await manage_request(ctx, *args, client=bot)
@bot.command()
async def guildwords(ctx, *args):
from commands.admincmds import paused
if paused:
return
from commands.custom_words_guild import manage_request
await manage_request(ctx, *args, client=bot)
@bot.command()
async def guildfamily(ctx, *args):
from commands.admincmds import paused
if paused:
return
from commands.guild_family import manage_request
await manage_request(ctx, *args, client=bot)
@bot.command()
async def userfamily(ctx, *args):
from commands.admincmds import paused
if paused:
return
from commands.user_family import manage_request
await manage_request(ctx, *args, client=bot)
@bot.command()
async def close(ctx):
from commands.admincmds import shutdown
await shutdown(ctx, bot)
@bot.command()
async def shutdown(ctx):
from commands.admincmds import shutdown
await shutdown(ctx, bot)
@bot.command()
async def pause(ctx):
from commands.admincmds import pause
await pause(ctx, bot)
make_directories()
bot.run(os.getenv("TOKEN"))