-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacademy.py
74 lines (61 loc) · 2.13 KB
/
academy.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
import discord
from discord.errors import Forbidden
from classes.services.database import DatabaseService
from classes.services.config import get_config
from classes.services.logging import config_logger
from classes.cogs.members import NamedCog, MemberCog
from classes.cogs.characters import CharactersCog
from classes.cogs.leagues import LeaguesCog, RaidCog
from classes.cogs.messaging import MessagingCog
from classes.cogs.roles import RolesCog
from classes.cogs.gears import UpgradesCog
from classes.cogs.jumps import JumpCog
from discord.ext.commands import CommandNotFound
from discord.ext import commands
from datetime import datetime
from datetime import timezone
from constants import *
config = get_config('academy.yaml')
logger = config_logger()
db_service = DatabaseService(config['url'], config['database'])
intents = discord.Intents.default()
intents.members = True
intents.dm_messages = True
bot = commands.Bot(command_prefix='-', intents=intents)
bot.remove_command('help')
def register_cogs():
bot.add_cog(NamedCog(bot))
bot.add_cog(LeaguesCog(bot))
bot.add_cog(CharactersCog(bot, db_service))
bot.add_cog(RolesCog(bot))
bot.add_cog(JumpCog(bot, db_service))
bot.add_cog(UpgradesCog(db_service))
bot.add_cog(MessagingCog(bot, db_service))
bot.add_cog(MemberCog(bot))
bot.add_cog(RaidCog(bot, db_service))
@bot.event
async def on_command_error(ctx, error):
debug_channel = bot.get_channel(784119325958864936)#bot - канал на моем сервере
if isinstance(error, CommandNotFound):
debug_msg = DEBUG_MESSAGE.format(
ctx.author,
ctx.message,
ctx.message.channel)
logger.info(debug_msg)
await debug_channel.send(debug_msg)
return
raise error
@bot.event
async def on_ready():
print(LOGGED.format(bot.user.id, bot.user.name))
register_cogs()
@bot.command()
async def time(ctx):
await ctx.send(TIME.format(datetime.now(timezone.utc).strftime(HOURS_FORMAT)))
@bot.command()
async def help(ctx):
try:
await ctx.author.send(HELP)
except Forbidden as e:
logger.debug(e)
bot.run(config['token'])