Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.7k stars 3.74k forks source link

How can I get the text from an embed's description? #1764

Closed CompuGenius-Programs closed 5 years ago

CompuGenius-Programs commented 5 years ago

Hi @Rapptz! I have this bot that assigns a mentioned user a certain role. I would like it that the bot doesn't only give the role to users mentioned in regular text, but in embeds as well. For example, let's say another bot mentions a user in a embed as a promotion. I want this bot to get the text from the embed, and use it the same way as if it got the text from a normal user's message. Thanks in advance! My bot: https://github.com/CompuGenius-Programs/moderator-for-a-day/blob/master/addroles.py

Harmon758 commented 5 years ago

https://discordpy.readthedocs.io/en/latest/api.html#discord.Message.embeds https://discordpy.readthedocs.io/en/latest/api.html#discord.Embed.description

For future questions like this, you should join either the official discord.py server or the Discord API server for help, as the README recommends.

CompuGenius-Programs commented 5 years ago

@Harmon758 thanks for replying so quickly! These references are for getting the description, and not for merely creating them? Sure I'll join the server!

Harmon758 commented 5 years ago

You can create Embed objects to send, as well as get their dictionary form from Message objects by using Message.embeds.

CompuGenius-Programs commented 5 years ago

@Harmon758 how do I get there description? What does message.embeds print out? A list?

EvieePy commented 5 years ago

If you read the documentation, you would know.

I also just saw you on the Discord.py server. That's where these sorts of questions belong.

CompuGenius-Programs commented 5 years ago

I know I was on the server, but they told me to check what you responded.

CompuGenius-Programs commented 5 years ago

@Harmon758 in sorry man, but I'm still confused! Can you please send me sample code that will repost what the descriptions of the embed is? I'm really sorry that in driving you nuts!

Harmon758 commented 5 years ago

As the documentation I linked to says, Message.embeds returns a list of embedded objects. These are dictionaries with the data from the Embeds. You can access the dictionary to get the description.

On the rewrite branch, Message.embeds will give you a list of Embed objects, with which you can get the description using the Embed.description attribute.

For further help, you should inquire on Discord. However, asking for code for what you want, instead of learning to write it yourself, is generally frowned upon.

CompuGenius-Programs commented 5 years ago

Thanks so much!!!!!!!

lgaan commented 5 years ago

You probably shouldn’t reopen older issues, also for help with the library join the support server (link is in the README)