View Source Nostrum.Struct.Guild.Member (Nostrum v0.10.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
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
The user ID.
Functions
Returns a guild-specific avatar URL for a Nostrum.Struct.Guild.Member
.
Returns a member's permissions in a guild channel, based on its Nostrum.Struct.Overwrite
s.
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
@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.
@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
@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 roles() :: [Nostrum.Struct.Guild.Role.id()]
A list of role ids
@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
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"
@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.Overwrite
s.
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]
@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]
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>"
@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.