View Source Nostrum.Struct.Guild.Role (Nostrum v0.6.1)

Struct representing a Discord role.

Mentioning Roles in Messages

A Nostrum.Struct.Guild.Role can be mentioned in message content using the String.Chars protocol or mention/1.

role = %Nostrum.Struct.Guild.Role{id: 431886897539973131}
Nostrum.Api.create_message!(184046599834435585, "#{role}")
%Nostrum.Struct.Message{}

role = %Nostrum.Struct.Guild.Role{id: 431884023535632398}
Nostrum.Api.create_message!(280085880452939778, "#{Nostrum.Struct.Guild.Role.mention(role)}")
%Nostrum.Struct.Message{}

Link to this section Summary

Types

The hexadecimal color code

Whether the role is pinned in the user listing

The id of the role

Whether the role is managed by an integration

Whether the role is mentionable

The name of the role

The permission bit set

The position of the role

t()

Functions

Formats an Nostrum.Struct.Role into a mention.

Link to this section Types

Specs

color() :: integer()

The hexadecimal color code

Specs

hoist() :: boolean()

Whether the role is pinned in the user listing

Specs

The id of the role

Specs

managed() :: boolean()

Whether the role is managed by an integration

Specs

mentionable() :: boolean()

Whether the role is mentionable

Specs

name() :: String.t()

The name of the role

Specs

permissions() :: integer()

The permission bit set

Specs

position() :: integer()

The position of the role

Specs

t() :: %Nostrum.Struct.Guild.Role{
  color: color(),
  hoist: hoist(),
  id: id(),
  managed: managed(),
  mentionable: mentionable(),
  name: name(),
  permissions: permissions(),
  position: position()
}

Link to this section Functions

Specs

mention(t()) :: String.t()

Formats an Nostrum.Struct.Role into a mention.

Examples

iex> role = %Nostrum.Struct.Guild.Role{id: 431886639627763722}
...> Nostrum.Struct.Guild.Role.mention(role)
"<@&431886639627763722>"