I had made a discord bot a while back for a purpose involving message embeds that my friends and I needed. Long story short the bot went offline for like a year because the host (a raspberry pi) died. Fast forwarding today, we needed it again so I tried it firing it up, but noticed that most of my code doesn't work anymore, because the async branch of discord.py has been updated to v1.0 which brings major changes and requiers migration in code to comply with the new library. Looking at the documentation, I was able to figure everything out, except the embed part of my bot. Which is the most important.
This is the code I will focus on, there is more after, but it's irrelevant to this part, because if I can sucessfully store the values I am aiming for in the string, then the rest should work.
async def on_message(message):
serverid = message.guild.id
channel = message.channel
messagecontent = message.content
if message.embeds:
try:
charaname = message.embeds[0]['author']['name']
charaseries = message.embeds[0]['description']
except AttributeError:
return
What I am basically trying to do, is if a message has an embed, then I need to store the name and description values in seperate strings, for later on use in the code. But I get this trying to do so:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\discord\client.py", line 270, in _run_event
await coro(*args, **kwargs)
File "C:\path_to_script", line 35, in on_message
charaseries = message.embeds[0]['description']
TypeError: 'Embed' object is not subscriptable
Some research showed to me that 'subscriptable' means when an object can contain multiple other objects, such as lists. It's explained here better. If it's not subscriptable, then I am guessing the new library has a whole new way of handling this, which I cannot seem to figure out. So I need help understanding what exactly is going on here, so I can adapt my code and get this part working again.
Help is appreciated alot, thank you!