Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
update play command
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import discord
|
| 2 |
from discord.ext import commands
|
|
|
|
| 3 |
import yt_dlp # Changed from youtube_dl
|
| 4 |
import asyncio
|
| 5 |
import gradio as gr
|
|
@@ -72,17 +73,24 @@ music_bot = MusicBot()
|
|
| 72 |
@bot.event
|
| 73 |
async def on_ready():
|
| 74 |
print(f'Bot is ready! Logged in as {bot.user}')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
@bot.command()
|
| 77 |
-
async def play(
|
|
|
|
|
|
|
| 78 |
await music_bot.join_voice(ctx)
|
| 79 |
music_bot.queue.append(url)
|
| 80 |
|
| 81 |
if not music_bot.is_playing:
|
| 82 |
await music_bot.play_next(ctx)
|
| 83 |
-
await
|
| 84 |
else:
|
| 85 |
-
await
|
| 86 |
|
| 87 |
@bot.command()
|
| 88 |
async def skip(ctx):
|
|
|
|
| 1 |
import discord
|
| 2 |
from discord.ext import commands
|
| 3 |
+
from discord import app_commands
|
| 4 |
import yt_dlp # Changed from youtube_dl
|
| 5 |
import asyncio
|
| 6 |
import gradio as gr
|
|
|
|
| 73 |
@bot.event
|
| 74 |
async def on_ready():
|
| 75 |
print(f'Bot is ready! Logged in as {bot.user}')
|
| 76 |
+
try:
|
| 77 |
+
synced = await bot.tree.sync()
|
| 78 |
+
print(f"Synced {len(synced)} command(s)")
|
| 79 |
+
except Exception as e:
|
| 80 |
+
print(e)
|
| 81 |
|
| 82 |
+
@bot.tree.command(name="play", description="Play a song from URL")
|
| 83 |
+
async def play(interaction: discord.Interaction, url: str):
|
| 84 |
+
await interaction.response.defer()
|
| 85 |
+
ctx = await commands.Context.from_interaction(interaction)
|
| 86 |
await music_bot.join_voice(ctx)
|
| 87 |
music_bot.queue.append(url)
|
| 88 |
|
| 89 |
if not music_bot.is_playing:
|
| 90 |
await music_bot.play_next(ctx)
|
| 91 |
+
await interaction.followup.send('Playing music!')
|
| 92 |
else:
|
| 93 |
+
await interaction.followup.send('Added to queue!')
|
| 94 |
|
| 95 |
@bot.command()
|
| 96 |
async def skip(ctx):
|