fstring的问题-SyntaxError:语法无效(<fstring>,第1行)

时间:2019-10-17 18:24:49

标签: python discord discord.py discord.py-rewrite

嗨,我收到一个错误消息,并试图找出可能导致此问题的原因。 我遇到的错误是SyntaxError: invalid syntax (<fstring>, line 1)但是,在我的代码的第1行中,我看不到任何问题。

这就是我正在使用的东西。

from discord.ext import commands
import discord
import youtube_dl
import asyncio
from random import randint

songs = asyncio.Queue()
playnext = asyncio.Event()
queues = {}

def embedgenerator(bot, desc, title = None):
    embed = discord.Embed(description=desc, color=randint(0, 0xffffff))
    if title:
        embed.title = title
    embed.set_footer(icon_url=bot.user.avatar_url, text=f"{bot.user.name} 
music module")
return embed

class Music(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

@commands.command(
    name='play',
    description='Plays a music.',
    usage='<url>'
)
@commands.guild_only()
async def play_command(self, ctx, *,  url = None):
    if url:
        with youtube_dl.YoutubeDL() as ytdl:
            info = ytdl.extract_info(f"ytsearch:{url}", download=False)
            a = info['entries']
            b = a[0]['formats'][3]['url']
        if not ctx.guild.voice_client:
            vclient = await ctx.author.voice.channel.connect()
        else:
            vclient = ctx.guild.voice_client
        source = discord.FFmpegPCMAudio(b, before_options=" -reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5")
        vclient.play(source)
        await ctx.send(embed=embedgenerator(self.bot, f"Playing **{info['entries'][0]['title']}**"))
        return

@commands.command(
    name='pause'
)
@commands.guild_only()
async def pause_command(self, ctx):
    client = ctx.guild.voice_client
    client.pause()
    await ctx.send(f'Paused. Type {await self.bot.get_prefix(ctx.message)}resume to resume.')
    return

@commands.command(
    name='resume'
)
@commands.guild_only()
async def resume_command(self, ctx):
    client = ctx.guild.voice_client
    client.resume()
    await ctx.send('Resumed.')
    return

@commands.command(
    name='stop'
)
async def stop_command(self, ctx):
    client = ctx.guild.voice_client
    await client.disconnect()
    return

def setup(bot):
    bot.add_cog(Music(bot))

如果有人可以帮助我,我在哪里出问题了。将不胜感激。

0 个答案:

没有答案