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

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{}

Summary

Types

The hexadecimal color code

Whether the role is pinned in the user listing

The hash of the role icon

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()

The standard unicode character emoji icon for the role

Functions

Formats an Nostrum.Struct.Role into a mention.

Types

@type color() :: integer()

The hexadecimal color code

@type hoist() :: boolean()

Whether the role is pinned in the user listing

@type icon() :: String.t() | nil

The hash of the role icon

@type id() :: Nostrum.Snowflake.t()

The id of the role

@type managed() :: boolean()

Whether the role is managed by an integration

@type mentionable() :: boolean()

Whether the role is mentionable

@type name() :: String.t()

The name of the role

@type permissions() :: integer()

The permission bit set

@type position() :: integer()

The position of the role

@type t() :: %Nostrum.Struct.Guild.Role{
  color: color(),
  hoist: hoist(),
  icon: icon(),
  id: id(),
  managed: managed(),
  mentionable: mentionable(),
  name: name(),
  permissions: permissions(),
  position: position(),
  unicode_emoji: unicode_emoji()
}
Link to this type

unicode_emoji()

View Source (since 0.7.0)
@type unicode_emoji() :: String.t() | nil

The standard unicode character emoji icon for the role

Functions

@spec 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>"