mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 22:57:48 +00:00
A bunch of small changes
This commit is contained in:
@@ -3,32 +3,24 @@ from discord.colour import Color
|
||||
from discord.ext import commands
|
||||
import sys
|
||||
import json
|
||||
import asyncio
|
||||
from typing import Any, Dict, Sequence
|
||||
from typing import Any, Dict, List, Sequence
|
||||
from discord import Message
|
||||
|
||||
|
||||
class Database:
|
||||
def __init__(self):
|
||||
self.loop = asyncio.get_event_loop()
|
||||
from discord.ext.commands.errors import (
|
||||
ExtensionAlreadyLoaded,
|
||||
ExtensionFailed,
|
||||
ExtensionNotFound,
|
||||
NoEntryPointError,
|
||||
)
|
||||
|
||||
|
||||
class ChristmasBot(commands.Bot):
|
||||
INITIAL_EXTENSIONS = [
|
||||
"cogs.owner",
|
||||
"cogs.settings",
|
||||
"cogs.information",
|
||||
"cogs.music",
|
||||
]
|
||||
|
||||
def __init__(self, config: Dict[Any, Any]):
|
||||
intents: discord.Intents = discord.Intents.none()
|
||||
intents.voice_states = True
|
||||
intents.guild_messages = True
|
||||
intents.guilds = True
|
||||
intents.messages = True
|
||||
intents = discord.Intents(
|
||||
voice_states=True, guild_messages=True, guilds=True, messages=True
|
||||
)
|
||||
|
||||
self.config = config
|
||||
self.initial_cog_names: List[str] = self.config.get("cogs", [])
|
||||
self.colors: Dict[str, Color] = self.process_colours(config.get("colors", []))
|
||||
|
||||
self.invite_link: str = ""
|
||||
@@ -56,7 +48,12 @@ class ChristmasBot(commands.Bot):
|
||||
try:
|
||||
self.load_extension(cog)
|
||||
print(f"Succesfully loaded extension {cog}.")
|
||||
except Exception as e:
|
||||
except (
|
||||
ExtensionNotFound,
|
||||
ExtensionAlreadyLoaded,
|
||||
NoEntryPointError,
|
||||
ExtensionFailed,
|
||||
) as e:
|
||||
print(f"Failed to load extension {cog}.\n\t{e}", file=sys.stderr)
|
||||
|
||||
async def on_ready(self):
|
||||
@@ -84,5 +81,4 @@ if __name__ == "__main__":
|
||||
|
||||
config = json.load(open("config.json", "r", encoding="utf-8"))
|
||||
token = config.pop("token")
|
||||
bot = ChristmasBot(config)
|
||||
bot.run(token, reconnect=True)
|
||||
ChristmasBot(config).run(token, reconnect=True)
|
||||
|
||||
Reference in New Issue
Block a user