Nostrum v0.4.0 Nostrum.Struct.Embed View Source

Functions that work on Discord embeds.

Building Embeds

Nostrum.Struct.Embeds can be built using this module's builder functions or standard Map syntax:

iex> import Nostrum.Struct.Embed
...> embed =
...>   %Nostrum.Struct.Embed{}
...>   |> put_title("craig")
...>   |> put_description("nostrum")
...>   |> put_url("https://google.com/")
...>   |> put_timestamp("2016-05-05T21:04:13.203Z")
...>   |> put_color(431_948)
...>   |> put_field("Field 1", "Test")
...>   |> put_field("Field 2", "More test", true)
...> embed
%Nostrum.Struct.Embed{
  title: "craig",
  description: "nostrum",
  url: "https://google.com/",
  timestamp: "2016-05-05T21:04:13.203Z",
  color: 431_948,
  fields: [
    %Nostrum.Struct.Embed.Field{name: "Field 1", value: "Test"},
    %Nostrum.Struct.Embed.Field{name: "Field 2", value: "More test", inline: true}
  ]
}

Link to this section Summary

Types

Author information

Color code of the embed

Description of the embed

Fields information

Footer information

Image information

Provider information

t()

Thumbnail information

Timestamp of embed content

Title of the embed

Type of the embed

Url of the embed

Video information

Functions

Puts the given value under :color in embed.

Puts the given value under :description in embed.

Puts a Nostrum.Struct.Embed.Image under :image in embed.

Puts a Nostrum.Struct.Embed.Thumbnail under :thumbnail in embed.

Puts the given value under :timestamp in embed.

Puts the given value under :title in embed.

Puts the given value under :url in embed.

Link to this section Types

Author information

Color code of the embed

Link to this type

description() View Source
description() :: String.t() | nil

Description of the embed

Fields information

Footer information

Image information

Provider information

Link to this type

t() View Source
t() :: %Nostrum.Struct.Embed{
  author: author(),
  color: color(),
  description: description(),
  fields: fields(),
  footer: footer(),
  image: image(),
  provider: provider(),
  thumbnail: thumbnail(),
  timestamp: timestamp(),
  title: title(),
  type: type(),
  url: url(),
  video: video()
}

Thumbnail information

Link to this type

timestamp() View Source
timestamp() :: String.t() | nil

Timestamp of embed content

Link to this type

title() View Source
title() :: String.t() | nil

Title of the embed

Type of the embed

Url of the embed

Video information

Link to this section Functions

Puts a Nostrum.Struct.Embed.Author under :author in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_author(embed, "skippi", "https://github.com/skippi", nil)
%Nostrum.Struct.Embed{
  author: %Nostrum.Struct.Embed.Author{
    name: "skippi",
    url: "https://github.com/skippi",
    icon_url: nil
  }
}
Link to this function

put_color(embed, value) View Source
put_color(t(), color()) :: t()

Puts the given value under :color in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_color(embed, 431948)
%Nostrum.Struct.Embed{color: 431948}
Link to this function

put_description(embed, value) View Source
put_description(t(), description()) :: t()

Puts the given value under :description in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_description(embed, "An elixir library for the discord API.")
%Nostrum.Struct.Embed{description: "An elixir library for the discord API."}

Adds a Nostrum.Struct.Embed.Field under :fields in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_field(embed, "First User", "b1nzy")
%Nostrum.Struct.Embed{
  fields: [
    %Nostrum.Struct.Embed.Field{name: "First User", value: "b1nzy"}
  ]
}

iex> embed = %Nostrum.Struct.Embed{
...>   fields: [
...>     %Nostrum.Struct.Embed.Field{name: "First User", value: "b1nzy"}
...>   ]
...> }
...> Nostrum.Struct.Embed.put_field(embed, "Second User", "Danny")
%Nostrum.Struct.Embed{
  fields: [
    %Nostrum.Struct.Embed.Field{name: "First User", value: "b1nzy"},
    %Nostrum.Struct.Embed.Field{name: "Second User", value: "Danny"}
  ]
}
Link to this function

put_footer(embed, text, icon_url \\ nil) View Source

Puts a Nostrum.Struct.Embed.Footer under :footer in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_footer(embed, "Discord API", nil)
%Nostrum.Struct.Embed{
  footer: %Nostrum.Struct.Embed.Footer{
    text: "Discord API",
    icon_url: nil
  }
}

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_footer(embed, "nostrum footer", "https://discordapp.com/assets/53ef346458017da2062aca5c7955946b.svg")
%Nostrum.Struct.Embed{
  footer: %Nostrum.Struct.Embed.Footer{
    text: "nostrum footer",
    icon_url: "https://discordapp.com/assets/53ef346458017da2062aca5c7955946b.svg"
  }
}

Puts a Nostrum.Struct.Embed.Image under :image in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_image(embed, "https://discordapp.com/assets/af92e60c16b7019f34a467383b31490a.svg")
%Nostrum.Struct.Embed{
  image: %Nostrum.Struct.Embed.Image{
    url: "https://discordapp.com/assets/af92e60c16b7019f34a467383b31490a.svg"
  }
}
Link to this function

put_thumbnail(embed, url) View Source
put_thumbnail(t(), Nostrum.Struct.Embed.Thumbnail.url()) :: t()

Puts a Nostrum.Struct.Embed.Thumbnail under :thumbnail in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_thumbnail(embed, "https://discordapp.com/assets/af92e60c16b7019f34a467383b31490a.svg")
%Nostrum.Struct.Embed{
  thumbnail: %Nostrum.Struct.Embed.Thumbnail{
    url: "https://discordapp.com/assets/af92e60c16b7019f34a467383b31490a.svg"
  }
}
Link to this function

put_timestamp(embed, value) View Source
put_timestamp(t(), timestamp()) :: t()

Puts the given value under :timestamp in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_timestamp(embed, "2018-04-21T17:33:51.893000Z")
%Nostrum.Struct.Embed{timestamp: "2018-04-21T17:33:51.893000Z"}
Link to this function

put_title(embed, value) View Source
put_title(t(), title()) :: t()

Puts the given value under :title in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_title(embed, "nostrum")
%Nostrum.Struct.Embed{title: "nostrum"}
Link to this function

put_url(embed, value) View Source
put_url(t(), url()) :: t()

Puts the given value under :url in embed.

Examples

iex> embed = %Nostrum.Struct.Embed{}
...> Nostrum.Struct.Embed.put_url(embed, "https://github.com/Kraigie/nostrum")
%Nostrum.Struct.Embed{url: "https://github.com/Kraigie/nostrum"}