forked from mdiller/MangoByte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmangobyte.py
89 lines (70 loc) · 2.65 KB
/
mangobyte.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
import datetime
import sys
import disnake
from disnake.ext import commands
import utils.other.errorhandling as errorhandling
import utils.other.initialization as initialization
import utils.other.update_script as update_script
from utils.tools.globals import botdata, logger, settings, httpgetter
from utils.tools.helpers import *
startupTimer = SimpleTimer()
description = """A discord bot built primarily around playing audio clips and dota related commands.
For more information about me, try `/bot info`"""
intents = disnake.Intents.default()
intents.message_content = True
sync_flags = commands.CommandSyncFlags.default()
sync_flags.sync_commands_debug = False
bot = commands.AutoShardedBot(
command_prefix="?", # for any lingering owner-only commands
description=description,
case_insensitive=True,
shard_count=settings.shard_count,
command_sync_flags=sync_flags,
test_guilds=settings.test_guilds,
guild_ready_timeout=10.0,
reload=False,
intents=intents)
bot.remove_command("help")
# registering some global events
@bot.event
async def on_shard_ready(shard_id):
logger.info(f"shard {shard_id} ({len(bot.shards)} total) called its on_shard_ready ({len(bot.guilds)} guilds)")
@bot.event
async def on_ready():
logger.info(f"on_ready() triggered")
@bot.application_command_check()
def check_app_commands(inter: disnake.Interaction):
return bot.get_cog("Admin").bot_check(inter)
@bot.event
async def on_command_error(ctx: commands.Context, error: commands.CommandError):
await errorhandling.on_prefix_command_error(ctx, error)
@bot.event
async def on_slash_command_error(inter: disnake.Interaction, error: commands.CommandError):
await errorhandling.on_app_command_error(inter, error)
from cogs.admin import Admin
from cogs.audio import Audio
from cogs.dotabase import Dotabase
from cogs.dotastats import DotaStats
from cogs.general import General
from cogs.owner import Owner
from cogs.pokemon import Pokemon
if __name__ == '__main__':
bot.add_cog(General(bot))
bot.add_cog(Audio(bot))
bot.add_cog(Dotabase(bot))
bot.add_cog(DotaStats(bot))
bot.add_cog(Pokemon(bot))
bot.add_cog(Admin(bot))
bot.add_cog(Owner(bot))
if len(sys.argv) > 1 and sys.argv[1] in ["commands", "update"]:
# instead of running the bot, run our script to update static files
logger.disabled = True
just_run_update_script = True
print("Starting bot temporarily...")
loop = asyncio.get_event_loop()
loop.create_task(update_script.update(bot))
loop.run_until_complete(bot.start(settings.token))
else:
print(f"Starting mango at {datetime.datetime.today().strftime('%d-%b-%Y %I:%M %p')}")
bot.loop.create_task(initialization.initialize(bot, startupTimer))
bot.run(settings.token)