mapih
TypeScript icon, indicating that this package has built-in type declarations

3.13.2 • Public • Published

view on npm npm module downloads

Mapih

Comprehensive collection of Discord, Slack*, and Spotify* API endpoint handlers

* These are still in very early development


Authentication

Choose one of the following options to authenticate:

Option 1: Using Environment Variablese

If you are using OnSocket, use this file to get the valid keys but add them to OnSocket's environment variables on the website itself.

Rename the provided .env.example file at the root of your project to .env and fill in any tokens/keys you wish to use.

Option 2: Using Initialization Function

const mapih = require('mapih');

// Minimum requirement if using this method
mapih.initialize({ discord: 'bot_token' });  

// All possible properties 
mapih.initialize({
  discord: 'bot_token',
  openai: 'sk-1p7NKtCpA0sG7XLdT3L7EqW9GFefX',
  spotify: {
    client_id: 'cc4287d9Cm4692a9f681d07d9boqji83',
    client_secret: '898Nb8f7b09tMnb2lkj3c55443ddmn0ze',
    redirect_uri: 'http:localhost:8001/spotify',
    scope: 'user-read-email user-read-private'
  },
  google: {
    api_key: 'AISlkuhyA4q4L9m0c3I09maoOYTN0wuyWdA',
    client_id: '2164170085-9r94msc46elo.apps.googleusercontent.com',
    client_secret: 'GOSLPM-sPn88Kn6GWk90Nh0uk_MNim7698By4',
    redirect_uri: 'http://localhost:8001/youtube'
  },
  slack: {
    user: '6942854604069-6272480346098-6284925009575-6901309',
    bot: '6942854604069-6262140883098-Vt6RKehxmTj4Luvvy',
    client_id: '6942854604069.624286609478',
    client_secret: '4e4998dh94rl846bdsdfegfb0f12',
    redirect_uri: 'http:localhost:8001/slack',
    user_scope: 'admin users:read.email',
    bot_scope: 'users:read.email channels:read'
  },
  dropbox: {
    basic_token: 'N09asdfGlzZzB9P63465efasNWxAvfpk3dQ',
    access_token: 'sl.BsobToktTBbsdf235aiihH7j60T_4T',
    client_id: '7cxvzmptyug7ymc9',
    client_secret: 'easdf8980k6csdf5y7u',
    redirect_uri: 'http:localhost:8001/dropbox'
  },
  box: {
    client_id: '3sdfgi8j90fpl8q25809sd0',
    client_secret: 'Jsdf6BB4UErgS2chrg4365sdfBXS',
    redirect_uri: 'http:localhost:8001/box'
  },
});

Basic usage

(async() => {

  await mapih.discord.channels.messages.create({
    channel_id: '774133713733812275',
    content: 'hello'
  });

})();

Table of Contents

Applications
    ◦ getMe
    ◦ updateMe
    ◦ appRoleConnectionMeta
    ◦ updateAppRoleConnectionMeta
    ◦ commands
        ‣ retrieve
        ‣ getAll
        ‣ create
        ‣ update
        ‣ destroy
        ‣ bulkOverwrite
        ‣ retrievePermissions
        ‣ getAllPermissions
        ‣ updatePermissions
    ◦ entitlements
        ‣ getAll
        ‣ create
        ‣ destroy
    ◦ skus
        ‣ getAll
Audit Log
    ◦ retrieve
Auto Moderation
    ◦ retrieveRule
    ◦ getAllRules
    ◦ createRule
    ◦ updateRule
    ◦ destroyRule
Channels
    ◦ retrieve
    ◦ update
    ◦ destroy
    ◦ updatePermissions
    ◦ deletePermissions
    ◦ getinvites
    ◦ inviteCreate
    ◦ typingCreate
    ◦ followAnnouncementChannel
    ◦ groupDMadd
    ◦ groupDMremove
    ◦ messages
        ‣ retrieve
        ‣ getAll
        ‣ create
        ‣ update
        ‣ destroy
        ‣ bulkDelete
        ‣ crosspost
        ‣ pin
        ‣ unpin
        ‣ getPinned
    ◦ threads
        ‣ forumThreadCreate
        ‣ createFromMessage
        ‣ createWithoutMessage
        ‣ join
        ‣ leave
        ‣ addMember
        ‣ removeMember
        ‣ retrieveMember
        ‣ getAllMembers
        ‣ getAllPublicArchived
        ‣ getAllPrivateArchived
        ‣ getAllJoinedPrivateArchived
    ◦ reactions
        ‣ create
        ‣ deleteOwn
        ‣ deleteUser
        ‣ deleteAll
        ‣ deleteAllEmoji
        ‣ getUsers
Guilds
    ◦ create
    ◦ update
    ◦ destroy
    ◦ retrieve
    ◦ destroy
    ◦ getPreview
    ◦ retrieveBan
    ◦ getAllBans
    ◦ createBan
    ◦ destroyBan
    ◦ getInvites
    ◦ updateMFAlevel
    ◦ getPruneCount
    ◦ beginPrune
    ◦ getVoiceRegions
    ◦ getAllIntegrations
    ◦ destroyIntegration
    ◦ retrieveWidget
    ◦ retrieveWidgetImage
    ◦ retrieveWidgetSettings
    ◦ updateWidget
    ◦ retrieveVanityURL
    ◦ retrieveWelcomeScreen
    ◦ updateWelcomeScreen
    ◦ retrieveOnboarding
    ◦ updateOnboarding
    ◦ newMemberWelcome
    ◦ channels
        ‣ getAll
        ‣ create
        ‣ updatePositions
    ◦ members
        ‣ retrieve
        ‣ getAll
        ‣ search
        ‣ remove
        ‣ update
        ‣ updateCurrent
        ‣ addRole
        ‣ removeRole
        ‣ getPermissionNames
        ‣ timeout
    ◦ roles
        ‣ retrieve
        ‣ getAll
        ‣ create
        ‣ update
        ‣ destroy
        ‣ updatePositions
    ◦ emojis
        ‣ retrieve
        ‣ getAll
        ‣ create
        ‣ update
        ‣ destroy
    ◦ stickers
        ‣ retrieve
        ‣ nitroPacks
        ‣ getAll
        ‣ retrieveGuild
        ‣ create
        ‣ update
        ‣ destroy
    ◦ events
        ‣ retrieve
        ‣ getAll
        ‣ getUsers
        ‣ create
        ‣ update
        ‣ destroy
    ◦ templates
        ‣ retrieve
        ‣ getAll
        ‣ create
        ‣ createGuild
        ‣ sync
        ‣ update
        ‣ destroy
Interactions
    ◦ callback
        ‣ reply
        ‣ defer
        ‣ get_original
        ‣ update_original
        ‣ delete_original
        ‣ component_defer
        ‣ component_update
        ‣ autocomplete_reply
        ‣ modal_reply
        ‣ upgrade
    ◦ followup
        ‣ retrieve
        ‣ create
        ‣ update
        ‣ destroy
Invites
    ◦ retrieve
    ◦ revoke
OAuth 2
Stage Instances
    ◦ retrieve
    ◦ create
    ◦ update
    ◦ destroy
Users
    ◦ retrieve
    ◦ currentUser
    ◦ myGuilds
    ◦ currentMember
    ◦ updateCurrent
    ◦ connections
    ◦ appRoleConnection
    ◦ updateAppRoleConnection
    ◦ createDM
    ◦ createGroupDM
    ◦ leaveGuild
Webhooks
    ◦ retrieve
    ◦ retrieveWithToken
    ◦ retrieveChannel
    ◦ retrieveGuild
    ◦ retrieveMessage
    ◦ updateMessage
    ◦ destroyMessage
    ◦ create
    ◦ update
    ◦ updateWithToken
    ◦ destroy
    ◦ destroyWithToken
    ◦ execute
Objects/Types
    ◦ Guilds
    ◦ Users
    ◦ Channels
    ◦ Interactions
    ◦ Roles
    ◦ Emojis/Stickers
    ◦ Message Components
    ◦ Webhooks
    ◦ Invites
    ◦ Application
    ◦ Audit Log
    ◦ Auto Moderation

Chat
    ◦ create
Images
    ◦ create
Speech
    ◦ create
Embeddings
    ◦ create

Docs coming soon

Users
    ◦ me
    ◦ topItems
    ◦ getProfile
Search
    ◦ advanced
    ◦ artists
    ◦ songs
    ◦ albums
Songs
    ◦ retrieve
    ◦ retrieveMany
    ◦ recommendations
    ◦ save
    ◦ unsave
    ◦ saved
    ◦ isSaved
    ◦ analyze
    ◦ audioFeatures
    ◦ audioFeaturesMany
Artists
    ◦ retrieve
    ◦ retrieveMany
    ◦ recommendations
    ◦ albums
    ◦ related
    ◦ follow
    ◦ unfollow
    ◦ following
    ◦ isFollowing
Albums
    ◦ retrieve
    ◦ retrieveMany
    ◦ songs
    ◦ new
    ◦ save
    ◦ unsave
    ◦ saved
    ◦ isSaved
Playlists
    ◦ featured
    ◦ category
    ◦ create
    ◦ addSongs
    ◦ update
    ◦ updateSongs
    ◦ removeSongs
    ◦ retrieveSongs
    ◦ created
    ◦ following
    ◦ isFollowing
    ◦ follow
    ◦ unfollow
    ◦ user
    ◦ cover
    ◦ updateCover
Playback
    ◦ state
    ◦ currentSong
    ◦ devices
    ◦ togglePlayback
    ◦ pause
    ◦ skip
    ◦ previous
    ◦ seek
    ◦ setVolume
    ◦ toggleShuffle
    ◦ toggleRepeat
    ◦ queue
    ◦ recent
    ◦ addToQueue
    ◦ transfer

Storage
    ◦ get
    ◦ getMany
    ◦ set
    ◦ setMany
    ◦ delete
    ◦ deleteMany
    ◦ merge
    ◦ push
    ◦ export
    ◦ filter
    ◦ all
    ◦ has
    ◦ entries
    ◦ keys
    ◦ values
    ◦ size
    ◦ bytes
    ◦ toJson
    ◦ clear
    ◦ equals
    ◦ history
    ◦ clearHistory


Discord

Guilds

All functions relating to Discord Guilds (servers)

Method Description
retrieve Get information about a guild
create Create a new guild
update Modify a guild's settings
destroy Delete a guild
getPreview Get the guild's preview
retrieveBan Get guild ban with given id
getAllBans Get a list of a guild's bans
createBan Create a new guild ban
destroyBan Delete a guild ban
getInvites Get a list of a guild's invites
updateMFAlevel Modify the guild's MFA level
getPruneCount Get number of members that would be removed in a prune operation
beginPrune Begin a prune operation
getVoiceRegions Get a list of a guild's voice regions
getAllIntegrations Get a list of a guild's integrations
destroyIntegration Delete a guild integration
retrieveWidget Get the guild's widget
retrieveWidgetSettings Get the guild's widget settings
retrieveWidgetImage Get the guild's widget image
updateWidget Modify the guild's widget
retrieveVanityURL Get the guild's vanity url
retrieveWelcomeScreen Get the guild's welcome screen
updateWelcomeScreen Modify the guild's welcome screen
retrieveOnboarding Get the guild's onboarding
updateOnboarding Modify the guild's onboarding
newMemberWelcome * undocumented

