2025-01-18 21:45:25 -05:00
|
|
|
import discord
|
|
|
|
from discord import app_commands
|
2025-01-19 23:19:16 -05:00
|
|
|
from audio import play_audio, stop_audio, set_volume, join_voice, leave_voice, pause_audio, resume_audio, generate_recommendations
|
2025-01-18 21:45:25 -05:00
|
|
|
|
|
|
|
|
2025-01-19 22:29:16 -05:00
|
|
|
async def setup_commands(client, guild_id=None):
|
|
|
|
@client.tree.command(name="join", description="Join the user's current voice channel.")
|
2025-01-18 21:45:25 -05:00
|
|
|
async def join(interaction: discord.Interaction):
|
|
|
|
await join_voice(interaction)
|
|
|
|
|
2025-01-19 22:29:16 -05:00
|
|
|
@client.tree.command(name="leave", description="Leave the current voice channel.")
|
2025-01-18 21:45:25 -05:00
|
|
|
async def leave(interaction: discord.Interaction):
|
|
|
|
await leave_voice(interaction)
|
|
|
|
|
2025-01-19 22:29:16 -05:00
|
|
|
@client.tree.command(name="play", description="Play a song by title or artist.")
|
2025-01-18 21:45:25 -05:00
|
|
|
async def play(interaction: discord.Interaction, query: str):
|
|
|
|
await play_audio(interaction, query)
|
|
|
|
|
2025-01-19 22:29:16 -05:00
|
|
|
@client.tree.command(name="stop", description="Stop playback and clear the queue.")
|
|
|
|
async def stop(interaction: discord.Interaction):
|
|
|
|
await stop_audio(interaction)
|
|
|
|
|
2025-01-19 23:19:16 -05:00
|
|
|
@client.tree.command(name="pause", description="Pause the current song.")
|
|
|
|
async def pause(interaction: discord.Interaction):
|
|
|
|
await pause_audio(interaction)
|
|
|
|
|
|
|
|
@client.tree.command(name="resume", description="Resume the paused song.")
|
|
|
|
async def resume(interaction: discord.Interaction):
|
|
|
|
await resume_audio(interaction)
|
|
|
|
|
|
|
|
|
2025-01-19 22:29:16 -05:00
|
|
|
@client.tree.command(name="volume", description="Set playback volume.")
|
|
|
|
async def volume(interaction: discord.Interaction, level: int):
|
|
|
|
await set_volume(interaction, level)
|
|
|
|
|
2025-01-19 23:19:16 -05:00
|
|
|
@client.tree.command(name="recommend", description="Get song recommendations based on your listening history.")
|
|
|
|
async def recommend(interaction: discord.Interaction):
|
|
|
|
user_id = interaction.user.id
|
|
|
|
recommendations = generate_recommendations(user_id)
|
|
|
|
|
|
|
|
embed = discord.Embed(
|
|
|
|
title="🎵 Recommended Songs",
|
|
|
|
description="\n".join(recommendations),
|
|
|
|
color=discord.Color.green()
|
|
|
|
)
|
|
|
|
await interaction.response.send_message(embed=embed)
|
|
|
|
|
2025-01-18 21:45:25 -05:00
|
|
|
await client.tree.sync()
|