-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcogs.py
29 lines (25 loc) · 970 Bytes
/
cogs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from nextcord import Interaction
from nextcord.ext import commands
import nextcord
import calculator
import time
class SlashCommands(commands.Cog):
def __init__(self, bot):
self.bot = bot
@nextcord.slash_command(force_global=True)
async def ariana(self, interaction: Interaction, message: str):
try:
vc: nextcord.VoiceClient = await interaction.user.voice.channel.connect()
except nextcord.errors.ClientException:
await interaction.response.send_message('bot is busy, try later')
return
except AttributeError:
await interaction.response.send_message('you need to join a voice channel')
return
await interaction.response.send_message(message)
url = calculator.sound_url_by_message(message)
source = nextcord.FFmpegPCMAudio(url)
vc.play(source)
while vc.is_playing():
time.sleep(1)
await vc.disconnect()