diff --git a/bot/commands.py b/bot/commands.py index ef7fae5..b084530 100644 --- a/bot/commands.py +++ b/bot/commands.py @@ -1,6 +1,7 @@ import discord from discord.ext import commands from django.contrib.auth.models import User +from django.db import close_old_connections from minecraft_manager.api import api from minecraft_manager.bot.utils import get_application, build_info @@ -12,6 +13,10 @@ class Commands(commands.Cog): def __init__(self, bot): self.bot = bot + async def cog_before_invoke(self, ctx): + # FIX STALE DB CONNECTIONS + close_old_connections() + async def cog_check(self, ctx): # No DMs if ctx.guild is None: diff --git a/bot/discord.py b/bot/discord.py index 970ccaf..89f7ae5 100644 --- a/bot/discord.py +++ b/bot/discord.py @@ -6,7 +6,6 @@ import traceback import discord from discord.ext import commands from django.conf import settings -from django.db import close_old_connections from minecraft_manager.bot.commands import Commands @@ -48,10 +47,6 @@ class Discord(commands.Bot): else: await dest.send(message) - async def before_invoke(self, coro): - # FIX STALE DB CONNECTIONS - close_old_connections() - async def on_command_error(self, context, exception): if not isinstance(exception, commands.CommandInvokeError): return