Move `close_old_connections()` to `cog_before_invoke()` (#30)

reminder
Joey Hines 2019-08-29 18:59:34 +02:00 committed by Gitea
parent 12e41ce9b7
commit 8073765a57
2 changed files with 5 additions and 5 deletions

View File

@ -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:

View File

@ -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