Делаю музыкального бота на disnake.py на slash командах.
Бот присоединяется, но не играет музыку.
Ошибка - "Error occured: 'ApplicationCommandInteraction' object has no attribute 'typing'"
@bot.slash_command()
async def play(inter, *, url:str):
global song_queue
voice = disnake.utils.get(bot.voice_clients, guild=inter.guild)
try :
if(voice == None):
if not inter.author.voice:
await inter.response.send_message(f"{inter.author.name} is not connected to a voice channel")
else:
channel = inter.author.voice.channel
await channel.connect()
async with inter.typing():
voice_client = inter.guild.voice_client
if not voice_client.is_playing():
song_queue.clear()
player = await YTDLSource.from_url(url, loop=bot.loop, stream=True)
if len(song_queue) == 0:
await start_playing(inter, player)
else:
song_queue.append(player)
await inter.response.send_message(f"**Queued at position {len(song_queue)-1}:** {player.title}")
except Exception as e:
await inter.response.send_message(f"Error occured: {e}")
async def start_playing(inter, player):
global song_queue
song_queue.append(player)
global tasker
if(song_queue[0] == None):
return
i = 0
while i < len(song_queue):
try:
inter.voice_client.play(song_queue[0], after=lambda e: print('Player error: %s' % e) if e else None)
await inter.response.send_message(f"**Now playing:** {song_queue[0].title}")
except Exception as e:
await inter.response.send_message(f"Something went wrong: {e}")
#await asyncio.sleep(song_queue[0].duration)
tasker = asyncio.create_task(coro(inter,song_queue[0].duration))
try:
await tasker
except asyncio.CancelledError:
print("Task cancelled")
if(len(song_queue) > 0):
song_queue.pop(0)