V
V
VangVang2021-11-25 23:08:05
Python
VangVang, 2021-11-25 23:08:05

Why is the discord bot not responding to commands?

import discord
from discord.ext import commands
import youtube_dl


class music(commands.Cog):
  def __init__(self, client):
    self.client = client

    @commands.command()
    async def join(self,ctx):
      if ctx.author.voice is None:
        await ctx.send("Вы не в голосовом канале.")
      voice_channel = ctx.author.voice.channel
      if ctx.voice_client is None:
        await voice_channel.connect()
      else:
        await ctx.voice_client.move_to(voice_channel)

    @commands.command()
    async def disconnect(self,ctx):
      await ctx.voice_client.disconnect()

    @commands.command()
    async def play(self,ctx,url):
      ctx.voice_client.stop()
      FFMPEG_OPTIONS = {'before_options': '-reconnect l -reconnect_stremed l -reconnect_delay_max 5', 'options': '-vn'}
      YDL_OPTIONS = {'format':"bestaudio"}
      vc = ctx.voice_client

      with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
        info = ydl.extract_info(url, download=False)
        url2 = info['formats'][0]['url']
        source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
        vc.play(source)

    @commands.command()
    async def pause(self,ctx):
      await ctx.voice_client.pause()
      await ctx.send("Пауза")

    @commands.command()
    async def resume(self,ctx):
      await ctx.voice_client.resume()
      await ctx.send("Продолжить")


def setup(client):
  client.add_cog(music(client))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
psaly2015, 2021-11-26
@VangVang

First, it would be worth pointing out that we are talking about kogi. To begin with, it is worth checking whether the cog is connected at all in the main code. Most likely this is the problem. If there were any errors in the syntax or the use of methods, you would get it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question