Answer the question
In order to leave comments, you need to log in
Why is UnboundLocalError: local variable 'embed' referenced before assignment?
I wrote this code:
UnboundLocalError: local variable 'embed' referenced before assignment?
@bot.event
async def on_message(message):
await bot.process_commands( message )
splited = message.content.split(' ')
if message.author.bot is False:
if f'<@!822563111571423254>' in splited[0]:
try:
if splited[1] is None:
pass
else:
pass
except:
embed = discord.Embed(title = f'Welcome!', timestamp = message.created_at, colour = discord.Colour.from_rgb(199, 182, 219), description = f'''
Hi {message.author.display_name}, my name **Osidium**!
• My prefix - `o+`
• Write the command 'o+help' to find out all my features.
• Want to know a little about me? Write `o-about`.
• Need help on the bot, or found a bug/error? Visit our server: [Join](https://discord.gg/tYr5xeSS79)''')
await message.reply(embed=embed)
Answer the question
In order to leave comments, you need to log in
Read about scopes. The embed variable may not be declared at the time of use.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question