-
Notifications
You must be signed in to change notification settings - Fork 3
/
amadeus.py
114 lines (92 loc) · 3.69 KB
/
amadeus.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
import traceback
import discord
from discord.ext import commands
from core.emote import emote
from core.config import config
from core import check, help, basecog
from features import presence
from repository.database import session
from repository.database import database
from repository.database.vote import Vote # noqa F401
from repository.database.remind import Reminder # noqa F401
from repository.database.user_channels import UserChannel # noqa F401
from repository.database.unverify import Unverify # noqa F401
from repository.database.tempverify import Tempverify # noqa F401
from repository.database.emote import Emote # noqa F401
intents = discord.Intents.default()
intents.members = True
intents.presences = True
bot = commands.Bot(
command_prefix=commands.when_mentioned_or(*config.prefixes),
help_command=help.Help(),
allowed_mentions=discord.AllowedMentions(roles=False, everyone=False, users=True),
intents=intents,
)
presence = presence.Presence(bot)
basecog = basecog.Basecog(bot)
@bot.event
async def on_ready():
"""If Amadeus is ready."""
if config.debug < 1:
login = "Logged in"
else:
login = "Logged with debug(" + str(config.debug) + ")"
await basecog.log(level="info", message=login)
await presence.set_presence()
@bot.event
async def on_error(event, *args, **kwargs):
channel = bot.get_channel(config.channel_botdev)
output = traceback.format_exc()
print(output)
output = list(output[0 + i : 1960 + i] for i in range(0, len(output), 1960))
if channel is not None:
for message in output:
await channel.send("```\n{}```".format(message))
@commands.check(check.is_mod)
@bot.command()
async def load(ctx, extension):
extension = extension.lower()
try:
bot.load_extension(f"cogs.{extension}")
await ctx.send(f"Rozšíření **{extension}** načteno.")
await basecog.log(level="info", message=f"Cog {extension} loaded")
except Exception as e:
await ctx.send(f"Načtení rozšíření **{extension}** se nezdařilo.")
await basecog.log(level="error", message="Cog loading failed" + str(e))
@commands.check(check.is_mod)
@bot.command()
async def unload(ctx, extension):
extension = extension.lower()
try:
bot.unload_extension(f"cogs.{extension}")
await ctx.send(f"Rozšíření **{extension}** odebráno.")
await basecog.log(level="info", message=f"Cog {extension} unloaded")
except Exception as e:
await ctx.send(f"Odebrání rozšíření **{extension}** se nezdařilo.")
await basecog.log(level="error", message="Cog loading failed" + str(e))
@commands.check(check.is_mod)
@bot.command()
async def reload(ctx, extension):
extension = extension.lower()
try:
bot.reload_extension(f"cogs.{extension}")
await ctx.send(f"Rozšíření **{extension}** aktualizováno.")
await basecog.log(level="info", message=f"Cog {extension} reloaded")
except Exception as e:
await ctx.send(f"Aktualizace rozšíření **{extension}** se nepovedla.")
await basecog.log(level="error", message="Cog loading failed" + str(e))
@reload.error
@load.error
@unload.error
async def missing_arg_error(ctx, error):
if isinstance(error, commands.errors.MissingRequiredArgument):
await ctx.send("Nesprávný počet argumentů" + emote.sad)
# database.base.metadata.drop_all(database.db)
database.base.metadata.create_all(database.db)
session.commit() # Making sure
bot.load_extension("cogs.errors")
print("Meta ERRORS extension loaded.")
for extension in config.extensions:
bot.load_extension(f"cogs.{extension}")
print("{} extension loaded.".format(extension.upper()))
bot.run(config.key)