mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 22:57:48 +00:00
Merge branch 'dev' into player-control-ui
This commit is contained in:
+9
-18
@@ -12,15 +12,13 @@ from discord.ext.commands import Context
|
|||||||
from bot import ChristmasBot
|
from bot import ChristmasBot
|
||||||
from utils.database import AutoJoin
|
from utils.database import AutoJoin
|
||||||
from utils.EmbedGenerator import EmbedGenerator
|
from utils.EmbedGenerator import EmbedGenerator
|
||||||
|
from utils.classes import BaseCog
|
||||||
from utils.paginator import HelpPaginator
|
from utils.paginator import HelpPaginator
|
||||||
|
|
||||||
|
|
||||||
class InformationCog(commands.Cog, name="Information"):
|
class InformationCog(BaseCog, name="Information"):
|
||||||
def __init__(self, bot: ChristmasBot):
|
@commands.command(name="ping", aliases=["pong"])
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@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"])
|
|
||||||
async def ping(self, ctx: Context):
|
async def ping(self, ctx: Context):
|
||||||
"""Test the latency"""
|
"""Test the latency"""
|
||||||
avatar = ctx.author.avatar.with_static_format("jpeg")
|
avatar = ctx.author.avatar.with_static_format("jpeg")
|
||||||
@@ -41,24 +39,18 @@ class InformationCog(commands.Cog, name="Information"):
|
|||||||
embed.set_footer(text=f"Requested by: {ctx.author}", icon_url=f"{avatar}")
|
embed.set_footer(text=f"Requested by: {ctx.author}", icon_url=f"{avatar}")
|
||||||
await msg.edit(embed=embed)
|
await msg.edit(embed=embed)
|
||||||
|
|
||||||
@commands.command(
|
@commands.command(name="invite")
|
||||||
name="invite", description="Gets the invite link!", slash_commands=True
|
|
||||||
)
|
|
||||||
@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"""
|
||||||
await EmbedGenerator.Message(
|
await EmbedGenerator.Message(
|
||||||
ctx, "Add our bot to your server:", self.bot.invite_link
|
ctx, "Add our bot to your server:", self.bot.invite_link
|
||||||
)
|
)
|
||||||
|
|
||||||
@commands.command(
|
@commands.command(name="wlinfo")
|
||||||
name="wlinfo",
|
|
||||||
description="Retrieve various Node/Server/Player information.",
|
|
||||||
slash_commands=True,
|
|
||||||
)
|
|
||||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
||||||
async def wlinfo(self, ctx: Context):
|
async def wlinfo(self, ctx: Context):
|
||||||
"""Retrieve various Node/Server/Player information."""
|
"""Retrieve various node/server/player information"""
|
||||||
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
player = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
||||||
node = player.node
|
node = player.node
|
||||||
|
|
||||||
@@ -79,10 +71,9 @@ class InformationCog(commands.Cog, name="Information"):
|
|||||||
f"Server Uptime: `{datetime.timedelta(milliseconds=node.stats.uptime)}`"
|
f"Server Uptime: `{datetime.timedelta(milliseconds=node.stats.uptime)}`"
|
||||||
)
|
)
|
||||||
await ctx.send(fmt)
|
await ctx.send(fmt)
|
||||||
|
|
||||||
AutoJoin.get_channels()
|
AutoJoin.get_channels()
|
||||||
|
|
||||||
@commands.command(name="help", aliases=["about", "info"], slash_command=True)
|
@commands.command(name="help", aliases=["about", "info"])
|
||||||
@commands.cooldown(1, 1, commands.BucketType.user)
|
@commands.cooldown(1, 1, commands.BucketType.user)
|
||||||
async def about(
|
async def about(
|
||||||
self,
|
self,
|
||||||
@@ -91,7 +82,7 @@ class InformationCog(commands.Cog, name="Information"):
|
|||||||
description="Show help for a command or category"
|
description="Show help for a command or category"
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
"""ChristmasBot command list"""
|
"""Retrieve a list of possible commands"""
|
||||||
if command:
|
if command:
|
||||||
entity = self.bot.get_cog(command) or self.bot.get_command(command)
|
entity = self.bot.get_cog(command) or self.bot.get_command(command)
|
||||||
|
|
||||||
|
|||||||
+12
-11
@@ -16,6 +16,7 @@ from lavalink.models import AudioTrack
|
|||||||
from lavalink.models import DefaultPlayer
|
from lavalink.models import DefaultPlayer
|
||||||
|
|
||||||
from bot import ChristmasBot
|
from bot import ChristmasBot
|
||||||
|
from utils.classes import BaseCog
|
||||||
from context import CustomContext
|
from context import CustomContext
|
||||||
from utils.database import AutoJoin
|
from utils.database import AutoJoin
|
||||||
from utils.database import Playlist
|
from utils.database import Playlist
|
||||||
@@ -74,10 +75,7 @@ class LavalinkVoiceClient(discord.VoiceClient):
|
|||||||
self.cleanup()
|
self.cleanup()
|
||||||
|
|
||||||
|
|
||||||
class Music(commands.Cog):
|
class Music(BaseCog):
|
||||||
def __init__(self, bot: ChristmasBot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@commands.Cog.listener()
|
@commands.Cog.listener()
|
||||||
async def on_ready(self):
|
async def on_ready(self):
|
||||||
if not hasattr(
|
if not hasattr(
|
||||||
@@ -118,7 +116,6 @@ class Music(commands.Cog):
|
|||||||
# Get the results for the query from Lavalink.
|
# Get the results for the query from Lavalink.
|
||||||
for query in queries:
|
for query in queries:
|
||||||
result = await player.node.get_tracks(query)
|
result = await player.node.get_tracks(query)
|
||||||
print(result)
|
|
||||||
if not result or not result["tracks"]:
|
if not result or not result["tracks"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -242,10 +239,14 @@ class Music(commands.Cog):
|
|||||||
|
|
||||||
@commands.command(name="connect", aliases=["p", "play", "join"])
|
@commands.command(name="connect", aliases=["p", "play", "join"])
|
||||||
async def play(self, ctx: CustomContext):
|
async def play(self, ctx: CustomContext):
|
||||||
"""Starts playing Christmas bangers"""
|
"""Start the radio"""
|
||||||
# Get the player for this guild from cache.
|
# Get the player for this guild from cache.
|
||||||
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
||||||
await self.fill_player_queue(player, self.bot.config["queue_buffer_size"] + 1)
|
if player.is_connected:
|
||||||
|
await ctx.send("Already connected")
|
||||||
|
return
|
||||||
|
|
||||||
|
await self.fill_player_queue(player, self.bot.config["queue_buffer_size"]
|
||||||
|
|
||||||
if not player.is_playing:
|
if not player.is_playing:
|
||||||
await player.play()
|
await player.play()
|
||||||
@@ -255,14 +256,14 @@ class Music(commands.Cog):
|
|||||||
|
|
||||||
@commands.command(name="skip", aliases=["next"])
|
@commands.command(name="skip", aliases=["next"])
|
||||||
async def skip(self, ctx: Context):
|
async def skip(self, ctx: Context):
|
||||||
"""I heard this song way too often"""
|
"""Skip the current song"""
|
||||||
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
||||||
await player.skip()
|
await player.skip()
|
||||||
await ctx.send("Skipped current song")
|
await ctx.send("Skipped current song")
|
||||||
|
|
||||||
@commands.command(name="queue")
|
@commands.command(name="queue", aliases=["q"])
|
||||||
async def queue(self, ctx: Context):
|
async def queue(self, ctx: Context):
|
||||||
"""Ghetto queue"""
|
"""Display the current radio queue"""
|
||||||
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
||||||
|
|
||||||
embed_color = self.bot.colors["embed"]
|
embed_color = self.bot.colors["embed"]
|
||||||
@@ -280,7 +281,7 @@ class Music(commands.Cog):
|
|||||||
|
|
||||||
@commands.command(name="disconnect", aliases=["dc", "stop"])
|
@commands.command(name="disconnect", aliases=["dc", "stop"])
|
||||||
async def disconnect(self, ctx: Context):
|
async def disconnect(self, ctx: Context):
|
||||||
"""Disconnects ChristmasBot"""
|
"""Disconnects the radio from the channel"""
|
||||||
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
player: DefaultPlayer = self.bot.lavalink.player_manager.get(ctx.guild.id)
|
||||||
|
|
||||||
if not ctx.author.voice or (
|
if not ctx.author.voice or (
|
||||||
|
|||||||
+3
-2
@@ -13,11 +13,12 @@ from discord.ext import commands
|
|||||||
from discord.ext.commands.context import Context
|
from discord.ext.commands.context import Context
|
||||||
|
|
||||||
from bot import ChristmasBot
|
from bot import ChristmasBot
|
||||||
|
from utils.classes import BaseCog
|
||||||
|
|
||||||
|
|
||||||
class OwnerCog(commands.Cog):
|
class OwnerCog(BaseCog):
|
||||||
def __init__(self, bot: ChristmasBot):
|
def __init__(self, bot: ChristmasBot):
|
||||||
self.bot = bot
|
super().__init__(bot)
|
||||||
self._last_result = None
|
self._last_result = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
+11
-6
@@ -1,4 +1,8 @@
|
|||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
from utils.EmbedGenerator import EmbedGenerator
|
||||||
|
from utils.classes import BaseCog
|
||||||
|
from utils.database import AutoJoin
|
||||||
|
from bot import ChristmasBot
|
||||||
from discord.ext.commands import Context
|
from discord.ext.commands import Context
|
||||||
|
|
||||||
from bot import ChristmasBot
|
from bot import ChristmasBot
|
||||||
@@ -7,13 +11,11 @@ from utils.database import AutoJoin
|
|||||||
from utils.EmbedGenerator import EmbedGenerator
|
from utils.EmbedGenerator import EmbedGenerator
|
||||||
|
|
||||||
|
|
||||||
class SettingsCog(commands.Cog, name="Settings"):
|
class SettingsCog(BaseCog, name="Settings"):
|
||||||
def __init__(self, bot: ChristmasBot):
|
|
||||||
self.bot = bot
|
|
||||||
|
|
||||||
@commands.group(aliases=["aj"], invoke_without_command=True)
|
@commands.group(aliases=["aj"], invoke_without_command=True)
|
||||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
||||||
async def autojoin(self, ctx: CustomContext):
|
async def autojoin(self, ctx: CustomContext):
|
||||||
|
"""Enable/Disable the bot automatically joining"""
|
||||||
await EmbedGenerator.Message(
|
await EmbedGenerator.Message(
|
||||||
ctx,
|
ctx,
|
||||||
"Autojoin",
|
"Autojoin",
|
||||||
@@ -24,16 +26,19 @@ class SettingsCog(commands.Cog, name="Settings"):
|
|||||||
@commands.has_permissions(manage_channels=True)
|
@commands.has_permissions(manage_channels=True)
|
||||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
||||||
async def autojoin_set(self, ctx: CustomContext):
|
async def autojoin_set(self, ctx: CustomContext):
|
||||||
|
"""Enable the bot automatically joining"""
|
||||||
voicechannel_id = ctx.author.voice.channel.id
|
voicechannel_id = ctx.author.voice.channel.id
|
||||||
textchannel_id = ctx.message.channel.id
|
textchannel_id = ctx.message.channel.id
|
||||||
await AutoJoin.update_channel(ctx.get_redis(), ctx.guild.id, voicechannel_id, textchannel_id)
|
await AutoJoin.update_channel(
|
||||||
|
ctx.get_redis(), ctx.guild.id, voicechannel_id, textchannel_id
|
||||||
|
)
|
||||||
await EmbedGenerator.Message(ctx, "Autojoin", "`enabled`")
|
await EmbedGenerator.Message(ctx, "Autojoin", "`enabled`")
|
||||||
|
|
||||||
@autojoin.command(name="disable")
|
@autojoin.command(name="disable")
|
||||||
@commands.has_permissions(manage_channels=True)
|
@commands.has_permissions(manage_channels=True)
|
||||||
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
@commands.cooldown(rate=1, per=5, type=commands.BucketType.user)
|
||||||
async def autojoin_del(self, ctx: CustomContext):
|
async def autojoin_del(self, ctx: CustomContext):
|
||||||
vc = ctx.author.voice.channel
|
"""Disable the bot automatically joining"""
|
||||||
await AutoJoin.del_channel(ctx.get_redis(), ctx.guild.id)
|
await AutoJoin.del_channel(ctx.get_redis(), ctx.guild.id)
|
||||||
await EmbedGenerator.Message(ctx, "Autojoin", "`disabled`")
|
await EmbedGenerator.Message(ctx, "Autojoin", "`disabled`")
|
||||||
|
|
||||||
|
|||||||
@@ -21,4 +21,5 @@
|
|||||||
"cogs": ["cogs.owner", "cogs.settings", "cogs.information", "cogs.music"],
|
"cogs": ["cogs.owner", "cogs.settings", "cogs.information", "cogs.music"],
|
||||||
"slash_command_guilds": [],
|
"slash_command_guilds": [],
|
||||||
"queue_buffer_size": 5,
|
"queue_buffer_size": 5,
|
||||||
|
"slash_descriptions": {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
from typing import Dict
|
||||||
|
from discord.ext.commands import Cog
|
||||||
|
from bot import ChristmasBot
|
||||||
|
|
||||||
|
|
||||||
|
class BaseCog(Cog):
|
||||||
|
def __init__(self, bot: ChristmasBot) -> None:
|
||||||
|
self.bot = bot
|
||||||
|
|
||||||
|
slash_descriptions: Dict[str, str] = self.bot.config["slash_descriptions"]
|
||||||
|
for command in self.walk_commands():
|
||||||
|
if brief := slash_descriptions.get(command.qualified_name):
|
||||||
|
command.brief = brief
|
||||||
Reference in New Issue
Block a user