Hi I'm getting an error and I'm trying to figure out what maybe causing the issue.
The error I'm getting is SyntaxError: invalid syntax (<fstring>, line 1)
However, looking at line 1 of my code I don't see any issue.
Here is what I'm working with.
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))
If anyone could help me where I'm going wrong here. It would be appreciated.