View Source Nostrum.Struct.Guild.Member (Nostrum v0.8.0)

Struct representing a Discord guild member.

A Nostrum.Struct.Guild.Member stores a Nostrum.Struct.User's properties pertaining to a specific Nostrum.Struct.Guild.

mentioning-members-in-messages

Mentioning Members in Messages

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

member = %Nostrum.Struct.Guild.Member{user_id: 120571255635181568}
Nostrum.Api.create_message!(184046599834435585, "#{member}")
%Nostrum.Struct.Message{content: "<@120571255635181568>"}

member = %Nostrum.Struct.Guild.Member{user_id: 89918932789497856}
Nostrum.Api.create_message!(280085880452939778, "#{Nostrum.Struct.Guild.Member.mention(member)}")
%Nostrum.Struct.Message{content: "<@89918932789497856>"}

Link to this section Summary

Types

Current timeout status of the member.

Whether the member is deafened. If you dont request offline guild members this field will be nil for any members that come online.

Date the member joined the guild, as a unix timestamp. If you dont request offline guild members this field will be nil for any members that come online.

Whether the member is muted. If you dont request offline guild members this field will be nil for any members that come online.

The nickname of the member

Current guild booster status of the member.

A list of role ids

t()

The user ID.

Functions

Returns a member's permissions in a guild channel, based on its Nostrum.Struct.Overwrites.

Returns a member's guild permissions.

Formats a Nostrum.Struct.Guild.Member into a mention.

Return the topmost role of the given member on the given guild.

Link to this section Types

Link to this type

communication_disabled_until()

View Source
@type communication_disabled_until() :: DateTime.t() | nil

Current timeout status of the member.

If member is currently timed out this will be a DateTime.t/0 of the unmute time, it will be nil or a date in the past if the member is not currently timed out.

@type deaf() :: boolean() | nil

Whether the member is deafened. If you dont request offline guild members this field will be nil for any members that come online.

@type joined_at() :: pos_integer() | nil

Date the member joined the guild, as a unix timestamp. If you dont request offline guild members this field will be nil for any members that come online.

@type mute() :: boolean() | nil

Whether the member is muted. If you dont request offline guild members this field will be nil for any members that come online.

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

The nickname of the member

@type premium_since() :: DateTime.t() | nil

Current guild booster status of the member.

If member is currently boosting a guild this will be a DateTime.t/0 since the start of the boosting, it will be nil if the member is not currently boosting the guild.

@type roles() :: [Nostrum.Struct.Guild.Role.id()]

A list of role ids

@type t() :: %Nostrum.Struct.Guild.Member{
  communication_disabled_until: communication_disabled_until(),
  deaf: deaf(),
  joined_at: joined_at(),
  mute: mute(),
  nick: nick(),
  premium_since: premium_since(),
  roles: roles(),
  user_id: user_id()
}
@type user_id() :: Nostrum.Struct.User.id() | nil

The user ID.

This field can be nil if the Member struct came as a partial Member object included in a message received from a guild channel. To retrieve the user object, use Nostrum.Cache.UserCache.

Link to this section Functions

Link to this function

guild_channel_permissions(member, guild, channel_id)

View Source
@spec guild_channel_permissions(
  t(),
  Nostrum.Struct.Guild.t(),
  Nostrum.Struct.Channel.id()
) :: [
  Nostrum.Permission.t()
]

Returns a member's permissions in a guild channel, based on its Nostrum.Struct.Overwrites.

examples

Examples

guild = Nostrum.Cache.GuildCache.get!(279093381723062272)
member = Map.get(guild.members, 177888205536886784)
channel_id = 381889573426429952
Nostrum.Struct.Guild.Member.guild_channel_permissions(member, guild, channel_id)
#=> [:manage_messages]
Link to this function

guild_permissions(member, guild)

View Source
@spec guild_permissions(t(), Nostrum.Struct.Guild.t()) :: [Nostrum.Permission.t()]

Returns a member's guild permissions.

examples

Examples

guild = Nostrum.Cache.GuildCache.get!(279093381723062272)
member = Map.get(guild.members, 177888205536886784)
Nostrum.Struct.Guild.Member.guild_permissions(member, guild)
#=> [:administrator]
@spec mention(t()) :: String.t()

Formats a Nostrum.Struct.Guild.Member into a mention.

examples

Examples

iex> member = %Nostrum.Struct.Guild.Member{user_id: 177888205536886784}
...> Nostrum.Struct.Guild.Member.mention(member)
"<@177888205536886784>"
Link to this function

top_role(member, guild)

View Source (since 0.5.0)
@spec top_role(t(), Nostrum.Struct.Guild.t()) :: Nostrum.Struct.Guild.Role.t() | nil

Return the topmost role of the given member on the given guild.

The topmost role is determined via t:Nostrum.Struct.Guild.Role.position.

parameters

Parameters

  • member: The member whose top role to return.
  • guild: The guild which the member belongs to.

return-value

Return value

The topmost role of the member on the given guild, if the member has roles assigned. Otherwise, nil is returned.