Nostrum.Struct.Guild.Role (nostrum v0.11.0-dev)

View Source

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.Message.create(184046599834435585, "#{role}")
%Nostrum.Struct.Message{}

role = %Nostrum.Struct.Guild.Role{id: 431884023535632398}
Nostrum.Api.Message.create(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

color()

@type color() :: integer()

The hexadecimal color code

hoist()

@type hoist() :: boolean()

Whether the role is pinned in the user listing

icon()

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

The hash of the role icon

id()

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

The id of the role

managed()

@type managed() :: boolean()

Whether the role is managed by an integration

mentionable()

@type mentionable() :: boolean()

Whether the role is mentionable

name()

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

The name of the role

permissions()

@type permissions() :: integer()

The permission bit set

position()

@type position() :: integer()

The position of the role

t()

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

unicode_emoji()

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

The standard unicode character emoji icon for the role

Functions

mention(role)

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