Embed¶
Extends: None
Wrapper for an Embed on Discord
Description¶
Contains all the data of an embed. It also has a few chainable methods to make creating embeds easy
Properties¶
| Type | Name | Description |
|---|---|---|
| String | title | The title of the Embed |
| String | type | The type of the Embed (default is rich) (See Discord Embed Types) |
| String | description | The description of the Embed |
| String | url | The url of the Embed |
| String | timestamp | The ISO8601 timestamp of the Embed (or null) |
| int | color | The color code of the Embed |
| Dictionary | footer | Footer information |
| Dictionary | image | Image information |
| Dictionary | thumbnail | Thumbnail information |
| Dictionary | video | Video information |
| Dictionary | provider | Provider information |
| Dictionary | author | Author information |
| Array | fields | The fields of the embed |
footer: Dictionary (See Discord Embed Footer Structure)
{
text: String, text of the footer,
icon_url?: String, url of footer icon,
proxy_url?: String, proxied url of footer icon
}
image: Dictionary (See Discord Embed Image Structure)
{
url?: String, source url of image,
proxy_url?: String, proxied url of image,
height?: int, height of image,
width?: int, width of image
}
thumbnail: Dictionary (See Discord Embed Thumbnail Structure)
{
url?: String, source url of thumbnail,
proxy_url?: String, proxied url of thumbnail,
height?: int, height of thumbnail,
width?: int, width of thumbnail
}
video: Dictionary (See Discord Embed Video Structure)
{
url?: String, source url of video,
proxy_url?: String, proxied url of video,
height?: int, height of video,
width?: int, width of video
}
provider: Dictionary (See Discord Embed Provider Structure)
{
name?: String, name of provider
url?: String, url of provider,
}
author: Dictionary (See Discord Embed Author Structure)
{
name?: String, name of author,
url?: String, url of author,
icon_url?: String, url of author icon,
proxy_url?: String, proxied url of author icon
}
Each field: Dictionary (See Discord Embed Field Structure)
{
name: String, name of the field,
value: String, value of the field,
inline?: bool, whether or not this field should display inline
}
Methods¶
Note
Getters are also defined for the above functions which all return Dictionary
Note
All setter methods and add_fields() return the Embed itself, so chaining of methods is possible
Method Descriptions¶
set_title(title)¶
Sets the title of the Embed
Returns: Embed
| Type | Parameter |
|---|---|
| String | title |
set_type(type)¶
Sets the type of the Embed
Returns: Embed
| Type | Parameter |
|---|---|
| String | type |
set_description(description)¶
Sets the description of the Embed
Returns: Embed
| Type | Parameter |
|---|---|
| String | description |
set_url(url)¶
Sets the url of the Embed
Returns: Embed
| Type | Parameter |
|---|---|
| String | url |
set_timestamp()¶
Sets the timestamp of the Embed to the current unix timestamp
Returns: Embed
Examples¶
Set the timestamp of an embed to the current ISO8601 timestamp
var embed = Embed.new().set_timestamp()
set_color(color)¶
Sets the color of the Embed
Returns: Embed
| Type | Parameter | Description |
|---|---|---|
| Array | String | int | color | Supports RGB array, HEX string or decimal representation |
Examples¶
An rgb color
var embed = Embed().new().set_color([255, 0, 255])
A hex color
var embed = Embed().new().set_color("#ff55ff")
A decimal color
var embed = Embed().new().set_color(16711935)
set_footer(text, icon_url?, proxy_icon_url?)¶
Sets the footer of the Embed
Returns: Embed
| Type | Parameter | Description |
|---|---|---|
| String | text | The text of the footer |
| String | icon_url | The url of footer icon |
| String | proxy_icon_url | The proxied url of footer icon |
set_image(url, width?, height?, proxy_url?)¶
Sets the image of the Embed
Returns: Embed
| Type | Parameter | Description |
|---|---|---|
| String | url | The url of embed image |
| int | width | The width of embed image |
| int | height | The height url of embed image |
| String | proxy_url | The proxied url of embed image |
set_thumbnail(url, width?, height?, proxy_url?)¶
Sets the thumbnail of the Embed
Returns: Embed
Type Parameter Description String url The url of embed thumbnail int width The width of embed thumbnail int height The height url of embed thumbnail String proxy_url The proxied url of embed thumbnail
set_video(url, width?, height?, proxy_url?)¶
Sets the video of the Embed
Returns: Embed
| Type | Parameter | Description |
|---|---|---|
| String | url | The url of embed video |
| int | width | The width of embed video |
| int | height | The height url of embed video |
| String | proxy_url | The proxied url of embed video |
set_provider(name, url?)¶
Sets the provider of the Embed
Returns: Embed
| Type | Parameter | Description |
|---|---|---|
| String | name | The name of embed provider |
| String | url | The url of embed provider |
set_author(name, url?, icon_url?, proxy_icon_url?)¶
Sets the author of the Embed
Returns: Embed
| Type | Parameter | Description |
|---|---|---|
| String | name | The name of embed author |
| String | url | The url of embed author |
| String | icon_url | The url of author icon |
| String | proxy_icon_url | The proxied url of author icon |
Examples¶
Set the author of an Embed
var embed = Embed.new().set_author("Delano Lourenco", "https://url_to_image_file.png")
add_field(name, value, inline?)¶
Sets the field of the Embed
Returns: Embed
Note
An Embed can have a max of 25 fields
| Type | Parameter | Description |
|---|---|---|
| String | name | The name of the embed field |
| String | value | The value of the embed field |
| bool | inline | Whether or not this field should display inline |
Examples¶
Add multiple fields to an Embed
# Make the embed
var embed = Embed.new()
embed.add_field("field 1", "text 1")
embed.add_field("field 2", "text 2")
embed.add_field("field 3", "inline text 1", true) # inline
embed.add_field("field 4", "inline text 1", true) # inline
# Send the embed
bot.send(message, {"embeds": [embed]})
slice_fields(index, delete_count?, replace_fields?)¶
Removes, replaces, and inserts fields in the Embed.
Returns: Embed
| Type | Parameter | Defaults | Description |
|---|---|---|---|
| int | index | Required | The index of the first field in the Embeds.fields to be removed |
| int | delete_count | 1 | The number of fields to remove |
| Array | replace_fields | [] | The replacing fields, an array of Dictionary(field) |
Dictionary(field): Dictionary
{
name: String, name of the field,
value: String, value of the field,
inline?: bool, whether or not this field should display inline
}
print()¶
Prints the Embed
Returns: void
Note
To print an Embed, use Embed.print() instead of print(Embed)