Home>

I wanted to write a bot for the music discord, but there are problems.

I also downloaded the ffmpeg. As I understand it, there will be no audio playback without it ... Help the teapot, I can attach the source code. As I understand it, on the second screen, the python does not see the class, although I declared it

UPD: attached the source code

ytdl= youtube_dl.YoutubeDL(ytdl_format_options)
class YTDLSource(discord.PCMVolumeTransformer):
    def __init__(self, source, *, data, volume=0.5):
        super().__init__(source, volume)
        self.data= data
        self.title= data.get('title')
        self.url= ""
@classmethod
async def from_url(cls, url, *, loop=None, stream=False):
    loop= loop or asyncio.get_event_loop()
    data= await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))
    if 'entries' in data:
        data= data['entries'][0]
        filename= data['title'] if stream else ytdl.prepare_filename(data)
        return filename
@commands.command()
async def play(self, ctx, url):
    try:
        server= ctx.message.guild
        voice_channel= server.voice_client
        async with ctx.typing():
            filename= await YTDLSource.from_url(url, loop=bot.loop)
            voice_channel.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=filename))
        await ctx.send('**Now playing:** {}'.format(filename))
    except:
        await ctx.send("not working, call admin")

Could you provide your code not as a screenshot, but as text? This will make it easier and more convenient for others to understand the issue and help you.

4500zenja2022-01-31 01:03:13

did as you asked

fiz_i_k2022-01-31 01:03:13