Move `close_old_connections()` to `cog_before_invoke()` (#30)
parent
12e41ce9b7
commit
8073765a57
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue