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