1
0
Fork 0
mirror of synced 2024-09-28 23:41:41 +12:00

Logging possible exceptions

This commit is contained in:
Phxntxm 2016-11-12 18:10:36 -06:00
parent 6f2a8895d0
commit 3bd12851b8
3 changed files with 158 additions and 142 deletions

View file

@ -1,6 +1,7 @@
import aiohttp
import asyncio
import discord
import traceback
from discord.ext import commands
from .utils import config
@ -52,6 +53,7 @@ class Deviantart:
# People might sub to the same person, so lets cache every person and their last update
cache = {}
try:
for entry in content:
user = discord.utils.get(self.bot.get_all_members(), id=entry['member_id'])
@ -94,6 +96,10 @@ class Deviantart:
r_filter = {'member_id': user.id}
update = {'last_updated': {da_name: result['deviationid']}}
await config.update_content('deviantart', update, r_filter)
except Exception as e:
tb = traceback.format_tb(e)
fmt = "{}\n{0.__class__.__name__}: {0}".format(tb, e)
log.error(fmt)
@commands.group()
@checks.custom_perms(send_messages=True)

View file

@ -46,6 +46,7 @@ class Picarto:
async def check_channels(self):
await self.bot.wait_until_ready()
# This is a loop that runs every 30 seconds, checking if anyone has gone online
try:
while not self.bot.is_closed:
r_filter = {'notifications_on': 1}
picarto = await config.get_content('picarto', r_filter)
@ -101,6 +102,10 @@ class Picarto:
await self.bot.send_message(channel, fmt)
await config.update_content('picarto', {'live': 0}, {'member_id': m_id})
await asyncio.sleep(30)
except Exception as e:
tb = traceback.format_tb(e)
fmt = "{}\n{0.__class__.__name__}: {0}".format(tb, e)
log.error(fmt)
@commands.group(pass_context=True, invoke_without_command=True, no_pm=True)
@checks.custom_perms(send_messages=True)

View file

@ -42,6 +42,7 @@ class Twitch:
async def check_channels(self):
await self.bot.wait_until_ready()
# Loop through as long as the bot is connected
try:
while not self.bot.is_closed:
twitch = await config.get_content('twitch', {'notifications_on': 1})
# Online/offline is based on whether they are set to such, in the config file
@ -93,6 +94,10 @@ class Twitch:
await self.bot.send_message(channel, fmt)
await config.update_content('twitch', {'live': 0}, {'member_id': m_id})
await asyncio.sleep(30)
except Exception as e:
tb = traceback.format_tb(e)
fmt = "{}\n{0.__class__.__name__}: {0}".format(tb, e)
log.error(fmt)
@commands.group(no_pm=True, invoke_without_command=True, pass_context=True)
@checks.custom_perms(send_messages=True)