mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
parent
4d7f065b10
commit
684004d614
@ -6,14 +6,14 @@ from importlib.machinery import ModuleSpec
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
from discord.ext.commands.bot import BotBase
|
||||||
from discord.ext.commands import GroupMixin
|
from discord.ext.commands import GroupMixin
|
||||||
|
|
||||||
from .cog_manager import CogManager
|
from .cog_manager import CogManager
|
||||||
from . import Config, i18n, RedContext
|
from . import Config, i18n, RedContext
|
||||||
|
|
||||||
|
|
||||||
class Red(commands.Bot):
|
class RedBase(BotBase):
|
||||||
def __init__(self, cli_flags, bot_dir: Path=Path.cwd(), **kwargs):
|
def __init__(self, cli_flags, bot_dir: Path=Path.cwd(), **kwargs):
|
||||||
self._shutdown_mode = ExitCodes.CRITICAL
|
self._shutdown_mode = ExitCodes.CRITICAL
|
||||||
self.db = Config.get_core_conf(force_registration=True)
|
self.db = Config.get_core_conf(force_registration=True)
|
||||||
@ -86,18 +86,6 @@ class Red(commands.Bot):
|
|||||||
async def get_context(self, message, *, cls=RedContext):
|
async def get_context(self, message, *, cls=RedContext):
|
||||||
return await super().get_context(message, cls=cls)
|
return await super().get_context(message, cls=cls)
|
||||||
|
|
||||||
async def shutdown(self, *, restart=False):
|
|
||||||
"""Gracefully quits Red with exit code 0
|
|
||||||
|
|
||||||
If restart is True, the exit code will be 26 instead
|
|
||||||
Upon receiving that exit code, the launcher restarts Red"""
|
|
||||||
if not restart:
|
|
||||||
self._shutdown_mode = ExitCodes.SHUTDOWN
|
|
||||||
else:
|
|
||||||
self._shutdown_mode = ExitCodes.RESTART
|
|
||||||
|
|
||||||
await self.logout()
|
|
||||||
|
|
||||||
def list_packages(self):
|
def list_packages(self):
|
||||||
"""Lists packages present in the cogs the folder"""
|
"""Lists packages present in the cogs the folder"""
|
||||||
return os.listdir("cogs")
|
return os.listdir("cogs")
|
||||||
@ -176,6 +164,23 @@ class Red(commands.Bot):
|
|||||||
# del sys.modules[name]
|
# del sys.modules[name]
|
||||||
|
|
||||||
|
|
||||||
|
class Red(RedBase, discord.AutoShardedClient):
|
||||||
|
"""
|
||||||
|
You're welcome Caleb.
|
||||||
|
"""
|
||||||
|
async def shutdown(self, *, restart=False):
|
||||||
|
"""Gracefully quits Red with exit code 0
|
||||||
|
|
||||||
|
If restart is True, the exit code will be 26 instead
|
||||||
|
Upon receiving that exit code, the launcher restarts Red"""
|
||||||
|
if not restart:
|
||||||
|
self._shutdown_mode = ExitCodes.SHUTDOWN
|
||||||
|
else:
|
||||||
|
self._shutdown_mode = ExitCodes.RESTART
|
||||||
|
|
||||||
|
await self.logout()
|
||||||
|
|
||||||
|
|
||||||
class ExitCodes(Enum):
|
class ExitCodes(Enum):
|
||||||
CRITICAL = 1
|
CRITICAL = 1
|
||||||
SHUTDOWN = 0
|
SHUTDOWN = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user