mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 23:37:47 +00:00
Merge branch 'dev' into redis-context
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
from aioredis.client import Redis
|
from aioredis.client import Redis
|
||||||
import discord
|
import discord
|
||||||
|
from discord import ActivityType
|
||||||
from discord.colour import Color
|
from discord.colour import Color
|
||||||
from discord.ext import commands
|
from discord.ext import commands, tasks
|
||||||
import sys
|
import sys
|
||||||
from signal import SIGINT, SIGTERM
|
from signal import SIGINT, SIGTERM
|
||||||
import json
|
import json
|
||||||
@@ -26,6 +27,9 @@ class ChristmasBot(commands.Bot):
|
|||||||
voice_states=True, guild_messages=True, guilds=True, messages=True
|
voice_states=True, guild_messages=True, guilds=True, messages=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.rpc_is_help_message = True
|
||||||
|
self.update_status.start()
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.initial_cog_names: List[str] = self.config.get("cogs", [])
|
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", []))
|
||||||
@@ -35,14 +39,18 @@ class ChristmasBot(commands.Bot):
|
|||||||
)
|
)
|
||||||
self.invite_link: str = ""
|
self.invite_link: str = ""
|
||||||
|
|
||||||
|
slash_guilds = None
|
||||||
|
if len(self.config["slash_command_guilds"]) > 0:
|
||||||
|
slash_guilds = self.config["slash_command_guilds"]
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
command_prefix=self.prefix_callable,
|
command_prefix=self.prefix_callable,
|
||||||
description=self.config["info"].get("description", ""),
|
description=self.config["info"]["description"],
|
||||||
case_insensitive=False,
|
case_insensitive=False,
|
||||||
fetch_offline_members=False,
|
fetch_offline_members=False,
|
||||||
intents=intents,
|
intents=intents,
|
||||||
slash_commands=True,
|
slash_commands=True,
|
||||||
slash_command_guilds=[227431704426446848],
|
slash_command_guilds=slash_guilds,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.loop.create_task(self.async_init())
|
self.loop.create_task(self.async_init())
|
||||||
@@ -82,6 +90,20 @@ class ChristmasBot(commands.Bot):
|
|||||||
async def get_context(self, message: Message, *, cls=CustomContext):
|
async def get_context(self, message: Message, *, cls=CustomContext):
|
||||||
return await super().get_context(message, cls=cls)
|
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__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
|||||||
+4
-16
@@ -6,24 +6,14 @@ from discord.ext.commands import Context
|
|||||||
import humanize
|
import humanize
|
||||||
import datetime
|
import datetime
|
||||||
import lavalink
|
import lavalink
|
||||||
|
from bot import ChristmasBot
|
||||||
from utils.EmbedGenerator import EmbedGenerator
|
from utils.EmbedGenerator import EmbedGenerator
|
||||||
from utils.paginator import HelpPaginator
|
from utils.paginator import HelpPaginator
|
||||||
|
|
||||||
|
|
||||||
class InformationCog(commands.Cog, name="Information"):
|
class InformationCog(commands.Cog, name="Information"):
|
||||||
def __init__(self, bot: commands.Bot):
|
def __init__(self, bot: ChristmasBot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.is_help_msg = True
|
|
||||||
self.update_status.start()
|
|
||||||
|
|
||||||
@tasks.loop(seconds=30.0)
|
|
||||||
async def update_status(self):
|
|
||||||
await self.bot.wait_until_ready()
|
|
||||||
title = "ck!connect | ck!help"
|
|
||||||
if self.is_help_msg:
|
|
||||||
title = "Tfoe broer"
|
|
||||||
self.is_help_msg = not self.is_help_msg
|
|
||||||
await self.bot.change_presence(activity=discord.Game(title))
|
|
||||||
|
|
||||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
||||||
@commands.command(description="PONG!", aliases=["pong"])
|
@commands.command(description="PONG!", aliases=["pong"])
|
||||||
@@ -53,9 +43,7 @@ class InformationCog(commands.Cog, name="Information"):
|
|||||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
||||||
async def invite(self, ctx: Context):
|
async def invite(self, ctx: Context):
|
||||||
"""Gets the invite link!"""
|
"""Gets the invite link!"""
|
||||||
link = f"https://discord.com/oauth2/authorize?client_id=643555373814382593&permissions=3230720&scope=bot%20applications.commands"
|
await EmbedGenerator.Message(ctx, "Add our bot to your server:", self.bot.invite_link)
|
||||||
embed = await EmbedGenerator.Message(ctx, "Add our bot to your server:", link)
|
|
||||||
await ctx.send(embed=embed)
|
|
||||||
|
|
||||||
@commands.command(
|
@commands.command(
|
||||||
name="wlinfo",
|
name="wlinfo",
|
||||||
@@ -129,6 +117,6 @@ class InformationCog(commands.Cog, name="Information"):
|
|||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot: commands.Bot):
|
def setup(bot: ChristmasBot):
|
||||||
bot.remove_command("help")
|
bot.remove_command("help")
|
||||||
bot.add_cog(InformationCog(bot))
|
bot.add_cog(InformationCog(bot))
|
||||||
|
|||||||
+2
-1
@@ -17,5 +17,6 @@
|
|||||||
"name": "CloudKid Radio",
|
"name": "CloudKid Radio",
|
||||||
"description": "A sample bot description"
|
"description": "A sample bot description"
|
||||||
},
|
},
|
||||||
"cogs": ["cogs.owner", "cogs.settings", "cogs.information", "cogs.music"]
|
"cogs": ["cogs.owner", "cogs.settings", "cogs.information", "cogs.music"],
|
||||||
|
"slash_command_guilds": []
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user