mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 19:57:48 +00:00
Merge branch 'dev' into lavalink-functionality
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import asyncio
|
||||
from aioredis.client import Redis
|
||||
import discord
|
||||
from discord import ActivityType
|
||||
from discord.colour import Color
|
||||
from discord.ext import commands
|
||||
from discord.ext import commands, tasks
|
||||
import sys
|
||||
from signal import SIGINT, SIGTERM
|
||||
import json
|
||||
from typing import Any, Dict, List, Sequence
|
||||
from discord import Message
|
||||
@@ -12,6 +16,10 @@ from discord.ext.commands.errors import (
|
||||
NoEntryPointError,
|
||||
)
|
||||
import lavalink
|
||||
import aioredis
|
||||
from aioredis import Redis
|
||||
|
||||
from context import CustomContext
|
||||
|
||||
|
||||
class ChristmasBot(commands.Bot):
|
||||
@@ -23,18 +31,31 @@ class ChristmasBot(commands.Bot):
|
||||
voice_states=True, guild_messages=True, guilds=True, messages=True
|
||||
)
|
||||
|
||||
self.rpc_is_help_message = True
|
||||
self.update_status.start()
|
||||
|
||||
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._redis_client: Redis = aioredis.from_url(
|
||||
self.config["redis_url"], encoding="utf-8", decode_responses=True
|
||||
)
|
||||
self.invite_link: str = ""
|
||||
|
||||
slash_guilds = None
|
||||
if len(self.config["slash_command_guilds"]) > 0:
|
||||
slash_guilds = self.config["slash_command_guilds"]
|
||||
|
||||
super().__init__(
|
||||
command_prefix=self.prefix_callable,
|
||||
description=self.config["info"].get("description", ""),
|
||||
description=self.config["info"]["description"],
|
||||
case_insensitive=False,
|
||||
fetch_offline_members=False,
|
||||
intents=intents,
|
||||
slash_commands=True,
|
||||
slash_command_guilds=[227431704426446848],
|
||||
slash_command_guilds=slash_guilds,
|
||||
)
|
||||
|
||||
self.loop.create_task(self.async_init())
|
||||
@@ -71,6 +92,23 @@ class ChristmasBot(commands.Bot):
|
||||
colour_dict[name] = Color(int(color, 16))
|
||||
return colour_dict
|
||||
|
||||
async def get_context(self, message: Message, *, cls=CustomContext):
|
||||
return await super().get_context(message, cls=cls)
|
||||
|
||||
@tasks.loop(seconds=30)
|
||||
async def update_status(self):
|
||||
await self.wait_until_ready()
|
||||
|
||||
bot_prefix = self.config["prefixes"][0]
|
||||
if self.rpc_is_help_message:
|
||||
title = f"for {bot_prefix}connect | {bot_prefix}help"
|
||||
activity = discord.Activity(name=title, type=ActivityType.watching)
|
||||
else:
|
||||
activity = discord.Activity(name="Some song", type=ActivityType.playing)
|
||||
|
||||
self.rpc_is_help_message = not self.rpc_is_help_message
|
||||
await self.change_presence(activity=activity)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user