-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
bot.py
148 lines (110 loc) · 3.65 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
from discord.ext import commands
from discord import Bot, Intents
import discord
import sys
from helpers.logger import Logger
from managers import cache_manager, mongo_manager, init_manager, post_command_manager
from config import TOKEN, MONGO_URI, TEST_TOKEN
from helpers import general_helper
from checkers import rare_catch_detection
from checkers import auto_battle_log
from checkers import spawn_speed_detection
from checkers import donation_detection
# determines whether to run the bot in local, or global mode
is_test = False
intents = Intents.default()
intents.message_content = True
# for getting the prefix
def prefix_callable(_bot: Bot, message):
return [f"<@{_bot.user.id}> ", f"<@!{_bot.user.id}> ", "-aa ", "aa."]
bot = commands.AutoShardedBot(command_prefix=prefix_callable, description="Botto", case_insensitive=True, intents=intents)
bot.remove_command("help")
initial_cogs = [
"presence_cycle",
"admin",
"starboard",
"help",
"smogon",
"mail",
"utility",
"suggestion",
"error_handler",
"pokedex",
"pokemon_info",
"random_misc",
"ruleset",
"spawn_speed",
"tag",
"fun",
"battle",
"donation"
]
initial_slash_cogs = [
"pokedex",
"pokeinfo",
"starboard",
"random_misc",
"ruleset",
"suggestion",
"tag",
"smogon",
"utility",
"battle",
"fun",
"help"
]
@bot.event
async def on_guild_join(guild):
await init_manager.register_guild(bot, guild)
@bot.event
async def on_guild_remove(guild):
await init_manager.remove_guild(bot, guild)
@bot.event
async def on_ready():
mongo_manager.init_mongo(MONGO_URI, "aerialace")
await cache_manager.cache_data()
Logger.log_message(f"Logged in as {bot.user}")
Logger.log_message(f"Discord Version : {discord.__version__}")
@bot.event
async def on_message(message: discord.Message):
# ignore your own stuff
if message.author == bot.user:
return
# reply to solo pings
if message.content == "<@908384747393286174>":
await message.channel.send(embed=(await general_helper.get_info_embd(title="Alola :wave:, This is Aerial Ace.", desc="Prefix : `-aa` or `aa.`\n**Slash Commands are available**\nPing : **{ping} ms** \nHelp Command : `-aa help`".format(ping=round(bot.latency * 1000, 2)))))
# detect rare catches from the poketwo bot
await rare_catch_detection.rare_check(bot, message)
# await auto_battle_log.determine_battle_message(bot, message)
await spawn_speed_detection.detect_spawn(message)
await donation_detection.donation_check(bot, message)
# process commands
await bot.process_commands(message)
@bot.listen("on_command_completion")
@bot.listen("on_application_command_completion")
async def after_command(ctx: commands.Context):
if ctx.command.name != "help" and ctx.command.name != "mail":
await post_command_manager.process_post_commands(ctx)
def main():
for cog in initial_cogs:
bot.load_extension(f"cogs.{cog}")
for slash_cog in initial_slash_cogs:
bot.load_extension(f"cogs.slash.{slash_cog}")
if __name__ == "__main__":
print("""
___ _ _ ___
/ _ \ (_) | | / _ \
/ /_\ \ ___ _ __ _ __ _| | / /_\ \ ___ ___
| _ |/ _ \ '__| |/ _` | | | _ |/ __/ _ \\
| | | | __/ | | | (_| | | | | | | (_| __/
\_| |_/\___|_| |_|\__,_|_| \_| |_/\___\___|
""")
if len(sys.argv) < 2:
is_test = False
else:
is_test = (True if sys.argv[1].lower() == "true" else False)
main()
if is_test is False:
bot.run(TOKEN)
else:
bot.run(TEST_TOKEN)