-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
55 lines (38 loc) · 1.47 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
import logging
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
import discord
from discord.ext import commands
from cogs.error_handler import GenericErrorHandler
from cogs.settings import UserCog
from fb.env import (
DISCORD_TOKEN,
LOG_LEVEL,
SENTRY_DSN,
)
from tasks import travel_task, alerts_task
logger = logging.getLogger(__name__)
logging.basicConfig(level=getattr(logging, LOG_LEVEL))
if SENTRY_DSN:
sentry_logging = LoggingIntegration(
level=logging.DEBUG, # Capture info and above as breadcrumbs
event_level=logging.ERROR # Send errors as events
)
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=[sentry_logging, AioHttpIntegration()]
)
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
"""http://discordpy.readthedocs.io/en/rewrite/api.html#discord.on_ready"""
print(f'\n\nLogged in as: {bot.user.name} - {bot.user.id}\nVersion: {discord.__version__}\n')
# Changes our bots Playing Status. type=1(streaming) for a standard game you could remove type and url.
await bot.change_presence(activity=discord.Game(name='Torn City', type=1, url='https://www.torn.com'))
print(f'Successfully logged in and booted...!')
bot.add_cog(GenericErrorHandler(bot))
bot.add_cog(UserCog(bot))
bot.loop.create_task(alerts_task(bot))
bot.loop.create_task(travel_task(bot))
bot.run(DISCORD_TOKEN)