Removed cog commands from music cog

This commit is contained in:
2022-11-12 19:59:59 +01:00
parent 833bb61660
commit de31c6b273
+3 -82
View File
@@ -1,24 +1,19 @@
import typing
from cogs.music.commands import MusicCommands
import asyncio import asyncio
import typing
from typing import Optional from typing import Optional
import lavalink import lavalink
from discord import Embed
from discord.channel import TextChannel from discord.channel import TextChannel
from discord.ext import commands from discord.ext import commands
from discord.ext.commands.errors import CommandError from discord.ext.commands.errors import CommandError
from lavalink.models import AudioTrack
from lavalink.models import DefaultPlayer from lavalink.models import DefaultPlayer
from cogs.music import helper
from bot import TuneBot from bot import TuneBot
from cogs.music import helper
from cogs.music.commands import MusicCommands
from cogs.music.voice_client import LavalinkVoiceClient from cogs.music.voice_client import LavalinkVoiceClient
from utils.embed import create_embed
from utils.log import logger
from context import CustomContext from context import CustomContext
from utils.classes import BaseCog from utils.classes import BaseCog
from utils.EmbedGenerator import EmbedGenerator
from utils.exceptions import EmbeddedCommandException from utils.exceptions import EmbeddedCommandException
@@ -116,80 +111,6 @@ class MusicCog(BaseCog):
elif isinstance(event, lavalink.events.TrackEndEvent): elif isinstance(event, lavalink.events.TrackEndEvent):
await self.fill_player_queue(event.player, 1) await self.fill_player_queue(event.player, 1)
@commands.command(name="connect", aliases=["p", "play", "join"])
async def play(self, ctx: CustomContext):
"""Start the radio"""
logger.info(f"Joining channel {ctx.channel}")
# Get the player for this guild from cache.
if ctx.player.is_connected:
await ctx.send("Already connected")
return
await self.fill_player_queue(
ctx.player, self.bot.config["queue_buffer_size"] + 1
)
if not ctx.player.is_playing:
await ctx.player.play()
await EmbedGenerator.Title(ctx, "*⃣ | Connected.")
return
@commands.command(name="skip", aliases=["next"])
async def skip(self, ctx: CustomContext):
"""Skip the current song"""
await ctx.player.skip()
await ctx.send("Skipped current song")
@commands.command(name="queue")
async def queue(self, ctx: CustomContext):
"""Display the current radio queue"""
embed_color = self.bot.colors["embed"]
embed = Embed(title="Coming Up...", colour=embed_color)
if len(ctx.player.queue) > 0:
embed.description = "\n".join(
f"{index}. [{track.title}]({track.uri})"
for index, track in enumerate(ctx.player.queue, 1)
)
else:
embed.description = "We are still determining a playlist"
await ctx.send(embed=embed)
@commands.command(name="disconnect", aliases=["dc", "stop"])
async def disconnect(self, ctx: CustomContext):
"""Disconnects the radio from the channel"""
if not ctx.author.voice or (
ctx.player.is_connected
and ctx.author.voice.channel.id != int(ctx.player.channel_id)
):
# Abuse prevention. Users not in voice channels, or not in the same voice channel as the bot
# may not disconnect the bot.
await EmbedGenerator.Title(ctx, "You're not in my voicechannel!")
return
# Clear the queue to ensure old tracks don't start playing
# when someone else queues something.
ctx.player.queue.clear()
# Stop the current track so Lavalink consumes less resources.
await ctx.player.stop()
# Disconnect from the voice channel.
await ctx.voice_client.disconnect(force=True)
await EmbedGenerator.Title(ctx, "*⃣ | Disconnected.")
@commands.command(name="now")
async def now_playing(self, ctx: CustomContext):
"""Displays information about the currently played track"""
if not ctx.player.current:
embed = create_embed(ctx.author)
embed.title = "You're not listening to anything right now."
await ctx.send(embed=embed)
return
embed = helper.create_track_embed(ctx.player.current)
await ctx.send(embed=embed)
async def setup(bot: "TuneBot"): async def setup(bot: "TuneBot"):
await bot.add_cog(MusicCog(bot)) await bot.add_cog(MusicCog(bot))