Parameters

Field Type Description
guild_id snowflake the id of the guild
with_counts? boolean Approcimate member and presence counts

Example

await api.discord.guilds.retrieve({
  guild_id: '0000000000'
});

This endpoint can be used only by bots in less than 10 servers.

Parameters

Field Type Description
name string Name of the guild (2-100 characters)
icon? string/buffer Guild icon (url to image or image buffer)
roles? array of Role objects Roles to add to the guild
channels? array of PartialChannel objects Channels to add to the guild
verification_level? number The guild's verification level
default_message_notifications? number Default message notification level
explicit_content_filter? number Explicit content filter level
afk_channel_id? snowflake ID for afk channel
afk_timeout? number afk timeout in seconds, can be set to: 60, 300, 900, 1800, 3600
system_channel_id? snowflake The id of the channel where guild notices such as welcome messages and boost events are posted
system_channel_flags? number System channel flags

Example

await api.discord.guilds.create({
  name: "Eric's Server",
  icon: 'https://imgurl.png', // or buffer
  default_message_notifications: 1, // ONLY_MENTIONS
  verification_level: 0, // NONE
  explicit_content_filter: 0, // DISABLED
  roles: [{
    name: 'Administrator',
    permissions: 1 << 3,
    hoist: 'true',
    mentionable: 'false'
  }],
  channels: [
    {
      name: 'my-category',
      type: 4, // GUILD_CATEGORY
      id: 1
    },
    {
      name: 'bot-testing',
      type: 0, // GUILD_TEXT
      id: 2,
      parent_id: 1 // 'my-category'
    }
  ]
});

Parameters

Field Type Description
name string Name of the guild (2-100 characters)
description string
owner_id snowflake User id to transfer server ownership to
icon url/buffer
splash url/buffer
discovery_splash url/buffer
banner url/buffer
verification_level number The guild's verification level
default_message_notifications number Default message notification level
explicit_content_filter number Explicit content filter level
afk_channel_id snowflake id for afk channel
afk_timeout number afk timeout in seconds, can be set to: 60, 300, 900, 1800, 3600
system_channel_id snowflake The id of the channel where guild notices such as welcome messages and boost events are posted
system_channel_flags number System channel flags
rules_channel_id snowflake
system_updates_channel_id snowflake
premium_progress_bar_enabled number

Example

