Skip to content

GuildMember

GuildMember combines a User with guild-specific data: nickname, role assignments, permission bitfield, and per-guild avatar.

import { GuildMember } from "lunibee";
Property Type Description
user User The underlying Discord user.
guildId string Guild this member belongs to.
nickname string | null Server nickname, or null if not set.
roleIds string[] Array of assigned role snowflake IDs.
pending boolean Whether the member is pending membership screening.
joinedAt Date | undefined When the member joined the guild.
permissions PermissionsBitField The member’s permissions. From an interaction, Discord’s resolved value; anywhere else, computed at guild level from the cached roles each time it is read (empty when the guild’s roles are not cached).
avatarHash string | null Server-specific avatar hash.
premiumSince Date | null When they started boosting, or null.
timedOutUntil Date | null Timeout expiry, or null if not timed out.
flags number Member flags bitfield.
displayName string Nickname if set, otherwise user.displayName.
isTimedOut boolean true if currently timed out.

Returns the server-specific member avatar URL, falling back to the user’s avatar, or null.

const avatar = member.avatarURL({ size: 128 });

Always returns a URL — member avatar → user avatar → default avatar.

const avatar = member.displayAvatarURL({ size: 256 });

Returns the Discord user mention string (<@userId>).

Check permissions before acting

client.on("interactionCreate", async (interaction) => {
if (!interaction.isChatInputCommand() || interaction.commandName !== "purge") return;
const member = interaction.member;
if (!member?.permissions.has(Permission.manageMessages)) {
return interaction.reply({ content: "You need Manage Messages.", ephemeral: true });
}
// proceed with purge...
});

Member info command

client.on("interactionCreate", async (interaction) => {
if (!interaction.isChatInputCommand() || interaction.commandName !== "memberinfo") return;
const member = interaction.member;
if (!member) return;
const embed = new CreateEmbed()
.setTitle(member.displayName)
.setThumbnail(member.displayAvatarURL({ size: 128 }))
.addFields(
{ name: "Joined", value: member.joinedAt ? `<t:${Math.floor(member.joinedAt.getTime() / 1000)}:R>` : "Unknown", inline: true },
{ name: "Boosting", value: member.premiumSince ? "Yes 💎" : "No", inline: true },
{ name: "Timed Out", value: member.isTimedOut ? "Yes ⏱️" : "No", inline: true },
);
await interaction.reply({ embeds: [embed] });
});

Members from messages, interactions, the member cache and guilds.members(id).fetch() are attached to the client, so they can act on themselves. Every action takes an optional audit-log reason, and throws when the member is not attached to a client.

Method Description
permissionsIn(channelId) Permissions in a channel, with its overwrites; null when the channel or guild is not cached.
kick(reason?) Kicks the member.
ban({ reason?, deleteMessageSeconds? }) Bans the member.
timeout(ms | null, reason?) Times the member out, or clears the timeout with null. ms must be positive (a RangeError otherwise).
setNickname(nick | null, reason?) Sets or clears the nickname.
addRole(roleId, reason?) / removeRole(roleId, reason?) Changes one role.
edit(options, reason?) Any member field Discord accepts.
client.on("messageCreate", async (message) => {
if (message.content !== "!mute" || !message.member) return;
if (!message.member.permissions.has("ModerateMembers")) return message.reply("You can't do that.");
const target = message.mentions[0];
if (target) await client.guilds.members(message.guildId!).timeout(target.id, 10 * 60_000, "Muted by a moderator");
});

The GuildMemberManager methods (kick, addRole, removeRole, edit, timeout) take the same optional reason.