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

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

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

Summary

Types

Avatar hash of the custom avatar set by the user in the guild.

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.

Guild member flags represented as a bitset.

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 member gate status. false if user has yet to pass the membership screening configuration for the guild, true if the member has passed.

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.

Types

Link to this type

avatar()

View Source (since 0.9.1)
@type avatar() :: String.t() | nil

Avatar hash of the custom avatar set by the user in the guild.

If animated, this is prefixed with a_.

You can use avatar_url/3 to fetch a full-formed URL of this asset.

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 flags() :: pos_integer() | nil

Guild member flags represented as a bitset.

Look at the Nostrum.Struct.Guild.Member.Flags module for guidance parsing this value.

@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

Link to this type

pending()

View Source (since 0.9.1)
@type pending() :: boolean() | nil

Current guild member gate status. false if user has yet to pass the membership screening configuration for the guild, true if the member has passed.

@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{
  avatar: avatar(),
  communication_disabled_until: communication_disabled_until(),
  deaf: deaf(),
  flags: flags(),
  joined_at: joined_at(),
  mute: mute(),
  nick: nick(),
  pending: pending(),
  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.

Functions

Link to this function

avatar_url(member, guild_id, image_format \\ "png")

View Source (since 0.9.1)

Returns a guild-specific avatar URL for a Nostrum.Struct.Guild.Member.

Supported formats are png (default), jpg, webp and gif.

As mentioned in the avatar hash typedoc, if the avatar hash begins with a_, the avatar is animated and can be returned as a gif.

Examples

iex> member = %Nostrum.Struct.Guild.Member{
...>   user_id: 165023948638126080,
...>   avatar: "4c8319db8ea745275a1399f8f8aa74ab"
...> }
iex> guild_id = 1226944827137069107
iex> Nostrum.Struct.Guild.Member.avatar_url(member, guild_id)
"https://cdn.discordapp.com/guilds/1226944827137069107/users/165023948638126080/avatars/4c8319db8ea745275a1399f8f8aa74ab.png"
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

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

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

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

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

Return value

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