await api.discord.guilds.update({
  name: "Eric's New Server",
  // ...
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.destroy({
  guild_id: '0000000000'
});

• If the user is not in the guild, then the guild must be lurkable.

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.getPreview({
  guild_id: '0000000000'
});

• Returns a ban object for the given user or a 404 not found if the ban cannot be found.
• Requires the BAN_MEMBERS permission.

Parameters

Field Type Description
guild_id snowflake the id of the guild
user_id snowflake The ID of the user the ban was created for

Example

await api.discord.guilds.retrieveBan({
  guild_id: '0000000000',
  user_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
limit? number Number of users to return (up to maximum 1000) (default 1000)
before? snowflake Consider only users before given user ID
after? snowflake Consider only users after given user ID

Example

await api.discord.guilds.getAllBans({
  guild_id: '0000000000',
  limit: 50,
  after: '0000000000'
});

• Requires the BAN_MEMBERS permission.

Parameters

Field Type Description
guild_id snowflake the id of the guild
user_id snowflake User ID of the user to ban
delete_message_seconds? snowflake Number of seconds to delete the banned user's messages for, between 0 and 604800 (7 days).
reason? string Reason for the ban

Example

await api.discord.guilds.createBan({
  guild_id: '0000000000',
  user_id: '0000000000',
  delete_message_seconds: 604800,
  reason: 'not cool enough'
});

• Requires the BAN_MEMBERS permission.

Parameters

Field Type Description
guild_id snowflake the id of the guild
user_id snowflake User ID of the user to unban
reason? string Reason

Example

await api.discord.guilds.destroyBan({
  guild_id: '0000000000',
  user_id: '0000000000',
  reason: 'ok I guess you\'re alright'
});

• Requires guild ownership.

Parameters

Field Type Description
guild_id snowflake the id of the guild
level number MFA level

Example

await api.discord.guilds.updateMFAlevel({
  guild_id: '0000000000',
  level: 0
});

• By default, prune will not remove users with roles.
• You can optionally include specific roles in your prune by providing the include_roles parameter.
• Any inactive user that has a subset of the provided role(s) will be counted in the prune and users with additional roles will not.

Parameters

Field Type Description
guild_id snowflake the id of the guild
days number Number of days to count prune for (1-30) (Default 7)
include_roles? string[] An array of role IDs to include

Example

await api.discord.guilds.getPruneCount({
  guild_id: '0000000000',
  days: 3,
  include_roles: [
    '0000000000'
  ]
});

• For large guilds it's recommended to set the compute_prune_count option to false, forcing pruned to null.
• By default, prune will not remove users with roles.
• You can optionally include specific roles in your prune by providing the include_roles parameter.
• Any inactive user that has a subset of the provided role(s) will be counted in the prune and users with additional roles will not.

Parameters

Field Type Description
guild_id snowflake the id of the guild
days number Number of days to count prune for (1-30) (default 7)
compute_prune_count boolean Whether pruned is returned, discouraged for large guilds (default true)
include_roles? snowflake[] An array of role IDs to include
reason? string Reason

Example

await api.discord.guilds.beginPrune({
  guild_id: '0000000000',
  days: 3,
  compute_prune_count: true,
  include_roles: [
    '0000000000'
  ]
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.getVoiceRegions({
  guild_id: '0000000000'
});

This endpoint returns a maximum of 50 integrations.
If a guild has more integrations, they cannot be accessed.

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.getAllIntegrations({
  guild_id: '0000000000'
});

• Deletes any associated webhooks and kicks the associated bot if there is one.

Parameters

Field Type Description
guild_id snowflake the id of the guild
integration_id snowflake The ID of the integration to delete

Example

await api.discord.guilds.destroyIntegration({
  guild_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.retrieveWidget({
  guild_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.retrieveWidgetSettings({
  guild_id: '0000000000'
});
Widget Style Options
Value Description Example
shield shield style widget with Discord icon and guild members online count Example
banner1 large image with guild icon, name and online count. "POWERED BY DISCORD" as the footer of the widget Example
banner2 smaller widget style with guild icon, name and online count. Split on the right with Discord logo Example
banner3 large image with guild icon, name and online count. In the footer, Discord logo on the left and "Chat Now" on the right Example
banner4 large Discord logo at the top of the widget. Guild icon, name and online count in the middle portion of the widget and a "JOIN MY SERVER" button at the bottom Example

Parameters

Field Type Description
guild_id snowflake the id of the guild
style string Widget style (see above)

Example

await api.discord.guilds.retrieveWidgetImage({
  guild_id: '0000000000',
  style: 'banner3'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
channel_id? snowflake temp
enabled? boolean Whether the widget is enabled

Example

await api.discord.guilds.updateWidget({
  guild_id: '0000000000',
  enabled: true
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.retrieveVanityURL({
  guild_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.retrieveWelcomeScreen({
  guild_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
description? string The server description to show in the welcome screen
enabled? boolean Whether the welcome screen is enabled.
welcome_channels? array of welcome screen channel objects Channels shown in the welcome screen, up to 5

Example

await api.discord.guilds.updateWelcomeScreen({
  guild_id: '0000000000',
  enabled: true
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.retrieveOnboarding({
  guild_id: '0000000000',
  enabled: true
});

• Requires the MANAGE_GUILD and MANAGE_ROLES permissions.
• Onboarding enforces constraints when enabled. These constraints are that there must be at least 7 Default Channels and at least 5 of them must allow sending messages to the @everyone role. The mode field modifies what is considered when enforcing these constraints.**

Parameters

Field Type Description
guild_id snowflake the id of the guild
prompts array of onboarding prompt objects Prompts shown during onboarding and in customize commutity
default_channel_ids array of snowflakes Channel IDs that members get opted into automatically
enabled boolean Whether onboarding is enabled in the guild
mode onboarding mode Current mode of onboarding

Example

await api.discord.guilds.updateOnboarding({
  guild_id: '0000000000',
  prompts: [{
    id: '0000000000',
    type: 0,
    title: 'Prompt Title',
    single_select: true,
    required: true,
    in_onboarding: true,
    options: [{
      title: 'Option Title',
      description: 'Option description',
      id: '0000000000',
      channel_ids: [
        '0000000000'
      ],
      role_ids: [
        '0000000000'
      ],
      emoji: {
        id: '0000000000',
        name: 'emoji_name',
        animated: false
      }
    }]
  }]
});

Guild Channels

Method Description
getAll Retrieve all channels in a guild.
create Create a new guild channel.
updatePositions Modify the positions of channels.
Does not include threads

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.channels.getAll({
  guild_id: '0000000000'
});

All parameters to this endpoint are optional and nullable excluding name

Parameters

Field Type Description Channel Type
name string channel name (1-100 characters) All
type number the type of channel All
topic string channel topic (0-1024 characters) Text, Announcement, Forum, Media
bitrate number the bitrate (in bits) of the voice or stage channel; min 8000 Voice, Stage
user_limit number the user limit of the voice channel Voice, Stage
rate_limit_per_user number amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected Text, Voice, Stage, Forum, Media
position number sorting position of the channel All
permission_overwrites array of partial overwrite objects the channel's permission overwrites All
parent_id snowflake id of the parent category for a channel Text, Voice, Announcement, Stage, Forum, Media
nsfw boolean whether the channel is nsfw Text, Voice, Announcement, Stage, Forum
rtc_region string channel voice region id of the voice or stage channel, automatic when set to null Voice, Stage
video_quality_mode number the camera video quality mode of the voice channel Voice, Stage
default_auto_archive_duration number the default duration that the clients use (not the API) for newly created threads in the channel, in minutes, to automatically archive the thread after recent activity Text, Announcement, Forum, Media
default_reaction_emoji default reaction object emoji to show in the add reaction button on a thread in a GUILD_FORUM or a GUILD_MEDIA channel Forum, Media
available_tags array of tag objects set of tags that can be used in a GUILD_FORUM or a GUILD_MEDIA channel Forum, Media
default_sort_order number the default sort order type used to order posts in GUILD_FORUM and GUILD_MEDIA channels Forum, Media
default_forum_layout number the default forum layout view used to display posts in GUILD_FORUM channels Forum
default_thread_rate_limit_per_user number the initial rate_limit_per_user to set on newly created threads in a channel. this field is copied to the thread at creation time and does not live update. Text, Announcement, Forum, Media

Example

await api.discord.guilds.channels.create({
  guild_id: '0000000000',
  name: 'my-new-channel',
  type: 0,
  topic: 'Cool people only',
  position: 19
});

Only channels to be modified are required

Parameters

Field Type Description
id snowflake channel id
position? ?number sorting position of the channel
lock_permissions? ?boolean syncs the permission overwrites with the new parent, if moving to a new category
parent_id? ?snowflake the new parent ID for the channel that is moved

Example

await api.discord.guilds.channels.updatePositions({
  guild_id: '0000000000',
  channels: [{
    id: '0000000000',
    position: 3,
    lock_permissions: true,
    parent_id: '0000000000'
  }]
});

Guild Members

Method Description
retrieve Returns information about a user
getAll List all members of a guild
search Search for guild members by name or nickname
remove Remove a member from a guild
update Modify attributes of a guild member
updateCurrent Modify the current bot's nickname in the guild
addRole Add a role to a guild member
removeRole Remove a role from a guild member
getPermissionNames Get a user's permission's names
timeout Update a member's communication timeout

Parameters

Field Type Description
guild_id snowflake the id of the guild
user_id snowflake The ID of the user

Example

await api.discord.guilds.members.retrieve({
  guild_id: '0000000000',
  user_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
limit number Max number of members to return (1-1000) (default 1)
after snowflake The highest user id in the previous page (default 0)

Example

await api.discord.guilds.members.getAll({
  guild_id: '0000000000',
  limit: 1000
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
query string Query string to match username(s) and nickname(s) against
limit number Max number of members to return (1-1000) (default 1)

Example

await api.discord.guilds.members.search({
  guild_id: '0000000000',
  query: 'lostmyinfo',
  limit: 1
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
user_id snowflake The ID of the user to remove
reason? string Reason for kick

Example

await api.discord.guilds.members.remove({
  guild_id: '0000000000',
  user_id: '0000000000',
  reason: 'not cool enough'
});

• If the channel_id is set to null, this will force the target user to be disconnected from voice.

All parameters to this endpoint are optional and nullable.

Parameters

Field Type Description Permission
guild_id snowflake the id of the guild
role_id snowflake the id of the role
nick string value to set user's nickname to MANAGE_NICKNAMES
roles array of snowflakes array of role ids the member is assigned MANAGE_ROLES
mute boolean whether the user is muted in voice channels MUTE_MEMBERS
deaf boolean whether the user is deafened in voice channels DEAFEN_MEMBERS
channel_id snowflake id of channel to move user to (if they are connected to voice) MOVE_MEMBERS
communication_disabled_until ISO8601 timestamp when the user's timeout will expire (up to 28 days in the future) MODERATE_MEMBERS
flags number guild member flags MODERATE_MEMBERS

Example

await api.discord.guilds.members.update({
  guild_id: '0000000000',
  nick: 'cool new nick'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
nick? string Value to set user's nickname to

Example

await api.discord.guilds.members.updateCurrent({
  guild_id: '0000000000',
  nick: 'cool new nick'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
user_id snowflake The user ID of the user to assign the role to
role_id snowflake The role ID of the role to give the user

Example

await api.discord.guilds.members.addRole({
  guild_id: '0000000000',
  user_id: '0000000000',
  role_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
user_id snowflake The user ID of the user to remove the role from
role_id snowflake The role ID of the role to remove from the user

Example

await api.discord.guilds.members.removeRole({
  guild_id: '0000000000',
  user_id: '0000000000',
  role_id: '0000000000'
});

Get Member Permission Names

Parameters

Type Description
array of role IDs Roles of a member
array of role objects Roles of a guild

Example

const x = params.member.roles;
const y = params.guild.roles;
const permNames = getPermissionNames(x, y);

Timeout Guild Member

• Sets/adjusts/clears a member's timeout

Parameters

Field Type Description
guild_id snowflake the id of the guild
user_id snowflake The user ID of the user to remove the role from
duration number Duration in seconds to set timeout. Set to null or omit to clear timeout.
reason? string Reason

Example

// timeout a member for 5 minutes
await api.discord.guilds.members.timeout({
  guild_id: '0000000000',
  user_id: '0000000000',
  duration: 300 // 5 minutes
});

// clear a member's timeout
await api.discord.guilds.members.timeout({
  guild_id: '0000000000',
  user_id: '0000000000'
});

Guild Roles

Method Description
retrieve Retrieve a role by ID
getAll List all roles in a guild
create Create a new role in the guild
update Modify properties of a guild role
destroy Modify properties of a guild role

Get Guild role

Parameters

Field Type Description
guild_id snowflake the id of the guild
role_id snowflake the id of the role

Example

await api.discord.guilds.roles.retrieve({
  guild_id: '0000000000',
  role_id: '0000000000'
});

Get Guild Roles

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.roles.getAll({
  guild_id: '0000000000'
});

Create Guild Role

Parameters

Field Type Description Default
guild_id snowflake the id of the guild
role_id snowflake the id of the role
name string name of the role, max 100 characters "new role"
permissions string bitwise value of the enabled/disabled permissions @everyone
color number RGB color value 0
hoist boolean whether the role should be displayed separately in the sidebar false
icon url/buffer the role's icon image (if the guild has the ROLE_ICONS feature) null
unicode_emoji ?string the role's unicode emoji as a standard emoji (if guild has the ROLE_ICONS feature) null
mentionable boolean whether the role should be mentionable false

Example

await api.discord.guilds.roles.create({
  guild_id: '0000000000',
  name: 'cool kids',
  hoist: true,
  mentionable: true,
  icon: 'https://www.picofcoolkid.png'
});

Modify Guild Role

All parameters to this endpoint are optional and nullable.

Parameters

Field Type Description
guild_id snowflake the id of the guild
role_id snowflake the id of the role
name string name of the role, max 100 characters
permissions string bitwise value of the enabled/disabled permissions
color number RGB color value
hoist boolean whether the role should be displayed separately in the sidebar
icon url/buffer the role's icon image (if the guild has the ROLE_ICONS feature)
unicode_emoji ?string the role's unicode emoji as a standard emoji (if guild has the ROLE_ICONS feature)
mentionable boolean whether the role should be mentionable

Example

await api.discord.guilds.roles.update({
  guild_id: '0000000000',
  role_id: '0000000000',
  name: 'new role name',
  hoist: false,
  mentionable: false,
  icon: 'https://www.newimage.png'
});

Delete Guild Role

Parameters

Field Type Description
guild_id snowflake the id of the guild
role_id snowflake the id of the role
reason? string reason

Example

await api.discord.guilds.roles.destroy({
  guild_id: '0000000000',
  role_id: '0000000000'
});

Modify Guild Role Positions

Parameters

Field Type Description
guild_id snowflake the id of the guild
roles array of partial channel objects the ids and new positions of the channels to modify

Example

await api.discord.guilds.roles.retrieve({
  guild_id: '0000000000',
  roles: [
    { id: '0000000000', position: 3 },
    { id: '0000000000', position: 8 }
  ]
});

Guild Emojis

Method Description
retrieve Get a specific emoji from a guild
getAll List all emojis in a guild
create Create a new emoji in the guild
update Modify a guild emoji
destroy Delete a guild emoji

Parameters

Field Type Description
guild_id snowflake the id of the guild
emoji_id snowflake The id of the emoji

Example

await api.discord.guilds.emojis.retrieve({
  guild_id: '0000000000',
  emoji_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.emojis.getAll({
  guild_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
name string name of the emoji
image url/buffer the 128x128 emoji image
roles array of snowflakes roles allowed to use this emoji

Example

await api.discord.guilds.emojis.create({
  guild_id: '0000000000',
  name: 'goodsie',
  image: 'https://picofgoodsie.png'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
emoji_id snowflake the id of the emoji
name string name of the emoji
roles array of snowflakes roles allowed to use this emoji

Example

await api.discord.guilds.emojis.update({
  guild_id: '0000000000',
  emoji_id: '0000000000',
  name: 'newemojiname'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
emoji_id snowflake The id of the emoji

Example

await api.discord.guilds.emojis.destroy({
  guild_id: '0000000000',
  emoji_id: '0000000000'
});

Guild Stickers

Method Description
retrieve Get a specific sticker
retrieveGuildSticker Get a specific sticker from a guild
nitroPacks Lists available sticker packs
getAll List all stickers in a guild
create Create a guild sticker
update Update a guild sticker
destroy Delete a guild sticker

Parameters

Field Type Description
sticker_id snowflake The id of the sticker

Example

await api.discord.guilds.stickers.retrieve({
  sticker_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
sticker_id snowflake The id of the sticker

Example

await api.discord.guilds.stickers.retrieveGuild({
  guild_id: '0000000000',
  sticker_id: '0000000000'
});

Example

await api.discord.guilds.stickers.retrieve();

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.stickers.getAll({
  guild_id: '0000000000'
});

This endpoint may take time. It goes through multiple functions before returning the sticker.

Parameters

Field Type Description
guild_id snowflake the id of the guild
name string name of the sticker (2-30 characters)
description string description of the sticker (empty or 2-100 characters)
tags string autocomplete/suggestion tags for the sticker (max 200 characters)
file url/buffer the sticker file to upload

Example

await api.discord.guilds.stickers.create({
  guild_id: '0000000000',
  name: 'mynewsticker',
  description: 'cool description',
  tags: 'uhhh',
  file: 'https://uhhh.gif'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
name string name of the sticker (2-30 characters)
description string description of the sticker (empty or 2-100 characters)
tags string autocomplete/suggestion tags for the sticker (max 200 characters)

Example

await api.discord.guilds.stickers.update({
  guild_id: '0000000000',
  name: 'mynewnewsticker',
  description: 'new cool description',
  tags: 'new uhhh',
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
sticker_id string the id of the sticker

Example

await api.discord.guilds.stickers.destroy({
  guild_id: '0000000000',
  sticker_id: '0000000000',
});

Guild Scheduled Event

Method Description
retrieve Get a specific scheduled event in the guild
getAll List all scheduled events for the guild
getUsers Get users subscribed to a scheduled event
create Create a new scheduled event in the guild
update Modify a guild scheduled event
destroy Delete a guild scheduled event

Parameters

Field Type Description
guild_id snowflake the id of the guild
guild_scheduled_event_id snowflake the id of the event
with_user_count? boolean include number of users subscribed to each event

Example

await api.discord.guilds.events.retrieve({
  guild_id: '0000000000',
  guild_scheduled_event_id: '0000000000',
  with_user_count: true
});

Parameters

Field Type Description
guild_id snowflake the id of the guild
with_user_count? boolean include number of users subscribed to each event

Example

await api.discord.guilds.events.getAll({
  guild_id: '0000000000',
  with_user_count: true
});

Parameters

Field Type Description Default
guild_id snowflake the id of the guild
guild_scheduled_event_id snowflake the id of the event
limit? number number of users to return (up to maximum 100) 100
with_member? boolean include guild member data if it exists false
before? * snowflake consider only users before given user id null
after? * snowflake consider only users after given user id null

* Provide a user id to before and after for pagination. Users will always be returned in ascending order by user_id.

If both before and after are provided, only before is respected. Fetching users in-between before and after is not supported.**

Example

await api.discord.guilds.events.getUsers({
  guild_id: '0000000000',
  guild_scheduled_event_id: '0000000000',
  limit: 10,
  with_member: true
});

Parameters

Field Type Description
guild_id snowflake
channel_id? * ?snowflake Set to null if changing entity type to EXTERNAL
entity_metadata? ** entity metadata The entity metadata of the scheduled event
name string The name of the scheduled event
privacy_level privacy level The privacy level of the scheduled event
scheduled_start_time ISO8601 timestamp The time to schedule the scheduled event
scheduled_end_time? ** ISO8601 timestamp The time when the scheduled event is scheduled to end
description? string The description of the scheduled event
entity_type event entity type The entity type of the scheduled event
image? url/buffer The cover image of the scheduled event

* Optional for events with 'entity_type': EXTERNAL
** Required for events with 'entity_type': EXTERNAL

Example

await api.discord.guilds.events.create({
  guild_id: '0000000000',
  name: 'Cool Event Name',
  privacy_level: 2,
  scheduled_start_time: '2023-04-04T11:00:00',
  entity_type: 2,
  channel_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake
channel_id? * ?snowflake Set to null if changing entity type to EXTERNAL
entity_metadata? ?entity metadata The entity metadata of the scheduled event
name? string The name of the scheduled event
privacy_level? privacy level The privacy level of the scheduled event
scheduled_start_time? ISO8601 timestamp The time to schedule the scheduled event
scheduled_end_time? * ISO8601 timestamp The time when the scheduled event is scheduled to end
description? ?string The description of the scheduled event
entity_type? * event entity type The entity type of the scheduled event
status? event status The status of the scheduled event
image? url/buffer The cover image of the scheduled event

* If updating entity_type to EXTERNAL:

  • channel_id is required and must be set to null
  • entity_metadata with a location field must be provided
  • scheduled_end_time must be provided

Example

await api.discord.guilds.events.update({
  guild_id: '0000000000',
  guild_scheduled_event_id: '0000000000'
  name: 'Edited Event Name',
  status: 2 // ACTIVE
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.guilds.events.destroy({
  guild_id: '0000000000'
});

Guild Templates

Method Description
retrieve Get a guild template by its code
getAll List all templates for a guild
create Create a new template for the guild
createGuild Create a new guild from a template
sync Sync a guild template with the guild's current state
update Modify a guild template
destroy Delete a guild template

Parameters

Field Type Description
template_code snowflake the template's code

Example

await api.discord.guilds.templates.retrieve({
  template_code: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the guild id

Example

await api.discord.guilds.templates.getAll({
  guild_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the guild's id
name string name of the template (1-100 characters)
description? ?string description for the template (0-120 characters)

Example

await api.discord.guilds.templates.create({
  guild_id: '0000000000',
  name: 'fancy template'
});

Parameters

Field Type Description
guild_id snowflake the guild's id
template_code snowflake the template's code
name? string name of the template (1-100 characters)
description? ?string description for the template (0-120 characters)

Example

await api.discord.guilds.templates.update({
  guild_id: '0000000000',
  template_code: '0000000000',
  name: 'new fancy template name'
});

Parameters

Field Type Description
guild_id snowflake the guild id
template_code snowflake the template's code

Example

await api.discord.guilds.templates.destroy({
  guild_id: '0000000000',
  template_code: '0000000000'
});

This endpoint can be used only by bots in less than 10 guilds.

Parameters

Field Type Description
guild_id snowflake the guild's id
template_code snowflake the template's code
name string name of the template (1-100 characters)
icon? url/buffer image url or image buffer for the guild's icon

Example

await api.discord.guilds.templates.createGuild({
  template_code: '0000000000',
  name: 'Eric\'s cool server template',
  icon: 'https://templateGuildIcon.png'
});

Parameters

Field Type Description
guild_id snowflake the guild id
template_code snowflake the template's code

Example

await api.discord.guilds.templates.sync({
  guild_id: '0000000000',
  template_code: '0000000000'
});

Channels

All functions relating to Discord Channels

Method Description
retrieve Get information about a channel in a guild
update update a channel in a guild
destroy Delete a channel in a guild
editPermissions Update the permissions of a channel in a guild
deletePermissions Delete a channels permissions
getInvites Get all invites for a channel
inviteCreate Create a new channel invite
typingCreate Trigger the typing indicator in a channel
followAnnouncementChannel Follow an announcement channel
groupDMadd Add a user to a group DM
groupDMremove Remove a user from a group DM.

Parameters

Field Type Description
channel_id snowflake the id of the channel

Example

await api.discord.channels.retrieve({
  channel_id: '0000000000'
});

Parameters

Field Type Description Channel Type
channel_id snowflake the id of the channel
name string 1-100 character channel name All
type number the type of channel; only conversion between text and announcement is supported and only in guilds with the "NEWS" feature Text, Announcement
position ?number the position of the channel in the left-hand listing All
topic ?string 0-1024 character channel topic (0-4096 characters for GUILD_FORUM and GUILD_MEDIA channels) Text, Announcement, Forum, Media
nsfw ?boolean whether the channel is nsfw Text, Voice, Announcement, Stage, Forum, Media
rate_limit_per_user ?number amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected Text, Voice, Stage, Forum, Media
bitrate* ?number the bitrate (in bits) of the voice or stage channel; min 8000 Voice, Stage
user_limit ?number the user limit of the voice or stage channel, max 99 for voice channels and 10,000 for stage channels (0 refers to no limit) Voice, Stage
permission_overwrites** ?array of partial overwrite objects channel or category-specific permissions All
parent_id ?snowflake id of the new parent category for a channel Text, Voice, Announcement, Stage, Forum, Media
rtc_region ?string channel voice region id, automatic when set to null Voice, Stage
video_quality_mode ?number the camera video quality mode of the voice channel Voice, Stage
default_auto_archive_duration ?number the default duration that the clients use (not the API) for newly created threads in the channel, in minutes, to automatically archive the thread after recent activity Text, Announcement, Forum, Media
flags? number channel flags combined as a bitfield. Currently only REQUIRE_TAG (1 << 4) is supported by GUILD_FORUM and GUILD_MEDIA channels. HIDE_MEDIA_DOWNLOAD_OPTIONS (1 << 15) is supported only by GUILD_MEDIA channels Forum, Media
available_tags? array of tag objects the set of tags that can be used in a GUILD_FORUM or a GUILD_MEDIA channel; limited to 20 Forum, Media
default_reaction_emoji? ?default reaction object the emoji to show in the add reaction button on a thread in a GUILD_FORUM or a GUILD_MEDIA channel Forum, Media
default_thread_rate_limit_per_user? number the initial rate_limit_per_user to set on newly created threads in a channel. this field is copied to the thread at creation time and does not live update. Text, Forum, Media
default_sort_order? ?number the default sort order type used to order posts in GUILD_FORUM and GUILD_MEDIA channels Forum, Media
default_forum_layout? number the default forum layout type used to display posts in GUILD_FORUM channels Forum

* For voice channels, normal servers can set bitrate up to 96000, servers with Boost level 1 can set up to 128000, servers with Boost level 2 can set up to 256000, and servers with Boost level 3 or the VIP_REGIONS guild feature can set up to 384000. For stage channels, bitrate can be set up to 64000.
** In each overwrite object, the allow and deny keys can be omitted or set to null, which both default to "0".

Parameters (Thread)

• When setting archived to false, when locked is also false, only the SEND_MESSAGES permission is required.
• Otherwise, requires the MANAGE_THREADS permission.

Field Type Description
name string 1-100 character channel name
archived boolean whether the thread is archived
auto_archive_duration number the thread will stop showing in the channel list after auto_archive_duration minutes of inactivity, can be set to: 60, 1440, 4320, 10080
locked boolean whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it
invitable boolean whether non-moderators can add other non-moderators to a thread; only available on private threads
rate_limit_per_user ?number amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages, manage_thread, or manage_channel, are unaffected
flags? number channel flags; PINNED can only be set for threads in forum and media channels
applied_tags? array of snowflakes the IDs of the set of tags that have been applied to a thread in a GUILD_FORUM or a GUILD_MEDIA channel; limited to 5

Example

await api.discord.channels.update({
  channel_id: '0000000000',
  name: 'new-name'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel

Example

await api.discord.channels.destroy({
  channel_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
allow? string? the bitwise value of all allowed permissions (default "0")
deny? string? the bitwise value of all disallowed permissions (default "0")
type number 0 for a role or 1 for a member

Example

await api.discord.channels.editPermissions({
  channel_id: '0000000000',
  overwrite_id: '0000000000',
  type: 1, // member
  allow: '1024'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel

Example

await api.discord.channels.deletePermissions({
  channel_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel

Example

await api.discord.channels.getInvites({
  channel_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
uses number number of times this invite has been used
max_uses number max number of times this invite can be used
max_age number duration (in seconds) after which the invite expires
temporary boolean whether this invite only grants temporary membership
created_at ISO8601 timestamp when this invite was created

Example

await api.discord.channels.inviteCreate({
  channel_id: '0000000000',
  max_age: 7200,
  max_uses: 1
});

Parameters

Field Type Description
channel_id snowflake the id of the channel

Example

await api.discord.channels.typingCreate({
  channel_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel to send announcements to
webhook_channel_id snowflake the id of the target channel

Example

await api.discord.channels.followAnnouncementChannel({
  channel_id: '0000000000',
  webhook_channel_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel to send announcements to
user_id snowflake the id of the channel to send announcements to
access_token string access token of a user that has granted your app the gdm.join scope
nick string nickname of the user being added

Example

await api.discord.channels.groupDMadd({
  channel_id: '0000000000',
  user_id: '0000000000',
  access_token: 'abcdef123456',
  nick: 'userNickname'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel to send announcements to
user_id snowflake the id of the user to remove

Example

await api.discord.channels.groupDMremove({
  channel_id: '0000000000',
  user_id: '0000000000'
});

Channel Messages

Method Description
retrieve Retrieve a message with given id
getAll Get all messages in a channel
create Create a new message
update Update a message
destroy Delete a message
bulkDelete Delete multiple messages at a time
crosspost Crosspost a message
pin Pin a message
unpin Unpin a message
getPinned Get all pinned messages in a channel

Parameters

Field Type Description
channel_id snowflake the id of the channel
message_id snowflake the id of the message

Example

await api.discord.channels.messages.retrieve({
  channel_id: '0000000000',
  message_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
around? snowflake Get messages around this message ID
before? snowflake Get messages before this message ID
after? snowflake Get messages after this message ID
limit? number Max number of messages to return (1-100) (default 50)

The before, after, and around parameters are mutually exclusive, only one may be passed at a time.

Example

await api.discord.channels.messages.getAll({
  channel_id: '0000000000',
  limit: 50
});

To create a message as a reply to another message, apps can include a message_reference with a message_id.
• The channel_id and guild_id in the message_reference are optional, but will be validated if provided.

Parameters

Field Type Description
channel_id snowflake Channel id of the channel to send the message to
content?* string Message contents (up to 2000 characters)
tts? boolean true if this is a TTS message
embeds?* array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
message_reference? message reference Include to make your message a reply
components?* array of message component objects Components to include with the message
sticker_ids?* array of snowflakes IDs of up to 3 stickers in the server to send in the message
attachments? array of partial attachment objects Attachment objects with filename and description.
flags? number Message flags (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS can be set)

* At least one of content, embeds, sticker_ids, components, or files[n] is required.

Example

await api.discord.channels.messages.create({
  channel_id: '0000000000',
  content: 'sup'
});

Example

await api.discord.channels.messages.create({
  channel_id: '0000000000',
  content: '',
  embeds: [{
    title: 'embed title',
    description: 'embed description'
  }],
  components: [{
    type: 1,
    components: [{
      type: 2, // button
      style: 1,
      label: 'buttonLabel',
      custom_id: 'asdfghjkl'
    }]
  }]
});

Example

await api.discord.channels.messages.create({
  channel_id: '0000000000',
  content: 'this will surprese all mentions',
  allowed_mentions: {
    parse: []
  }
});

Parameters

Field Type Description
channel_id snowflake the id of the channel the message is in
message_id snowflake the id of the message to edit
content? string Message contents (up to 2000 characters)
embeds? array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
message_reference? message reference Include to make your message a reply
components? array of message component objects Components to include with the message
attachments? array of partial attachment objects Attachment objects with filename and description.
flags? number Message flags (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS can be set)

• When the content field is edited, the mentions array in the message object will be reconstructed from scratch based on the new content.
• The allowed_mentions field of the edit request controls how this happens.
• If there is no explicit allowed_mentions in the edit request, the content will be parsed with default allowances, that is, without regard to whether or not an allowed_mentions was present in the request that originally created the message.
• The attachments array must contain all attachments that should be present after edit, including retained and new attachments.

Example

await api.discord.channels.messages.update({
  channel_id: '0000000000',
  message_id: '0000000000',
  content: 'new message'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
message_id snowflake the id of the message

Example

await api.discord.channels.messages.destroy({
  channel_id: '0000000000',
  message_id: '0000000000'
});

• Any message IDs given that do not exist or are invalid will count towards the minimum and maximum message count (currently 2 and 100 respectively).

This endpoint will not delete messages older than 2 weeks.

Parameters

Field Type Description
channel_id snowflake the id of the channel
messages array of snowflakes an array of message ids to delete (2-100)

Example

await api.discord.channels.messages.bulkDelete({
  channel_id: '0000000000',
  messages: [ 
    '0000000000',
    '0000000000'
  ]
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
message_id snowflake the message id of the message to crosspost

Example

await api.discord.channels.messages.crosspost({
  channel_id: '0000000000',
  message_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
message_id snowflake the message id of the message to pin

Example

await api.discord.channels.messages.pin({
  channel_id: '0000000000',
  message_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
message_id snowflake the message id of the message to unpin

Example

await api.discord.channels.messages.unpin({
  channel_id: '0000000000',
  message_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel

Example

await api.discord.channels.messages.getPinned({
  channel_id: '0000000000'
});

Channel Threads

All functions relating to Discord Threads

Method Description
forumThreadCreate Create a thread in a forum channel
createFromMessage Create a thread from an existing message
createWithoutMessage Create a thread that is not connected to an existing message
join Add current user to a thread
leave Removes current user from a thread
addMember Adds another member to a thread
removeMember Removes another member from a thread
retrieveMember Retrieve information of a thread member
getAllMembers Get all members in a thread
getAllPublicArchived Retrieve threads in a channel that are public
getAllPrivateArchived Retrieve private archived threads in a channel
getAllJoinedPrivateArchived Retrieve private archived threads that the user has joined

Parameters

Field Type Description
channel_id snowflake the id of the channel
name string 1-100 character channel name
auto_archive_duration?* integer duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
rate_limit_per_user? ?integer amount of seconds a user has to wait before sending another message (0-21600)
message forum thread message params object contents of the first message in the forum/media thread
applied_tags? array of snowflakes the IDs of the set of tags that have been applied to a thread in a GUILD_FORUM or a GUILD_MEDIA channel

Example

await api.discord.channels.threads.forumThreadCreate({
  channel_id: '0000000000',
  name: 'thread name',
  message: {
    content: 'new message',
    embeds: [{
      title: 'example',
      description: 'example'
    }]
  },
  auto_archive_duration: 4320
});

• When called on a GUILD_TEXT channel, creates a PUBLIC_THREAD.
• When called on a GUILD_ANNOUNCEMENT channel, creates an ANNOUNCEMENT_THREAD.
• Does not work on a GUILD_FORUM channel.
• The ID of the created thread will be the same as the ID of the source message, and as such a message can only have a single thread created from it.

Parameters

Field Type Description
channel_id snowflake the id of the channel
message_id snowflake the id of the message to create the thread from
name string 1-100 character channel name
auto_archive_duration? number duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
rate_limit_per_user? ?number amount of seconds a user has to wait before sending another message (0-21600)

Example

await api.discord.channels.threads.createFromMessage({
  channel_id: '0000000000',
  message_id: '0000000000',
  name: 'thread name',
  auto_archive_duration: 10080
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
name string 1-100 character channel name
type? * number the type of thread to create
invitable? * boolean whether non-moderators can add other non-moderators to a thread; only available when creating a private thread
rate_limit_per_user? ?number amount of seconds a user has to wait before sending another message (0-21600)

* type currently defaults to PRIVATE_THREAD in order to match the behavior when thread documentation was first published.

Example

await api.discord.channels.threads.createWithoutMessage({
  channel_id: '0000000000',
  type: 11, // PUBLIC_THREAD
  name: 'thread name',
  auto_archive_duration: 10080,
  invitable: true
});

Parameters

Field Type Description
channel_id snowflake the id of the channel

Example

await api.discord.channels.threads.join({
  channel_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel

Example

await api.discord.channels.threads.leave({
  channel_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
user_id snowflake the id of the user to add

Example

await api.discord.channels.threads.addMember({
  channel_id: '0000000000',
  user_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
user_id snowflake the id of the user to add

Example

await api.discord.channels.threads.removeMember({
  channel_id: '0000000000',
  user_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
user_id snowflake the id of the user to add
with_member? boolean whether to include a guild member object

Example

await api.discord.channels.threads.retrieveMember({
  channel_id: '0000000000',
  user_id: '0000000000',
  with_member: true
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
user_id snowflake the id of the user to add
with_member? boolean whether to include a guild member object
after? snowflake Get thread members after this user ID
limit? integer Max number of thread members to return (1-100). Defaults to 100.

Example

await api.discord.channels.threads.getAllMembers({
  channel_id: '0000000000',
  with_member: true
});

• When called on a GUILD_TEXT channel, returns threads of type PUBLIC_THREAD.
• When called on a GUILD_ANNOUNCEMENT channel, returns threads of type ANNOUNCEMENT_THREAD.
• Threads are ordered by archive_timestamp, in descending order.

Parameters

Field Type Description
channel_id snowflake the id of the channel
before? ISO8601 timestamp returns threads archived before this timestamp
limit? integer optional maximum number of threads to return

Example

await api.discord.channels.threads.getAllPublicArchived({
  channel_id: '0000000000',
  limit: 10
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
before? ISO8601 timestamp returns threads archived before this timestamp
limit? integer optional maximum number of threads to return

Example

await api.discord.channels.threads.getAllPrivateArchived({
  channel_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel
before? ISO8601 timestamp returns threads archived before this timestamp
limit? integer optional maximum number of threads to return

Example

await api.discord.channels.threads.getAllJoinedPrivateArchived({
  channel_id: '0000000000'
});

Channel Reactions

Method Description
create Create a reaction for the message
createMany Create multiple reactions to a message at once
deleteOwn Delete a reaction the current user has made for the message
deleteUser Deletes another user's reaction
deleteAll Deletes all reactions on a message
deleteAllEmoji Deletes all the reactions for a given emoji on a message
getUsers Get a list of users that reacted with this emoji

Parameters

| Field | Type | Description | |------------------------|-------------------------| | channel_id | snowflake | the id of the channel | | message_id | snowflake | the id of the message | | emoji | string | the emoji to react with |

Example

await api.discord.channels.reactions.create({
  channel_id: '0000000000',
  message_id: '0000000000',
  emoji: 'name:id'
});

Parameters

| Field | Type | Description | |------------------------|--------------------------------------------------------------------------------------------------| | channel_id | snowflake | The id of the channel | | message_id | snowflake | The id of the message | | emojis | string[] | An array of emoji parameters | | delay? | number | Amount of millseconds to wait between reactions. For use when getting rate-limited. Default 300. |

Example

await api.discord.channels.reactions.createMany({
  channel_id: '0000000000',
  message_id: '0000000000',
  emojis: [
    'name:id:',
    'name:id:',
    'name:id:'
  ],
  delay: 200
});

Parameters

| Field | Type | Description | |------------------------|-------------------------| | channel_id | snowflake | the id of the channel | | message_id | snowflake | the id of the message | | emoji | string | the emoji to react with |

Example

await api.discord.channels.reactions.deleteOwn({
  channel_id: '0000000000',
  message_id: '0000000000',
  emoji: 'name:id'
});

Parameters

| Field | Type | Description | |------------------------|-----------------------------------------| | channel_id | snowflake | the id of the channel | | message_id | snowflake | the id of the message | | user_id | snowflake | the id the user the reaction belongs to | | emoji | string | the emoji to react with |

Example

await api.discord.channels.reactions.deleteUser({
  channel_id: '0000000000',
  message_id: '0000000000',
  user_id: '0000000000',
  emoji: 'name:id'
});

Parameters

| Field | Type | Description | |------------------------|-------------------------| | channel_id | snowflake | the id of the channel | | message_id | snowflake | the id of the message |

Example

await api.discord.channels.reactions.deleteAll({
  channel_id: '0000000000',
  message_id: '0000000000'
});

Parameters

| Field | Type | Description | |------------------------|-------------------------| | channel_id | snowflake | the id of the channel | | message_id | snowflake | the id of the message | | emoji | string | the emoji to delete |

Example

await api.discord.channels.reactions.deleteAllEmoji({
  channel_id: '0000000000',
  message_id: '0000000000',
  emoji: ':name:id'
});

Parameters

| Field | Type | Description | |------------------------|----------------------------------------------------| | channel_id | snowflake | the id of the channel | | message_id | snowflake | the id of the message | | emoji | string | the emoji to get users for | | after? | snowflake | Get users after this user ID | | limit? | integer | Max number of users to return (1-100) (default 25) |

Example

await api.discord.channels.reactions.getUsers({
  channel_id: '0000000000',
  message_id: '0000000000',
  emoji: ':name:id',
  limit: 50
});

Users

All functions relating to Discord Users

Endpoints

Method Description
retrieve Get user object for given user id
currentUser Get user object of requester's account
myGuilds Get a list of partial guild objects the current user is a member of
currentMember Get guild member object for the current user
updateCurrent Modify the requester's user account settings
connections Get a list of the user's connections
appRoleConnection Get user's application role connection object
updateAppRoleConnection Updates the user's application role connection
createDM Create a new DM channel with a user
createGroupDM Create a new group DM channel with multiple users
leaveGuild Leave a guild

Parameters

Field Type Description
user_id snowflake the id of the user

Example

await api.discord.users.retrieve({
  user_id: '0000000000'
});

Example

await api.discord.users.currentUser();

Parameters

Field Type Description
before snowflake get guilds before this guild ID
after snowflake get guilds after this guild ID
limit integer max number of guilds to return (1-200) (default 200)
with_counts boolean include approximate member and presence counts in response

Example

await api.discord.users.myGuilds();

Parameters

Field Type Description
guild_id snowflake id of the guild to get member object from

Example

await api.discord.users.currentMember({
  guild_id: '0000000000',
});

All parameters to this endpoint are optional.

Field Type Description
username string user's username
avatar url/buffer if passed, modifies the user's avatar

Example

await api.discord.users.updateCurrent({
  username: 'new username',
  avatar: 'https://imageURL.png'
});

Example

await api.discord.users.connections();

Parameters

Field Type Description
application_id? snowflake bot's application id

Example

await api.discord.users.appRoleConnection();

Requires an OAuth2 access token with role_connections.write scope for the application specified in the path.

Parameters

Field Type Description
platform_name? string the vanity name of the platform a bot has connected (max 50 characters)
platform_username? string the username on the platform a bot has connected (max 100 characters)
metadata? object object mapping application role connection metadata keys to their string-ified value (max 100 characters) for the user on the platform a bot has connected

Example

await api.discord.users.updateAppRoleConnection({
  platform_name: 'OnSocket',
  platform_username: 'goodsie'
});

Parameters

Field Type Description
recipient_id snowflake the recipient to open a DM channel with
content?* string Message contents (up to 2000 characters)
tts? boolean true if this is a TTS message
embeds?* array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
message_reference? message reference Include to make your message a reply
components?* array of message component objects Components to include with the message
sticker_ids?* array of snowflakes IDs of up to 3 stickers in the server to send in the message
attachments? array of partial attachment objects Attachment objects with filename and description.
flags? integer Message flags (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS can be set)

* At least one of content, embeds, sticker_ids, components, or files[n] is required.

Example

await api.discord.users.createDM({
  recipient_id: '0000000000',
  content: '<super cool message here>'
});

Parameters

Field Type Description
access_tokens array of strings access tokens of users that have granted your app the gdm.join scope
nicks dict a dictionary of user ids to their respective nicknames
content?* string Message contents (up to 2000 characters)
tts? boolean true if this is a TTS message
embeds?* array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
message_reference? message reference Include to make your message a reply
components?* array of message component objects Components to include with the message
sticker_ids?* array of snowflakes IDs of up to 3 stickers in the server to send in the message
attachments? array of partial attachment objects Attachment objects with filename and description.
flags? integer Message flags (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS can be set)

* At least one of content, embeds, sticker_ids, components, or files[n] is required.

Example

await api.discord.users.createGroupDM({
  access_tokens: [
    '0000000000',
    '0000000000'  
  ],
  nicks: {
    'user_id': 'nickname'
  },
  content: 'boo',
});

Parameters

Field Type Description
guild_id snowflake the id of the guild to leave

Example

await api.discord.users.leaveGuild({
  guild_id: '0000000000'
});

Interactions

Namespaces

| Namespace | | Callback | | Followup |

Interactions Callback

Endpoints

Method Description
reply Create a response to an Interaction
defer Send "thinking" state and edit response later
get_original Get the initial Interaction response
update_original Edit the initial Interaction response
delete_original Delete the initial Interaction response
component_defer* Acknowledge an interaction and edit response later
component_update* Edit the message the component was attached to
autocomplete_reply Respond to an autocomplete interaction with suggested choices
modal_reply** Respond to an interaction with a popup modal
upgrade*** Respond to an interaction with an upgrade button

* Only valid for component-based interactions.
** Not available for MODAL_SUBMIT and PING interactions.
*** Only available for apps with monetization enabled.

Parameters

Field Type Description
params object The interaction payload
ephemeral? boolean Whether the message should be visible to only the user
content?* string Message contents (up to 2000 characters)
tts? boolean true if this is a TTS message
embeds?* array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
components?* array of message component objects Components to include with the message
attachments? array of partial attachment objects Attachment objects with filename and description

* At least one of content, embeds, sticker_ids, components, or files[n] is required.

Example

await api.discord.interactions.callback.reply(params, {
  ephemeral: true,
  content: 'This will respond to an interaction immediately'
});

Defer Interaction Response

Parameters

Field Type Description
params object The interaction payload
ephemeral? boolean Whether the message should be visible to only the user

Example

await api.discord.interactions.callback.defer(params, {
  ephemeral: true
});

Example

await api.discord.interactions.callback.defer(params)

Parameters

Field Type Description
params object The interaction payload

Example

await api.discord.interactions.callback.get_original(params);

Parameters

Field Type Description
params object The interaction payload
content?* string Message contents (up to 2000 characters)
embeds?* array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
components?* array of message component objects Components to include with the message
attachments? array of partial attachment objects Attachment objects with filename and description

Example

await api.discord.interactions.callback.update_original(params, {
  content: 'This will update the original interaction response'
});

Parameters

Field Type Description
params object The interaction payload

Example

await api.discord.interactions.callback.delete_original(params);

Component Defer

Parameters

Field Type Description
params object The interaction payload

Example

await api.discord.interactions.callback.component_defer(params);

Component Update

Parameters

Field Type Description
params object The interaction payload
content?* string Message contents (up to 2000 characters)
embeds?* array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
components?* array of message component objects Components to include with the message
attachments? array of partial attachment objects Attachment objects with filename and description

Example

await api.discord.interactions.callback.component_update(params, {
  content: 'new stuff!'
});

Autocomplete Reply

Parameters

Field Type Description
params object The interaction payload
choices array of choices Autocomplete Choices (max of 25 choices)

Example

await api.discord.interactions.callback.autocomplete_reply(params, {
  choices: [
    {
      name: 'this might be wrong',
      value: 'let me know'
    }
  ]
});

Modal Reply

Parameters

Field Type Description
custom_id string a developer-defined identifier for the modal, max 100 characters
title string the title of the popup modal, max 45 characters
components array of components between 1 and 5 (inclusive) components that make up the modal

Example

await callback.modal_reply(params, {
  custom_id: 'modal_id',
  title: 'Title goes here',
  components: [
    {
      type: 4,
      custom_id: 'id_1',
      label: 'this is a label',
      style: 1, // short
      placeholder: 'this is a placeholder',
      required: true
    },
    {
      type: 4,
      custom_id: 'id_2',
      label: 'This is another label',
      style: 1, // paragraph
      value: 'this is a pre-filled value',
      required: false
    }
  ]
});

Interactions Followup

Endpoints

Method Description
retrieve Get a followupmessage for an interaction
create Create a followup message for an interaction
update Edit a followup message for an interaction
destroy Delete a followup message for an interaction

Parameters

Field Type Description
params object The interaction payload
message_id snowflake The message id of the message to retrieve

Example

await api.discord.interactions.followup.retrieve(params, {
  message_id: '0000000000'  
});

Parameters

Field Type Description
params object The interaction payload
ephemeral? boolean Whether the message should be visible to only the user
content?* string Message contents (up to 2000 characters)
embeds?* array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
components?* array of message component objects Components to include with the message
attachments? array of partial attachment objects Attachment objects with filename and description

* At least one of content, embeds, sticker_ids, components, or files[n] is required.

Example

await api.discord.interactions.followup.create(params, {
  ephemeral: true,
  content: 'followup message',
  embeds: [{
     title: 'hello',
     description: 'this is a description'
  }]
});

Parameters

Field Type Description
params object The interaction payload
message_id snowflake The id of the message to update
content?* string Message contents (up to 2000 characters)
embeds?* array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
components?* array of message component objects Components to include with the message
attachments? array of partial attachment objects Attachment objects with filename and description

* At least one of content, embeds, sticker_ids, components, or files[n] is required.

Example

await api.discord.interactions.followup.update(params, {
  message_id: '0000000000',
  content: 'followup message',
  embeds: [{
     title: 'hello',
     description: 'this is a description'
  }]
});

Parameters

Field Type Description
params object The interaction payload
message_id snowflake The message id of the message to retrieve

Example

await api.discord.interactions.followup.destroy(params, {
  message_id: '0000000000'  
});

Webhooks

All functions relating to Discord Webhooks

Methods

Method Description
retrieve Get information about a webhook
retrieveWithToken Get information about a webhook using its token
retrieveChannel Get all channel webhooks
retrieveGuild Get all guild webhooks
retrieveMessage Get a previously-sent webhook message from the same token
destroyMessage Deletes a message that was created by the webhook
create Creates a new webhook
update Updates an existing webhook
updateWithToken Follow an announcement channel
destroy Delete a webhook permanently
destroyWithToken Delete a webhook permanently using its token
execute Executes a webhook
updateMessage Edits a previously-sent webhook message from the same token

Parameters

Field Type Description
webhook_id snowflake the id of the webhook

Example

await api.discord.webhooks.retrieve({
  webhook_id: '0000000000'
});

This call does not require authentication and returns no user in the webhook object.

Parameters

Field Type Description
webhook_id snowflake the id of the webhook
webhook_token string the webhook's token

Example

await api.discord.webhooks.retrieveWithToken({
  webhook_id: '0000000000',
  webhook_token: 'abcdef123456'
});

Parameters

Field Type Description
channel_id snowflake the id of the channel

Example

await api.discord.webhooks.retrieveChannel({
  webhook_id: '0000000000'
});

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.webhooks.retrieveGuild({
  guild_id: '0000000000'
});

Parameters

Field Type Description
webhook_id snowflake the id of the webhook
webhook_token snowflake the webhook's token
message_id snowflake the id of the message
thread_id snowflake id of the thread the message is in

Example

await api.discord.webhooks.retrieveMessage({
  webhook_id: '0000000000',
  webhook_token: 'abcdef123456',
  message_id: '0000000000'
});

Parameters

Field Type Description
webhook_id snowflake the id of the webhook
webhook_token snowflake the webhook's token
message_id snowflake the id of the message
thread_id snowflake id of the thread the message is in
content? string Message contents (up to 2000 characters)
embeds? array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions? allowed mention object Allowed mentions for the message
components? array of message component objects Components to include with the message
attachments? array of partial attachment objects Attachment objects with filename and description

Example

await api.discord.webhooks.updateMessage({
  webhook_id: '0000000000',
  webhook_token: 'abcdef123456',
  message_id: '0000000000',
  content: 'hello'
});

Parameters

Field Type Description
webhook_id snowflake the id of the webhook
webhook_token snowflake the webhook's token
message_id snowflake the id of the message
thread_id snowflake id of the thread the message is in

Example

await api.discord.webhooks.destroyMessage({
  webhook_id: '0000000000',
  webhook_token: 'abcdef123456',
  message_id: '0000000000'
});

Parameters

Field Type Description
channel_id? snowflake the channel id of the channel to create webhook for
name? string name of the webhook (1-80 characters)
avatar? ?url/buffer image for the default webhook avatar

Example

await api.discord.webhooks.create({
  channel_id: '0000000000',
  name: 'myNewWebhook'
});

Parameters

Field Type Description
webhook_id snowflake the webhook id of the webhook to edit
channel_id snowflake the channel id of the channel to create webhook for
name string name of the webhook (1-80 characters)
avatar? ?url/buffer image for the default webhook avatar

Example

await api.discord.webhooks.update({
  webhook_id: '0000000000',
  channel_id: '0000000000',
  name: 'myNewNewWebhook'
});

Parameters

Field Type Description
webhook_id snowflake the webhook id of the webhook to edit
webhook_token string the token of the webhook to edit
name? string name of the webhook (1-80 characters)
avatar? ?url/buffer image for the default webhook avatar

Example

await api.discord.webhooks.updateWithToken({
  webhook_id: '0000000000',
  webhook_token: 'abcd1234',
  name: 'myNewNewWebhook'
});

Parameters

Field Type Description
webhook_id snowflake the id of the webhook

Example

await api.discord.webhooks.destroy({
  webhook_id: '0000000000'
});

Parameters

Field Type Description
webhook_id snowflake the id of the webhook
webhook_token string the webhook's token

Example

await api.discord.webhooks.destroyWithToken({
  webhook_id: '0000000000',
  webhook_token: 'abcdef123456'
});

Parameters

Field Type Description
webhook_id snowflake the id of the webhook
webhook_token snowflake the webhook's token
username string override the default username of the webhook
avatar_url string override the default avatar of the webhook
thread_id snowflake id of the thread the message is in
content string Message contents (up to 2000 characters)
embeds array of embed objects Up to 10 rich embeds (up to 6000 characters)
allowed_mentions allowed mention object Allowed mentions for the message
components array of message component objects Components to include with the message
attachments array of partial attachment objects Attachment objects with filename and description
thread_name string name of thread to create (requires the webhook channel to be a forum or media channel)
applied_tags array of snowflakes array of tag ids to apply to the thread (requires the webhook channel to be a forum or media channel)
wait boolean Waits for server confirmation of message send before response, and returns the created message body

Example

await api.discord.webhooks.execute({
  webhook_id: '0000000000',
  webhook_token: 'abcdef123456',
  content: 'message contents here',
  username: 'webhook usernrame',
  avatar_url: 'https://imgurl.png',
  embeds: [{
    title: 'example',
    description: 'example'
  }]
});

Invites

All functions relating to Discord Invites

Method Description
retrieve Get information about a specific invite
revoke Revoke an invite

Parameters

Field Type Description
invite_code string the invite's code
with_counts? boolean whether the invite should contain approximate member counts
with_expiration? boolean whether the invite should contain the expiration date
guild_scheduled_event_id? snowflake the guild scheduled event to include with the invite

Example

await api.discord.invites.retrieve({
  invite_code: '0vCdhLbwjZZTWZLD',
  with_counts: true,
  with_expiration: true
});

Parameters

| Field | Type | Description | | invite_code | string | the invite's code |

Example

await api.discord.invites.revoke({
  invite_code: '0vCdhLbwjZZTWZLD'
});

Applications

All Discord API endpoints relating to applications, commands, entitlements and SKUs

Method Description
getMe Get inforation on the current application
updateMe Edit properties of the app associated with the requesting bot user
appRoleConnectionMeta Get the applications role connection metadata information
updateAppRoleConnectionMeta Updates the application role connection metadata for the given application

Parameters

Field Type Description
application_id? snowflake the id of the application

Example

await api.discord.applications.getMe();

Parameters

Field Type Description
application_id? snowflake the id of the application
custom_install_url string Default custom authorization URL for the app, if enabled
description string Description of the app
role_connections_verification_url string Role connection verification URL for the app
install_params install params object Settings for the app's default in-app authorization link, if enabled
flags * number App's public flags
icon url/buffer Icon for the app
cover_image url/buffer Default rich presence invite cover image for the app
interactions_endpoint_url ** string Interactions endpoint URL for the app
tags array of strings List of tags describing the content and functionality of the app (max of 20 characters per tag). Max of 5 tags.

* Only limited intent flags (GATEWAY_PRESENCE_LIMITED, GATEWAY_GUILD_MEMBERS_LIMITED, and GATEWAY_MESSAGE_CONTENT_LIMITED) can be updated via the API.

Example

await api.discord.applications.updateMe({
  description: 'new description',
  icon: 'https://url_to_image.png' // or buffer,
  install_params: {
    scopes: [
      'identify',
      'bot',
      'applications.commands'
    ],
    permissions: '8'
  }
});

Parameters

Field Type Description
application_id? snowflake the id of the application

Example

await api.discord.applications.appRoleConnectionMeta();

Parameters

Field Type Description
application_id? snowflake the id of the application

Example

await api.discord.applications.updateAppRoleConnectionMeta();

Application Commands

Method Description
retrieve Get an application command
getAll Get all application commands
create Create a new application command
update Update an application command
destroy Delete an application command
bulkOverwrite Bulk overwrite application commands
retrievePermissions Get a guild commands permissions
getAllPermissions Get permissions for all commands in a guild
updatePermissions Update a guild's application command

This is to be used for both global and guild commands.
Provide a guild_id field if using for a guild command.

Parameters

Field Type Description
command_id snowflake the id of the command
application_id? snowflake the id of the application
guild_id? snowflake the id of the guild

Example

await api.discord.applications.commands.retrieve({
  command_id: '0000000000',
  guild_id: '0000000000'
})

This is to be used for both global and guild commands.
Provide a guild_id field if using for a guild command.

Parameters

Field Type Description
application_id? snowflake the id of the application
guild_id? snowflake the id of the guild
with_localizations? boolean Whether to include full localization dictionaries (name_localizations and description_localizations) in the returned objects, instead of the name_localized and description_localized fields.

Example

await api.discord.applications.commands.getAll();

Example

await api.discord.applications.commands.getAll({
  guild_id: '0000000000'
})

This is to be used for both global and guild commands.
Provide a guild_id field if using for a guild command.

Parameters

Field Type Description
application_id? snowflake the id of the application
guild_id? snowflake the id of the guild
name string Name of command, 1-32 characters
name_localizations? ?dictionary with keys in available locales Localization dictionary for the name field. Values follow the same restrictions as name
description? string 1-100 character description for CHAT_INPUT commands
description_localizations? ?dictionary with keys in available locales Localization dictionary for the description field. Values follow the same restrictions as description
options? array of application command option the parameters for the command
default_member_permissions? ?string Set of permissions represented as a bit set
dm_permission? ?boolean Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible.
type? one of application command type Type of command, defaults 1 if not set
nsfw? boolean Indicates whether the command is age-restricted

Example

await api.discord.applications.commands.create({
  name: 'slashcommand',
  description: 'Command description',
  guild_id: '0000000000', // optional
  options: [{
    type: 1, // SUB_COMMAND
    name: 'subCommand',
    options: [
      {
        type: 3, // STRING
        name: 'content',
        description: 'Enter content here',
        required: true
      },
      {
        type: 6, // USER
        name: 'user',
        description: 'Select a user'
      }
    ]
  }]
})

This is to be used for both global and guild commands.
Provide a guild_id field if using for a guild command.

Parameters

Field Type Description
application_id? snowflake the id of the application
guild_id? snowflake the id of the guild
name string Name of command, 1-32 characters
name_localizations? ?dictionary with keys in available locales Localization dictionary for the name field. Values follow the same restrictions as name
description? string 1-100 character description for CHAT_INPUT commands
description_localizations? ?dictionary with keys in available locales Localization dictionary for the description field. Values follow the same restrictions as description
options? array of application command option the parameters for the command
default_member_permissions? ?string Set of permissions represented as a bit set
dm_permission? ?boolean Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible.
nsfw? boolean Indicates whether the command is age-restricted

Example

await api.discord.applications.commands.update({
  name: 'slashcommand',
  description: 'Command description',
  guild_id: '0000000000', // optional
  options: [{
    type: 1, // SUB_COMMAND
    name: 'subCommand',
    options: [
      {
        type: 3, // STRING
        name: 'content',
        description: 'Enter content here',
        required: true
      },
      {
        type: 6, // USER
        name: 'user',
        description: 'Select a user'
      }
    ]
  }]
})

This is to be used for both global and guild commands.
Provide a guild_id field if using for a guild command.

Parameters

Field Type Description
command_id snowflake the id of the command
application_id? snowflake the id of the application
guild_id? snowflake the id of the guild

Example

await api.discord.applications.commands.destroy({
  command_id: '0000000000',
  guild_id: '0000000000'
})

This is to be used for both global and guild commands.
Provide a guild_id field if using for a guild command.
• Takes a list of application commands, overwriting the existing global command list for this application.

Parameters

Field Type Description
application_id? snowflake the id of the application
guild_id? snowflake the id of the guild
commands array of application commands Commands to overwrite the existing commands with

Example

await api.discord.applications.commands.bulkOverwrite({
  command_id: '0000000000',
  guild_id: '0000000000',
  commands: [commands]
})

• Fetches permissions for a specific command for your application in a guild.

Parameters

Field Type Description
command_id snowflake the id of the command
application_id? snowflake the id of the application
guild_id snowflake the id of the guild

Example

await api.discord.applications.commands.retrievePermissions({
  command_id: '0000000000',
  guild_id: '0000000000'
})

• Fetches permissions for all commands for your application in a guild.

Parameters

Field Type Description
application_id? snowflake the id of the application
guild_id snowflake the id of the guild

Example

await api.discord.applications.commands.getAllPermissions({
  guild_id: '0000000000'
})

• Edits command permissions for a specific command for your application in a guild.

Parameters

Field Type Description
application_id? snowflake the id of the application
guild_id snowflake the id of the guild
permissions array of application command permissions Permissions for the command in the guild

Example

await api.discord.applications.commands.updatePermissions({
  guild_id: '0000000000',
  permissions: [{
    id: '0000000000',
    type: 2,
    'true'
  }]
})

Application Entitlements

Method Description
getAll Get all entitlements for a given app
create Creates a test entitlement to a given SKU for a given guild or user
destroy Deletes a currently-active test entitlement

• Returns all entitlements for a given app, active and expired.

Parameters

Field Type Description
application_id? snowflake the id of the application
user_id? snowflake User ID to look up entitlements for
sku_ids? comma-delimited set of snowflakes Optional list of SKU IDs to check entitlements for
before? snowflake Retrieve entitlements before this entitlement ID
after? snowflake Retrieve entitlements after this entitlement ID
limit? number Number of entitlements to return, 1-100, default 100
guild_id? snowflake Guild ID to look up entitlements for
exclude_ended? boolean Whether or not ended entitlements should be omitted

Example

await api.discord.applications.entitlements.retrieve({
  user_id: '0000000000',
  before: '0000000000',
  after: '0000000000',
  limit: 2
})

• Creates a test entitlement to a given SKU for a given guild or user. Discord will act as though that user or guild has entitlement to your premium offering.
• This endpoint returns a partial entitlement object. It will not contain subscription_id, starts_at, or ends_at, as it's valid in perpetuity.
• After creating a test entitlement, you'll need to reload your Discord client. After doing so, you'll see that your server or user now has premium access.

Parameters

Field Type Description
application_id? snowflake the id of the application
sku_id string ID of the SKU to grant the entitlement to
owner_id string ID of the guild or user to grant the entitlement to
owner_type number 1 for a guild subscription, 2 for a user subscription

Example

await api.discord.applications.entitlements.create({
  sku_id: '0000000000',
  owner_id: '0000000000',
  owner_type: 1
})

• Deletes a currently-active test entitlement. Discord will act as though that user or guild no longer has entitlement to your premium offering.

Parameters

Field Type Description
application_id? snowflake the id of the application

Example

await api.discord.applications.entitlements.delete()

Application SKUs

Method Description
getAll Get all SKUs for a given application

• Because of how our SKU and subscription systems work, you will see two SKUs for your premium offering. For integration and testing entitlements, you should use the SKU with type: 5.

Parameters

Field Type Description
application_id? snowflake the id of the application

Example

await api.discord.applications.SKUs.getAll();

Audit Logs

Method Description
retrieve Get the audit logs for the guild

The returned list of audit log entries is ordered based on whether you use before or after.
When using before, the list is ordered by the audit log entry ID descending (newer entries first).
If after is used, the list is reversed and appears in ascending order (older entries first).
Omitting both before and after defaults to before the current timestamp and will show the most recent entries in descending order by ID, the opposite can be achieved using after=0 (showing oldest entries).

Parameters

Field Type Description
guild_id snowflake the id of the application
user_id? snowflake Entries from a specific user ID
action_type? number Entries for a specific audit log event
before? snowflake Entries with ID less than a specific audit log entry ID
after? snowflake Entries with ID greater than a specific audit log entry ID
limit? number Maximum number of entries (between 1-100) to return, defaults to 50

Example

await api.discord.auditlog.retrieve({
  guild_id: '0000000000',
  user_id: '0000000000',
  limit: 10 // default 50
});

Auto Moderation

Method Description
retrieveRule Get an auto moderation rule
getAllRules Get all auto moderation rules
createRule Create a new auto moderation rule
updateRule Update an auto moderation rule
destroyRule Delete an auto moderation rule

Parameters

Field Type Description
guild_id snowflake the id of the guild
auto_moderation_rule_id snowflake the id of the automod rule

Example

await api.discord.automod.retrieveRule({
  auto_moderation_rule_id: '0000000000',
  guild_id: '0000000000'
})

Parameters

Field Type Description
guild_id snowflake the id of the guild

Example

await api.discord.automod.getAll({
  guild_id: '0000000000'
})

Parameters

Field Type Description
guild_id snowflake the id of the guild
name string the rule name
event_type integer the event type
trigger_type integer the trigger type
trigger_metadata? * object the trigger metadata
actions array of action objects the actions which will execute when the rule is triggered
enabled? boolean whether the rule is enabled (False by default)
exempt_roles? array of snowflakes the role ids that should not be affected by the rule (Max 20)
exempt_channels? array of snowflakes the channel ids that should not be affected by the rule (Max 50)

Example

await api.discord.automod.createRule({
  guild_id: '0000000000',
  name: 'EricsAutoModRule',
  event_type: 1 // MESSAGE_SEND
  trigger_type: 3 // SPAM
  actions: [{
    type: 2, // SEND_ALERT_MESSAGE
    metadata: { channel_id: '0000000000' }
  }],
  enabled: true,
  exempt_roles: ['0000000000'],
  exempt_channels: ['0000000000']
})

Parameters

Field Type Description
guild_id snowflake the id of the guild
name string the rule name
event_type integer the event type
trigger_metadata? * object the trigger metadata
actions array of action objects the actions which will execute when the rule is triggered
enabled? boolean whether the rule is enabled (False by default)
exempt_roles? array of snowflakes the role ids that should not be affected by the rule (Max 20)
exempt_channels? array of snowflakes the channel ids that should not be affected by the rule (Max 50)

Example

await api.discord.automod.updateRule({
  guild_id: '0000000000',
  auto_moderation_rule_id: '00000',
   name: 'EricsAutoModRule',
   event_type: 1 // MESSAGE_SEND
   actions: [{
     type: 1, // BLOCK_MESSAGE
     metadata: { custom_message: 'GO AWAY' }
   }],
   trigger_metadata: {
     keyword_filter: ['cat*', '*dog'],
     regex_patterns: ['^(?:[0-9]{1,3}\\.){3}[0-9]{1,3}$']
   },
   enabled: true
})

Parameters

Field Type Description
guild_id snowflake the id of the guild
auto_moderation_rule_id snowflake the id of the automod rule

Example

await api.discord.automod.destroyRule({
  auto_moderation_rule_id: '0000000000',
  guild_id: '0000000000'
})

Stage Instance

A Stage Instance holds information about a live stage.

Endpoints

Method Description
retrieve Gets the stage instance associated with the Stage channel
create Creates a new Stage instance associated to a Stage channel
update Updates fields of an existing Stage instance
destroy Deletes the Stage instance

Parameters

Field Type Description
channel_id snowflake the id of the channel that the stage instance is in

Example

await api.discord.stageInstance.retrieve({
  channel_id: '0000000000'
});

Parameters

Field Type Description
channel_id snowflake The id of the Stage channel
topic string The topic of the Stage instance (1-120 characters)
privacy_level? integer The privacy level of the Stage instance (default GUILD_ONLY)
send_start_notification? * boolean Notify @everyone that a Stage instance has started
guild_scheduled_event_id? snowflake The guild scheduled event associated with this Stage instance

* The stage moderator must have the MENTION_EVERYONE permission for this notification to be sent.

Example

await api.discord.stageInstance.create({
  channel_id: '0000000000',
  topic: 'My super cool stage',
  send_start_notification: true
});

Parameters

Field Type Description
channel_id snowflake The id of the Stage channel
topic? string The topic of the Stage instance (1-120 characters)
privacy_level? integer The privacy level of the Stage instance (default GUILD_ONLY)

Example

await api.discord.stageInstance.update({
  channel_id: '0000000000',
  topic: 'My super duper cool stage',
});

Parameters

Field Type Description
channel_id snowflake the id of the channel that the stage instance is in

Example

await api.discord.stageInstance.destroy({
  channel_id: '0000000000'
});

OpenAI


Chat

Methods

Method Description
create Creat a chat completion

Parameters

Field Type Description
model string ID of the model to use
messages ChatCompletionMessage[] A list of messages comprising the conversation so far
max_tokens? number The maximum number of tokens that can be generated in the chat completion
temperature? number What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
top_p? number An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.
frequency_penalty? number Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
presence_penalty? number Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
n? number How many chat completion choices to generate for each input message
response_format? string An object specifying the format that the model must output. Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON.
seed? number This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.
stop? string Up to 4 sequences where the API will stop generating further tokens
logit_bias? Object Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100.
logprobs? boolean Whether to return log probabilities of the output tokens or not
top_logprobs? number An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, each with an associated log probability
stream? boolean If set, partial message deltas will be sent, like in ChatGPT.
tools? ToolCalls[] A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for.
tool_choice? ToolChoice Controls which (if any) function is called by the model. See tool_choice
user? string A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse

Example

await api.openai.chat.create({
  model: 'gpt-4',
  messages: [
    {
      role: 'system',
      content: 'You are a chatbot'
    },
    {
      role: 'user',
      content: 'hello!'
    }
  ],
  max_tokens: 1024,
  temperature: 0.7
});

Spotify

Many of the Spotify endpoints are designed for the input of a specific Spotify ID.

However, I have also incorporated the functionality to accept names.
Each endpoint includes options for both the ID* and the name**.
Utilizing a specific ID ensures the retrieval of the correct item.
On the other hand, providing a name might result in incorrect items depending on the uniqueness of the name.

* song_id(s), artist_id(s), album_id(s), playlist_id(s)
** song_name(s), artist_name(s), album_name(s), playlist_name(s)


Users

Methods

Method Description
me Get detailed profile information about the current user
topItems Get the current user's top artists or tracks
getProfile Get public profile information about a Spotify user

Example

await api.spotify.users.me();

Parameters

Field Type Description
type string The type of entity to return (artists or tracks)
time_range? * string Over what time frame the affinities are computed (default medium_term)
limit? number The maximum number of results to return
offset? number The index of the first result to return. Use with limit to get the next page of search results.

* Valid values for time_range:

  • long_term: calculated from several years of data and including all new data as it becomes available
  • medium_term: approximately last 6 months
  • short_term: approximately last 4 weeks

Example

await api.spotify.users.topItems({
  type: 'tracks',
  time_range: 'long_term',
  limit: 10
});

Parameters

Field Type Description
user_id string The user's Spotify user ID

Example

await api.spotify.users.getProfile({
  user_id: 'smedjan'
});

Search

Methods

Method Description
advanced Extensive search for songs, artists, albums
artists Search for artists
songs Search for songs
albums Search for albums

Parameters

Field Type Description
song? * string Song name to search for
artist? * string Artist name to search for
album? * string Album name to search for
include? string[] Type of results to include. One or more of songs, artists, albums.
limit? number The maximum number of results to return
offset? number The index of the first result to return. Use with limit to get the next page of search results.
sort? string Sort results by: popularity, followers, or duration_seconds
year? string Filter on a single year or a range (e.g. 1955-1960)
genre? string Filter on a single genre

* At least one of song, artist, album is required.

Example 1

await api.spotify.search.advanced({
  song: 'oops i did it again',
  year: '1990-1995',
  limit: 1
});

Example 2

await api.spotify.search.advanced({
  song: 'some popular song name',
  limit: 10,
  sort: 'popularity'
});

Example 3

await api.spotify.search.advanced({
  album: 'your favorite album name',
  include: ['albums'],
});

Parameters

Field Type Description
artist string Artist name to search for
limit? number The maximum number of results to return
offset? number The index of the first result to return. Use with limit to get the next page of search results.
sort? string Sort results by: popularity or followers

Example 1

await 

Package Sidebar

Install

npm i mapih

Weekly Downloads

152

Version

3.13.2

License

MIT

Unpacked Size

2.08 MB

Total Files

241

Last publish

Collaborators

  • goodsie
  • lostmyinfo