Represents a member of the guild.

Constructors

  • Constructs a newMember object.

    Parameters

    • client: Client

      The client instance managing this member.

    • data: any

      The raw data from the API representing the member.

    Returns Member

Properties

avatar?: string
avatarDecorationData?: any
communicationDisabledUntil?: string
deaf: boolean
flags: number
joinedAt: string
mute: boolean
nick?: string
pending?: boolean
permissions?: string
premiumSince?: string
roles: string[] = []
user?: User

Methods

  • Adds a role to a member in the guild.

    Parameters

    • roleId: string

      The ID of the role to be added.

    Returns Promise<void>

    Error - If the guildID or memberID is missing.

    Error - If an error occurs during the API request.

  • Bans a user with the given reason and options.

    Parameters

    • reason: string

      The reason for banning the user.

    • options: {
          delete_message_days?: number;
          delete_message_seconds?: number;
      } = {}

      Optional parameters for the ban.

      • Optionaldelete_message_days?: number
      • Optionaldelete_message_seconds?: number

        The number of seconds to delete messages for (0-604800, where 0 is no deletion).

    Returns Promise<any>

  • Edits the properties of the guild member with the specified options.

    This method sends a request to the Discord API to update the member's attributes identified by their user ID within the guild. The updated member data will be reflected in the current instance after the operation is successful.

    Parameters

    • options: {
          channel_id?: string;
          communication_disabled_until?: string;
          deaf?: boolean;
          flags?: number;
          mute?: boolean;
          nick?: string;
          roles?: string[];
      }

      The options for editing the member.

      • Optionalchannel_id?: string

        The ID of the channel to move the user to if they are connected to voice.

      • Optionalcommunication_disabled_until?: string

        The timestamp until the user is muted, or null to remove the timeout.

      • Optionaldeaf?: boolean

        Whether to deafen the user in voice channels.

      • Optionalflags?: number

        Guild member flags to set for the member.

      • Optionalmute?: boolean

        Whether to mute the user in voice channels.

      • Optionalnick?: string

        The nickname to set for the user.

      • Optionalroles?: string[]

        An array of role IDs to assign to the member.

    Returns Promise<Member>

    A promise that resolves to the updated Member instance.

    If the user's ID is not available or if the API request fails.

  • Kicks a user from the guild with the specified reason.

    This method performs a kick operation, which removes a user from the guild. It sends a request to the Discord API to update the guild member's status and then removes the member from the local cache.

    Parameters

    • reason: string

      The reason for kicking the user. This reason will be included in the audit log for the kick operation, which helps to track why the user was kicked. The reason should be a string and can be up to 512 characters long.

    Returns Promise<void>

    A promise that resolves when the kick operation is completed. The request method sends the API request to Discord, and the remove method updates the local cache of members.

    Throws an error if the user's ID is not available. This occurs when this.user?.id is undefined, which means the user cannot be identified, and the kick operation cannot proceed.

  • Removes a role from a member in the guild.

    This method sends a request to the Discord API to remove the specified role from the member. It ensures that the member's ID is available before proceeding with the request.

    Parameters

    • roleId: string

      The ID of the role to be removed.

    Returns Promise<void>

    Error - If the member's ID is missing.

    Error - If an error occurs during the API request.

  • Unbans a user from the guild with the specified reason.

    This method performs an unban operation, which removes a ban from a user in the guild. It sends a request to the Discord API to lift the ban and includes a reason for the action in the audit log.

    Parameters

    • userId: string

      The ID of the user to be unbanned. This ID uniquely identifies the user within the guild.

    • reason: string

      The reason for unbanning the user. This reason will be included in the audit log for the unban operation, which helps to track why the user was unbanned. The reason should be a string and can be up to 512 characters long.

    Returns Promise<void>

    A promise that resolves when the unban operation is completed. The request method sends the API request to Discord.

    Throws an error if the userId is not provided or invalid. This means the user cannot be identified, and the unban operation cannot proceed.