Class GuildMethods

Methods for interacting with Guilds

Hierarchy

  • GuildMethods

Methods

  • Add a guild member to a guild via oauth2 access token

    CurrentUser must be a member of the guild

    Returns

    guild member

    Permissions needed Condition
    CREATE_INSTANT_INVITE always
    OAUTH2 Scopes
    guilds.join

    Example

    // add a user to a server
    const client = new SnowTransfer("TOKEN")
    const memberData = {
    access_token: "access token of a user with the guilds.join scope"
    }
    client.guild.addGuildMember("guildId", "memberId", memberData)

    Parameters

    • guildId: string

      Id of the guild

    • memberId: string

      Id of the guild member

    • data: AddGuildMemberData

      object containing the needed request data

    Returns Promise<void | Member>

  • Add a role to a guild member

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_ROLES always

    Example

    // add a role to a member with a reason of "I want to add a role"
    const client = new SnowTransfer("TOKEN")
    client.guild.addGuildMemberRole("guildId", "memberId", "roleId", { reason: "I want to add a role" })

    Parameters

    • guildId: string

      Id of the guild

    • memberId: string

      Id of the guild member

    • roleId: string

      Id of the role

    • Optional data: {
          reason?: string;
      }

      object with reason property

      • Optional reason?: string

    Returns Promise<void>

  • Create a new Guild, limited to 10 guilds (you may create more if you are whitelisted) Check the discord docs for more infos

    Returns

    Guild

    Example

    // Creates a simple guild with the name "Demo Guild"
    const client = new SnowTransfer("TOKEN")
    const guildData = {
    name: "Demo Guild"
    }
    const guild = await client.guild.createGuild(guildData)

    Parameters

    Returns Promise<Guild>

  • Ban a guild member

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    BAN_MEMBERS always

    Example

    // Ban a user with a reason and delete the last 2 days of their messages
    const client = new SnowTransfer("TOKEN")
    const banData = {
    reason: "Memes were not good enough",
    delete_message_days":2
    }
    client.guild.createGuildBan("guild Id", "memberId", banData)

    Parameters

    • guildId: string

      Id of the guild

    • memberId: string

      Id of the guild member

    • Optional data: {
          delete_message_days?: number;
          reason?: string;
      }

      object with a reason and a delete_message_days property

      • Optional delete_message_days?: number
      • Optional reason?: string

    Returns Promise<void>

  • Create a channel within a guild

    Returns

    channel object

    Permissions needed Condition
    MANAGE_CHANNELS always
    ADMINISTRATOR setting MANAGE_ROLES in permission_overwrites
    * if setting * permission in overwrites where * is any permission

    Example

    // Creates a guild voice channel with the name "nice voice channel" and with permission connect denied for the
    

    Everyone

    role const client = new SnowTransfer("TOKEN") const channelData = { name: "nice voice channel", type: 2, permission_overwrites: [{ id: "guild id", type: 0, allow: "0" deny: (BigInt(1) << BigInt(20)).toString() }] } const channel = await client.guild.createGuildChannel("guild id", channelData)

    Parameters

    Returns Promise<GuildChannel>

  • Create a new Role

    Returns

    role

    Permissions needed Condition
    MANAGE_ROLES always

    Example

    // Create a role with the name "Nice Role" and a color of a soft blue
    const client = new SnowTransfer("TOKEN")
    const roleData = {
    name: "Nice Role",
    color: 0x7c7cf8
    }
    client.guild.createGuildRole("guild Id", roleData)

    Parameters

    • guildId: string

      Id of the guild

    • Optional data: RoleOptions

      data with role properties

    Returns Promise<Role>

  • Delete a guild

    CurrentUser must be the owner of the guild

    This action is irreversible, so use it with caution!

    Returns

    Resolves the Promise on successful execution

    Example

    const client = new SnowTransfer("TOKEN")
    client.guild.deleteGuild("guild id")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<void>

  • Update a guild welcome screen object

    Returns

    Guild Welcome Screen

    Permissions needed Condition
    MANAGE_GUILD always

    Example

    // Disabled the welcome screen
    const client = new SnowTransfer("TOKEN")
    const welcomeScreen = await client.guild.updateGuildWelcomeScreen("guildId", { enabled: false })

    Parameters

    • guildId: string

      Id of guild

    • data: Partial<WelcomeScreen> & {
          enabled?: boolean;
          reason?: string;
      }

      Welcome screen data

    Returns Promise<WelcomeScreen>

  • Get a guild via Id

    CurrentUser must be a member of the guild

    Returns

    Guild object

    Example

    const client = new SnowTransfer("TOKEN")
    const guild = await client.guild.getGuild("guild id")

    Parameters

    • guildId: string

      Id of the guild

    • Optional with_counts: boolean

      when true, will return approximate member and presence counts for the guild

    Returns Promise<Guild>

  • Get a specific ban of a guild member

    Returns

    ban object

    Throws

    a DiscordAPIError if the member is not banned

    Permissions needed Condition
    BAN_MEMBERS always

    Example

    const client = new SnowTransfer("TOKEN")
    const ban = await client.guild.getGuildBan("guildId", "memberId")

    Parameters

    • guildId: string

      Id of the guild

    • memberId: string

      Id of the member

    Returns Promise<Ban>

  • Get bans of a guild

    Returns

    List of bans

    Permissions needed Condition
    BAN_MEMBERS always

    Example

    const client = new SnowTransfer("TOKEN")
    const bans = await client.guild.getGuildBans("guildId")

    Parameters

    • guildId: string

      Id of the guild

    • Optional options: {
          after?: string;
          before?: string;
          limit?: number;
      }

      Query string options

      • Optional after?: string
      • Optional before?: string
      • Optional limit?: number

    Returns Promise<Ban[]>

  • Get a list of all channels for a guild. Does not include threads

    CurrentUser must be a member of the guild

    Returns

    list of channels

    Example

    const client = new SnowTransfer("TOKEN")
    const channels = await client.guild.getGuildChannels("guild id")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<GuildChannel[]>

  • Get integrations for a guild

    Returns

    List of integration objects

    Permissions needed Condition
    MANAGE_GUILD always

    Example

    const client = new SnowTransfer("TOKEN")
    const integrations = await client.guild.getGuildIntegrations("guildId")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<Integration[]>

  • Get invites for a guild

    Returns

    List of invites (with metadata)

    Permissions needed Condition
    MANAGE_GUILD always

    Example

    const client = new SnowTransfer("TOKEN")
    const invites = await client.guild.getGuildInvites("guildId")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<(Invite & InviteMetadata)[]>

  • Get a guild member via Id

    CurrentUser must be a member of the guild

    Returns

    guild member

    Example

    const client = new SnowTransfer("TOKEN")
    const member = await client.guild.getGuildMember("guild id", "member id")

    Parameters

    • guildId: string

      Id of the guild

    • memberId: string

      Id of the guild member

    Returns Promise<Member>

  • Get a list of guild members

    CurrentUser must be a member of the guild

    Returns

    list of guild members

    Intents
    GUILD_MEMBERS

    Example

    // Gets 10 members from a guild
    const client = new SnowTransfer("TOKEN")
    const members = await client.guild.getGuildMembers("guild id", { limit: 10 })

    Parameters

    Returns Promise<Member[]>

  • Gets a guild's preview. If the CurrentUser is not in the guild, the guild must be lurkable

    Returns

    Guild preview

    Example

    const client = new SnowTransfer("TOKEN")
    const guildPreview = await client.guild.getGuildPreview("guild id")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<Required<Pick<Guild, "name" | "description" | "id" | "approximate_presence_count" | "approximate_member_count" | "icon" | "splash" | "discovery_splash" | "emojis" | "features" | "stickers">>>

  • Get the amount of members that would be pruned when a prune with the passed amount of days would be started

    Returns

    Object with a "pruned" key indicating the amount of members that would be pruned

    Permissions needed Condition
    KICK_MEMBERS always

    Example

    const client = new SnowTransfer("TOKEN")
    const data = await client.guild.getGuildPruneCount("guildId", { days: 7 })

    Parameters

    • guildId: string

      Id of the guild

    • Optional query: {
          days?: number;
          include_roles?: string;
      }
      • Optional days?: number
      • Optional include_roles?: string

    Returns Promise<{
        pruned: number;
    }>

  • Get a list of roles for a guild

    Returns

    array of roles

    Permissions needed Condition
    MANAGE_ROLES always

    Example

    const client = new SnowTransfer("TOKEN")
    const roles = await client.guild.getGuildRoles("guildId")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<Role[]>

  • Get a guild's vanity URL code

    Returns

    partial invite object

    Permissions needed Condition
    MANAGE_GUILD always

    Example

    const client = new SnowTransfer("TOKEN")
    const vanityUrl = await client.guild.getGuildVanityUrl("guildId")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<{
        code: null | string;
        uses: number;
    }>

  • Get a list of voice regions for the guild, includes vip-regions unlike voice.getVoiceRegions

    Returns

    List of voice regions

    Example

    const client = new SnowTransfer("TOKEN")
    const regions = await client.guild.getGuildVoiceRegions("guildId")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<VoiceRegion[]>

  • Get a guild's welcome screen object

    Returns

    Guild Welcome Screen

    Permissions needed Condition
    MANAGE_GUILD if the welcome screen is not enabled

    Example

    const client = new SnowTransfer("TOKEN")
    const welcomeScreen = await client.guild.getGuildWelcomeScreen("guildId")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<WelcomeScreen>

  • Gets a guild widget object

    Returns

    Guild Widget

    Example

    const client = new SnowTransfer("TOKEN")
    const widget = await client.guild.getGuildWidget("guildId")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<GuildWidget>

  • Get a guild widget settings object

    Returns

    Guild Widget settings

    Permissions needed Condition
    MANAGE_GUILD always

    Example

    const client = new SnowTransfer("TOKEN")
    const widgetSettings = await client.guild.getGuildWidgetSettings("guildId")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<GuildWidgetSettings>

  • Returns all active threads in the guild, including public and private threads. Threads are ordered by their id, in descending order

    Returns

    All active threads and member objects of the CurrentUser that the CurrentUser has access to.

    Example

    const client = new SnowTransfer("TOKEN")
    const threads = await client.guild.listActiveThreads("guild id")

    Parameters

    • guildId: string

      Id of the guild

    Returns Promise<{
        members: ThreadMember[];
        threads: ThreadChannel[];
    }>

  • Remove a ban of a user

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    BAN_MEMBERS always

    Example

    // Remove a ban of a user with a reason
    const client = new SnowTransfer("TOKEN")
    client.guild.removeGuildBan("guildId", "memberId", "This guy was cool")

    Parameters

    • guildId: string

      Id of the guild

    • memberId: string

      Id of the guild member

    • Optional reason: string

      Reason for removing the ban

    Returns Promise<void>

  • Delete a guild integration

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_GUILD always

    Example

    const client = new SnowTransfer("TOKEN")
    await client.guild.deleteGuildIntegration("guildId", "integrationId", "Didn't need anymore")

    Parameters

    • guildId: string

      Id of the guild

    • integrationId: string

      Id of the integration

    • Optional reason: string

    Returns Promise<void>

  • Remove a guild member (aka kick them)

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    KICK_MEMBERS always

    Example

    // Kick a member with a reason of "spam"
    const client = new SnowTransfer("TOKEN")
    client.guild.removeGuildMember("guild Id", "memberId", "spam")

    Parameters

    • guildId: string

      Id of the guild

    • memberId: string

      Id of the guild member

    • Optional reason: string

      Reason for kicking the member

    Returns Promise<void>

  • Remove a role from a guild member

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_ROLES always

    Example

    // remove a role from a member with a reason of "I want to remove a role"
    const client = new SnowTransfer("TOKEN")
    client.guild.removeGuildMemberRole("guildId", "memberId", "roleId", "I want to remove a role")

    Parameters

    • guildId: string

      Id of the guild

    • memberId: string

      Id of the guild member

    • roleId: string

      Id of the role

    • Optional reason: string

    Returns Promise<void>

  • Delete a role from the guild

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_ROLES always

    Example

    // Deletes a role with a reason "This role is too cool"
    const client = new SnowTransfer("TOKEN")
    client.guild.deleteGuildRole("guildId", "roleId", "This role is too cool")

    Parameters

    • guildId: string

      Id of the guild

    • roleId: string

      Id of the role

    • Optional reason: string

      Reason for deleting the role

    Returns Promise<void>

  • Get a list of guild members that match a query

    Returns

    list of guild members

    Example

    // Gets all members with the username "Wolke"
    const client = new SnowTransfer("TOKEN")
    const members = await client.guild.searchGuildMembers("guild id", { query: "Wolke" })

    Parameters

    • guildId: string

      Id of the guild

    • options: {
          limit?: number;
          query: string;
      }

      query data

      • Optional limit?: number
      • query: string

    Returns Promise<Member[]>

  • Start a prune

    Returns

    Object with a "pruned" key indicating the amount of members that were pruned

    Permissions needed Condition
    KICK_MEMBERS always

    Example

    const client = new SnowTransfer("TOKEN")
    const data = await client.guild.startGuildPrune("guildId", { days: 7 })

    Parameters

    • guildId: string

      Id of the guild

    • data: {
          compute_prune_count?: boolean;
          days?: number;
          include_roles?: string[];
          reason?: string;
      }

      Object with prune data

      • Optional compute_prune_count?: boolean
      • Optional days?: number
      • Optional include_roles?: string[]
      • Optional reason?: string

    Returns Promise<{
        pruned: number;
    }>

  • Parameters

    • guildId: string
    • data: {
          compute_prune_count: false;
          days?: number;
          include_roles?: string[];
          reason?: string;
      }
      • compute_prune_count: false
      • Optional days?: number
      • Optional include_roles?: string[]
      • Optional reason?: string

    Returns Promise<{
        pruned: null;
    }>

  • Batch update the positions of channels. Only those being moved needs to be included here

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_CHANNELS always

    Example

    // Sets the position of a channel to 2 under a category channel
    const client = new SnowTransfer("TOKEN")
    client.guild.updateChannelPositions("guild id", [{ id: "channel id", position: 2, category_id: "category id" }])

    Parameters

    • guildId: string

      Id of the guild

    • data: {
          id: string;
          lock_permissions?: null | boolean;
          parent_id?: null | string;
          position: null | number;
      }[]

      Positional data to send

    Returns Promise<void>

  • Updates the current user's voice state in a stage channel

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    MUTE_MEMBERS when trying to un-suppress yourself
    REQUEST_TO_SPEAK when trying to request to speak

    Example

    // Unsuppresses the CurrentUser in the stage channel they're in
    const client = new SnowTransfer("TOKEN")
    client.guild.updateGuildVoiceState("guildId", { channel_id: "channel id", suppress: false })

    Parameters

    • guildId: string

      Id of the guild

    • data: {
          channel_id: string;
          request_to_speak_timestamp?: null | string;
          suppress?: boolean;
      }

      Data of the voice state

      • channel_id: string
      • Optional request_to_speak_timestamp?: null | string
      • Optional suppress?: boolean

    Returns Promise<void>

  • Update a guild

    Returns

    Guild object

    Permissions needed Condition
    MANAGE_GUILD always

    Example

    // Update the name of a guild to "Nice Guild"
    const client = new SnowTransfer("TOKEN")
    const guildData = {
    name: "Nice Guild"
    }
    client.guild.updateGuild("guild Id", guildData)

    Parameters

    Returns Promise<Guild>

  • Update properties of a guild member

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    MANAGE_NICKNAMES Nick Updates
    MANAGE_ROLES Role Updates
    MUTE_MEMBERS Mute Updates
    DEAFEN_MEMBERS Deaf Updates
    MOVE_MEMBERS Voice Move
    CONNECT Voice Move
    MODERATE_MEMBERS Timeouts

    Example

    // Reset the nickname of a guild member
    const client = new SnowTransfer("TOKEN")
    const memberData = {
    nick: "" // You can reset nicknames by providing an empty string as the value of data.nick
    }
    const member = await client.guild.updateGuildMember("guild Id", "memberId", memberData)

    Parameters

    • guildId: string

      Id of the guild

    • memberId: string

      Id of the guild member

    • data: UpdateGuildMemberData

      Updated properties

    Returns Promise<Member>

  • Update a guild role

    Returns

    Updated Role

    Permissions needed Condition
    MANAGE_ROLES always

    Example

    const client = new SnowTransfer("TOKEN")
    const roleData = {
    name: "Nicer Role",
    }
    client.guild.updateGuildRole("guildId", "roleId", roleData)

    Parameters

    • guildId: string

      Id of the guild

    • roleId: string

      Id of the role

    • data: RoleOptions

      updated properties of the role

    Returns Promise<Role>

  • Modify the positions of roles

    Returns

    array of roles

    Permissions needed Condition
    MANAGE_ROLES always

    Example

    const client = new SnowTransfer("TOKEN")
    const roles = await client.guild.updateGuildRolePositions("guildId", [{ id: "guild id", position: 1 }, { id: "role id 2", position: 2 }])

    Parameters

    • guildId: string

      Id of the guild

    • data: {
          id: string;
          position?: null | number;
      }[]

      Role data to update

    Returns Promise<Role[]>

  • Update a guild widget settings object

    Returns

    Updated Guild Widget settings

    Permissions needed Condition
    MANAGE_GUILD always

    Example

    // Sets a widget as disabled
    const client = new SnowTransfer("TOKEN")
    const widgetSettings = await client.guild.updateGuildWidgetSettings("guildId", { enabled: false })

    Parameters

    • guildId: string

      Id of the guild

    • data: Partial<GuildWidgetSettings & {
          reason: string;
      }>

      widget settings

    Returns Promise<GuildWidgetSettings>

  • Update the nick of the CurrentMember

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    CHANGE_NICKNAME always

    Example

    // change nick of bot to "Nice Nick"
    const client = new SnowTransfer("TOKEN")
    const nickData = {
    nick: "Nice Nick"
    }
    client.guild.updateSelf("guildId", nickData)

    Parameters

    • guildId: string

      Id of the guild

    • data: {
          nick: string;
          reason?: string;
      }

      object with a nick property and optionally, a reason property

      • nick: string
      • Optional reason?: string

    Returns Promise<Member>

  • Updates a user's voice state in a stage channel

    Returns

    Resolves the Promise on successful execution

    Permissions needed Condition
    MUTE_MEMBERS when trying to suppress/un-suppress

    Example

    // Suppresses the user in the stage channel they're in
    const client = new SnowTransfer("TOKEN")
    client.guild.updateGuildVoiceState("guildId", "userId", { channel_id: "channel id", suppress: true })

    Parameters

    • guildId: string

      Id of the guild

    • userId: string
    • data: {
          channel_id: string;
          suppress?: boolean;
      }

      Data of the voice state

      • channel_id: string
      • Optional suppress?: boolean

    Returns Promise<void>

Constructors

  • Create a new Guild Method Handler

    Usually SnowTransfer creates a method handler for you, this is here for completion

    You can access the methods listed via client.guild.method, where client is an initialized SnowTransfer instance

    Parameters

    • requestHandler: RequestHandler

      request handler that calls the rest api

    Returns GuildMethods

Properties

requestHandler: RequestHandler

Generated using TypeDoc