Browse Source

Update message_embeds.md

pull/56/head
Jari (LotU) 8 years ago
committed by GitHub
parent
commit
16257d6f48
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      docs/bot_tutorial/message_embeds.md

21
docs/bot_tutorial/message_embeds.md

@ -1,22 +1,21 @@
# Message Embeds
A [Message Embed](https://b1naryth1ef.github.io/disco/api/disco_types_message.html#messageembed) represents a Discord Embed object. An Embed object is used to display certain data, in a more layed out and pretty way than regular Discord messages.
A [Message Embed](https://b1naryth1ef.github.io/disco/api/disco_types_message.html#messageembed) represents a Discord Embed object. An Embed object is another component of Discord messages that can be used to present data with special formatting and structure.
An example of a message embed:
![alt text](https://i.stack.imgur.com/HRWHk.png "A discord embed")
![A discord embed](https://i.stack.imgur.com/HRWHk.png "A discord embed")
An embed can contain the following buildstones:
An embed can contain the following components:
* Author, including link and avatar
* Title
* Description
* Field(s)
* Thumbnail image
* Image
* Footer text
* Footer icon
* Footer, including text and icon
* Timestamp
Next to these, you can set the embeds color, which will set the color of the left sidebar of the embed.
* Color (sets the color of the left sidebar of the embed)
## Creating an embed
Creating an embed is simple, and can be done like this:
@ -40,21 +39,21 @@ embed.add_field(name='Inline field 3', value='Third value for the third field',
embed.add_field(name='A non-inline field', value='You can only have a max of 3 inline field on 1 line', inline=False)
embed.description = 'This is the general description of the embed, you can use the Discord supported MD in here too, to make it look extra fancy. For example, creating some **bold** or ~~strikethrough~~ text.'
```
Last up, let's set a footer, color and add a timestamp
Last up, let's set a footer, color and add a timestamp:
```py
embed.timestamp = datetime.utcnow().isoformat()
embed.set_footer(text='Disco Message Embeds tutorial')
embed.color = '10038562' #This can be any color, but I chose a nice dark red tint
```
Once your embed is finshed, you can send it using the `channels_messages_create()` message or the `event.msg.reply()` function in a command like this:
with `channels_messages_create()`:
Once your embed is finshed, you can send it using the `channel.send_message()` message or the `event.msg.reply()` function.
With `channel.send_message()`:
```py
self.bot.client.api.channels_messages_create(<ChannelID>, '<optional text>', embed=embed)
self.bot.state.channels.get(<ChannelID>).send_message('[optional text]', embed=embed)
```
with the `event.msg.reply()` function:
```py
event.msg.reply('<optional text>', embed=embed)
event.msg.reply('[optional text]', embed=embed)
```
The final embed we created in this tutorial would look like this:

Loading…
Cancel
Save