From 8073765a5719743e6a9c6681794cd6c3e79ff7f1 Mon Sep 17 00:00:00 2001 From: ZeroHD Date: Thu, 29 Aug 2019 18:59:34 +0200 Subject: [PATCH] Move `close_old_connections()` to `cog_before_invoke()` (#30) --- bot/commands.py | 5 +++++ bot/discord.py | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) 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