detritus

Clientclass

The REST client: one method per Discord endpoint, with automatic ratelimit handling. Methods resolve with the raw JSON Discord sends back.

On this page
import { Client } from 'detritus-client-rest';
EventEmitterEventSpewerClient
20 properties366 methodssrc/client.ts:85

Constructor

Properties

authType
Default AuthTypes.BOT
buckets
BucketCollection
readonly
clientsideChecks
boolean
Default true
errorOnRatelimit
boolean
Default false
errorOnRatelimitIfMoreThan
number
Default 0
fingerprint?
string
optional
globalBucket
Bucket
haltOnUnauthorized
boolean
Default false
invalidRequests
number[]
Default []
invalidRequestsWarned
boolean
Default false
restClient
routes
BaseCollection<string, string>
readonly
token?
string
optional
tokenUnauthorized
boolean
Default false

Accessors

authTypeText
string
get
invalidRequestCount
number
get
isBearer
boolean
get
isBot
boolean
get
isUser
boolean
get
tokenFormatted
string
get

Methods

acceptAgreements()

async src/client.ts:359
acceptAgreements(privacy?: boolean, terms?: boolean): Promise<any>
privacy?
boolean
Default true
terms?
boolean
Default true

acceptTeamInvite()

async src/client.ts:388
acceptTeamInvite(token: string): Promise<any>

ackChannelMessage()

async src/client.ts:421
ackChannelMessage(channelId: string, messageId: string, token: string): Promise<any>

ackChannelPins()

async src/client.ts:447
ackChannelPins(channelId: string): Promise<any>

addInviteTargetUser()

async src/client.ts:589
addInviteTargetUser(code: string, userId: string): Promise<any>

addPinnedMessage()

async src/client.ts:609
addPinnedMessage(channelId: string, messageId: string, options?: PinMessage): Promise<any>

addThreadMember()

async src/client.ts:572
addThreadMember(channelId: string, userId: string): Promise<any>

consumeApplicationEntitlement()

async src/client.ts:964
consumeApplicationEntitlement(applicationId: string, entitlementId: string): Promise<any>

createChannelStoreListingGrantEntitlement()

async src/client.ts:1193
createChannelStoreListingGrantEntitlement(channelId: string): Promise<any>

createLobbyChannelInvite()

async src/client.ts:1670
createLobbyChannelInvite(lobbyId: string, userId?: string): Promise<any>
lobbyId
string
userId?
string
Default '@me'

createOauth2ApplicationBot()

async src/client.ts:1896
createOauth2ApplicationBot(applicationId: string): Promise<any>

createReaction()

async src/client.ts:1938
createReaction(channelId: string, messageId: string, emoji: string): Promise<any>

crosspostMessage()

async src/client.ts:2053
crosspostMessage(channelId: string, messageId: string): Promise<any>

deleteApplicationCommand()

async src/client.ts:2086
deleteApplicationCommand(applicationId: string, commandId: string): Promise<any>

deleteApplicationEmoji()

async src/client.ts:2100
deleteApplicationEmoji(applicationId: string, emojiId: string): Promise<any>

deleteApplicationEntitlement()

async src/client.ts:2114
deleteApplicationEntitlement(applicationId: string, entitlementId: string): Promise<any>

deleteApplicationGuildCommand()

async src/client.ts:2128
deleteApplicationGuildCommand(
  applicationId: string,
  guildId: string,
  commandId: string,
): Promise<any>

deleteConnection()

async src/client.ts:2187
deleteConnection(platform: string, accountId: string): Promise<any>

deleteGuildPremiumSubscription()

async src/client.ts:2286
deleteGuildPremiumSubscription(guildId: string, subscriptionId: string): Promise<any>

deleteGuildTemplate()

async src/client.ts:2410
deleteGuildTemplate(guildId: string, templateId: string): Promise<any>

deleteMeApplicationRoleConnection()

async src/client.ts:5904
deleteMeApplicationRoleConnection(applicationId: string): Promise<any>

deleteMeBillingPaymentSource()

async src/client.ts:2463
deleteMeBillingPaymentSource(paymentSourceId: string): Promise<any>

deleteMeBillingSubscription()

async src/client.ts:2479
deleteMeBillingSubscription(subscriptionId: string): Promise<any>

deleteOauth2ApplicationAsset()

async src/client.ts:2540
deleteOauth2ApplicationAsset(applicationId: string, assetId: string): Promise<any>

deletePinnedMessage()

async src/client.ts:2557
deletePinnedMessage(
  channelId: string,
  messageId: string,
  options?: PinMessage,
): Promise<any>

deleteReaction()

async src/client.ts:2613
deleteReaction(
  channelId: string,
  messageId: string,
  emoji: string,
  userId?: string,
): Promise<any>
channelId
string
messageId
string
emoji
string
userId?
string
Default '@me'

deleteReactions()

async src/client.ts:2578
deleteReactions(channelId: string, messageId: string): Promise<any>

deleteReactionsEmoji()

async src/client.ts:2595
deleteReactionsEmoji(channelId: string, messageId: string, emoji: string): Promise<any>

deleteRelationship()

async src/client.ts:2632
deleteRelationship(userId: string): Promise<any>

deleteStoreApplicationAsset()

async src/client.ts:2668
deleteStoreApplicationAsset(applicationId: string, assetId: string): Promise<any>

editLobbyMessageModerationMetadata()

async src/client.ts:3688
editLobbyMessageModerationMetadata(
  lobbyId: string,
  messageId: string,
  metadata: Record<string, string>,
): Promise<any>

editNote()

async src/client.ts:3909
editNote(userId: string, note: string): Promise<any>

editRelationship()

async src/client.ts:3952
editRelationship(userId: string, type: number): Promise<any>

enableOauth2ApplicationAssets()

async src/client.ts:4124
enableOauth2ApplicationAssets(applicationId: string): Promise<any>

enableOauth2ApplicationRpc()

async src/client.ts:4141
enableOauth2ApplicationRpc(applicationId: string): Promise<any>

endChannelPoll()

async src/client.ts:4231
endChannelPoll(channelId: string, messageId: string): Promise<any>

executeWebhook()

async src/client.ts:4158
executeWebhook(
  webhookId: string,
  webhookToken: string,
  options?: string | ExecuteWebhook,
  compatibleType?: string,
): Promise<any>

fetchApplication()

async src/client.ts:4527
fetchApplication(applicationId: string): Promise<any>

fetchApplicationCommand()

async src/client.ts:4278
fetchApplicationCommand(applicationId: string, commandId: string): Promise<any>

fetchApplicationEmoji()

async src/client.ts:4308
fetchApplicationEmoji(applicationId: string, emojiId: string): Promise<any>

fetchApplicationEmojis()

async src/client.ts:4295
fetchApplicationEmojis(applicationId: string): Promise<any>

fetchApplicationEntitlement()

async src/client.ts:4322
fetchApplicationEntitlement(applicationId: string, entitlementId: string): Promise<any>

fetchApplicationGuildCommand()

async src/client.ts:4414
fetchApplicationGuildCommand(
  applicationId: string,
  guildId: string,
  commandId: string,
): Promise<any>

fetchApplicationGuildCommandPermissions()

async src/client.ts:4432
fetchApplicationGuildCommandPermissions(
  applicationId: string,
  guildId: string,
  commandId: string,
): Promise<any>

fetchApplicationGuildCommandsPermissions()

async src/client.ts:4397
fetchApplicationGuildCommandsPermissions(
  applicationId: string,
  guildId: string,
): Promise<any>

fetchApplicationNews()

async src/client.ts:4450
fetchApplicationNews(applicationIds?: string | string[]): Promise<any>

fetchApplicationNewsId()

async src/client.ts:4470
fetchApplicationNewsId(newsId: string): Promise<any>

fetchApplicationRoleConnectionsMetadata()

async src/client.ts:4486
fetchApplicationRoleConnectionsMetadata(applicationId: string): Promise<any>

fetchApplicationsDetectable()

async src/client.ts:4560
fetchApplicationsDetectable(): Promise<any>

fetchApplicationSkus()

async src/client.ts:4502
fetchApplicationSkus(applicationId: string): Promise<any>

fetchApplicationsPublic()

async src/client.ts:4569
fetchApplicationsPublic(applicationIds: string | string[]): Promise<any>

fetchApplicationsTrendingGlobal()

async src/client.ts:4585
fetchApplicationsTrendingGlobal(): Promise<any>

fetchAuthConsentRequired()

async src/client.ts:4594
fetchAuthConsentRequired(): Promise<any>

fetchChannelCall()

async src/client.ts:4619
fetchChannelCall(channelId: string): Promise<any>

fetchChannelInvites()

async src/client.ts:4636
fetchChannelInvites(channelId: string): Promise<any>

fetchChannelStoreListing()

async src/client.ts:4676
fetchChannelStoreListing(channelId: string): Promise<any>

fetchChannelWebhooks()

async src/client.ts:4779
fetchChannelWebhooks(channelId: string): Promise<any>

fetchDiscoverableGuilds()

async src/client.ts:4825
fetchDiscoverableGuilds(): Promise<any>

fetchDms()

async src/client.ts:4834
fetchDms(userId?: string): Promise<any>
userId?
string
Default '@me'

fetchEmojiGuild()

async src/client.ts:4848
fetchEmojiGuild(emojiId: string): Promise<any>

fetchExperiments()

async src/client.ts:4861
fetchExperiments(fingerprint?: string): Promise<any>

fetchGuildApplications()

async src/client.ts:4939
fetchGuildApplications(guildId: string, channelId?: string): Promise<any>

fetchGuildAutoModerationRule()

async src/client.ts:4999
fetchGuildAutoModerationRule(guildId: string, autoModerationRuleId: string): Promise<any>

fetchGuildAutoModerationRules()

async src/client.ts:4983
fetchGuildAutoModerationRules(guildId: string): Promise<any>

fetchGuildBan()

async src/client.ts:5046
fetchGuildBan(guildId: string, userId: string): Promise<any>

fetchGuildChannels()

async src/client.ts:5063
fetchGuildChannels(guildId: string): Promise<any>

fetchGuildEmoji()

async src/client.ts:5095
fetchGuildEmoji(guildId: string, emojiId: string): Promise<any>

fetchGuildEmojis()

async src/client.ts:5079
fetchGuildEmojis(guildId: string): Promise<any>

fetchGuildIntegrations()

async src/client.ts:5112
fetchGuildIntegrations(guildId: string): Promise<any>

fetchGuildInvites()

async src/client.ts:5128
fetchGuildInvites(guildId: string): Promise<any>

fetchGuildMember()

async src/client.ts:5188
fetchGuildMember(guildId: string, userId: string): Promise<any>

fetchGuildMemberVerification()

async src/client.ts:5205
fetchGuildMemberVerification(guildId: string): Promise<any>

fetchGuildOnboarding()

async src/client.ts:5320
fetchGuildOnboarding(guildId: string): Promise<any>

fetchGuildPremiumSubscriptions()

async src/client.ts:5221
fetchGuildPremiumSubscriptions(guildId: string): Promise<any>

fetchGuildPreview()

async src/client.ts:5387
fetchGuildPreview(guildId: string): Promise<any>

fetchGuildRole()

async src/client.ts:5333
fetchGuildRole(guildId: string, roleId: string): Promise<any>

fetchGuildRoleMemberCounts()

async src/client.ts:5348
fetchGuildRoleMemberCounts(guildId: string): Promise<any>

fetchGuildRoles()

async src/client.ts:5425
fetchGuildRoles(guildId: string): Promise<any>

fetchGuildSoundboardSound()

async src/client.ts:5516
fetchGuildSoundboardSound(guildId: string, soundId: string): Promise<any>

fetchGuildSoundboardSounds()

async src/client.ts:5533
fetchGuildSoundboardSounds(guildId: string): Promise<any>

fetchGuildSticker()

async src/client.ts:5642
fetchGuildSticker(guildId: string, stickerId: string): Promise<any>

fetchGuildStickers()

async src/client.ts:5659
fetchGuildStickers(guildId: string): Promise<any>

fetchGuildTemplates()

async src/client.ts:5692
fetchGuildTemplates(guildId: string): Promise<any>

fetchGuildThreadsActive()

async src/client.ts:5361
fetchGuildThreadsActive(guildId: string): Promise<any>

fetchGuildVanityUrl()

async src/client.ts:5708
fetchGuildVanityUrl(guildId: string): Promise<any>

fetchGuildVoiceState()

async src/client.ts:3556
fetchGuildVoiceState(guildId: string, userId?: string): Promise<any>
guildId
string
userId?
string
Default '@me'

fetchGuildWebhooks()

async src/client.ts:5724
fetchGuildWebhooks(guildId: string): Promise<any>

fetchGuildWelcomeScreen()

async src/client.ts:5374
fetchGuildWelcomeScreen(guildId: string): Promise<any>

fetchGuildWidget()

async src/client.ts:5740
fetchGuildWidget(guildId: string): Promise<any>

fetchGuildWidgetJson()

async src/client.ts:5756
fetchGuildWidgetJson(guildId: string): Promise<any>

fetchInviteTargetUsers()

async src/client.ts:5793
fetchInviteTargetUsers(code: string): Promise<any>

fetchInviteTargetUsersJobStatus()

async src/client.ts:5810
fetchInviteTargetUsersJobStatus(code: string): Promise<any>

fetchMeApplicationRoleConnection()

async src/client.ts:5891
fetchMeApplicationRoleConnection(applicationId: string): Promise<any>

fetchMeBillingPaymentSources()

async src/client.ts:5930
fetchMeBillingPaymentSources(): Promise<any>

fetchMeBillingSubscriptions()

async src/client.ts:5958
fetchMeBillingSubscriptions(): Promise<any>

fetchMeConnectionAccessToken()

async src/client.ts:5983
fetchMeConnectionAccessToken(platform: string, accountId: string): Promise<any>

fetchMeConnectionSubreddits()

async src/client.ts:6000
fetchMeConnectionSubreddits(accountId: string): Promise<any>

fetchMeGuildMember()

async src/client.ts:5917
fetchMeGuildMember(guildId: string): Promise<any>

fetchMessage()

async src/client.ts:6055
fetchMessage(channelId: string, messageId: string): Promise<any>

fetchMeStickerPacks()

async src/client.ts:6107
fetchMeStickerPacks(countryCode?: string): Promise<any>

fetchOauth2Application()

async src/client.ts:6138
fetchOauth2Application(applicationId?: string): Promise<any>
applicationId?
string
Default '@me'

fetchOauth2ApplicationAssets()

async src/client.ts:6154
fetchOauth2ApplicationAssets(applicationId: string): Promise<any>

fetchOauth2ApplicationWhitelist()

async src/client.ts:6170
fetchOauth2ApplicationWhitelist(applicationId: string): Promise<any>

fetchOauth2AuthorizeWebhookChannels()

async src/client.ts:6206
fetchOauth2AuthorizeWebhookChannels(guildId: string): Promise<any>

fetchOauth2Token()

async src/client.ts:6233
fetchOauth2Token(tokenId: string): Promise<any>

fetchPinnedMessages()

asyncdeprecated src/client.ts:6275
fetchPinnedMessages(channelId: string): Promise<any>

Deprecated. use fetchChannelPins, this route is deprecated and capped at 50 pins

fetchSkuSubscription()

async src/client.ts:5599
fetchSkuSubscription(skuId: string, subscriptionId: string): Promise<any>

fetchSoundboardDefaultSounds()

async src/client.ts:5549
fetchSoundboardDefaultSounds(): Promise<any>

fetchStageInstance()

async src/client.ts:6324
fetchStageInstance(channelId: string): Promise<any>

fetchStickerPack()

async src/client.ts:5574
fetchStickerPack(stickerPackId: string): Promise<any>

fetchStoreApplicationAssets()

async src/client.ts:6340
fetchStoreApplicationAssets(applicationId: string): Promise<any>

fetchStorePublishedListingsSku()

async src/client.ts:6375
fetchStorePublishedListingsSku(skuId: string): Promise<any>

fetchStorePublishedListingsSkus()

async src/client.ts:6356
fetchStorePublishedListingsSkus(applicationId: string): Promise<any>

fetchStorePublishedListingsSkuSubscriptionPlans()

async src/client.ts:6391
fetchStorePublishedListingsSkuSubscriptionPlans(skuId: string): Promise<any>

fetchStreamPreview()

async src/client.ts:6407
fetchStreamPreview(streamKey: string): Promise<any>

fetchTeamApplications()

async src/client.ts:6446
fetchTeamApplications(teamId: string): Promise<any>

fetchTeamMember()

async src/client.ts:6478
fetchTeamMember(teamId: string, userId: string): Promise<any>

fetchTeamMembers()

async src/client.ts:6462
fetchTeamMembers(teamId: string): Promise<any>

fetchTemplate()

async src/client.ts:6516
fetchTemplate(templateId: string): Promise<any>

fetchUserActivityMetadata()

async src/client.ts:6593
fetchUserActivityMetadata(
  userId: string,
  sessionId: string,
  activityId: string,
): Promise<any>

fetchUserChannels()

async src/client.ts:6611
fetchUserChannels(userId: string): Promise<any>

fetchUserProfile()

async src/client.ts:6627
fetchUserProfile(userId: string): Promise<any>

fetchVoiceRegions()

async src/client.ts:6652
fetchVoiceRegions(guildId?: string): Promise<any>

fetchWebhookToken()

async src/client.ts:6692
fetchWebhookToken(webhookId: string, webhookToken: string): Promise<any>

integrationJoin()

async src/client.ts:6776
integrationJoin(integrationId: string): Promise<any>

on()

src/client.ts:349
on(event: string | symbol, listener: (...args: any[]) => void): this

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

server.on('connection', (stream) => {
  console.log('someone connected!');
});

Returns a reference to the EventEmitter, so that calls can be chained.

By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => console.log('a'));
myEE.prependListener('foo', () => console.log('b'));
myEE.emit('foo');
// Prints:
//   b
//   a

Since v0.1.101

event
string | symbol
listener
(...args: any[]) => void

The callback function

on(event: "request", listener: (payload: RequestPayload) => any): this
on(event: "response", listener: (payload: ResponsePayload) => any): this
Overrides EventSpewer.on

removeInviteTargetUser()

async src/client.ts:7101
removeInviteTargetUser(code: string, userId: string): Promise<any>

removeLobbyMember()

async src/client.ts:3749
removeLobbyMember(lobbyId: string, userId?: string): Promise<any>
lobbyId
string
userId?
string
Default '@me'

removeOauth2ApplicationWhitelistUser()

async src/client.ts:7137
removeOauth2ApplicationWhitelistUser(applicationId: string, userId: string): Promise<any>

removeRecipient()

async src/client.ts:7154
removeRecipient(channelId: string, userId: string): Promise<any>

removeTeamMember()

async src/client.ts:7171
removeTeamMember(teamId: string, userId: string): Promise<any>

removeThreadMember()

async src/client.ts:7188
removeThreadMember(channelId: string, userId: string): Promise<any>

resetOauth2Application()

async src/client.ts:7205
resetOauth2Application(applicationId: string): Promise<any>

resetOauth2ApplicationBot()

async src/client.ts:7222
resetOauth2ApplicationBot(applicationId: string): Promise<any>

searchChannel()

async src/client.ts:7364
searchChannel(
  channelId: string,
  options?: SearchOptions,
  retry?: boolean,
  retryNumber?: number,
): Promise<any>
channelId
string
retry?
boolean
Default true
retryNumber?
number
Default 0

searchGuild()

async src/client.ts:7373
searchGuild(
  guildId: string,
  options?: SearchOptions,
  retry?: boolean,
  retryNumber?: number,
): Promise<any>
guildId
string
retry?
boolean
Default true
retryNumber?
number
Default 0

searchLobbies()

asyncdeprecated src/client.ts:7383
searchLobbies(applicationId: string, options?: SearchLobbies): Promise<any>

Deprecated. old GameSDK lobbies, this endpoint doesn't exist anymore

sendDownloadText()

async src/client.ts:7406
sendDownloadText(number: string): Promise<any>

sendLobbyData()

asyncdeprecated src/client.ts:7466
sendLobbyData(lobbyId: string, data: string): Promise<any>

Deprecated. old GameSDK lobbies, use createLobbyMessage

submitConnectionPinCode()

async src/client.ts:7523
submitConnectionPinCode(platform: string, pin: string): Promise<any>

submitOauth2ApplicationApproval()

async src/client.ts:7540
submitOauth2ApplicationApproval(applicationId: string): Promise<any>

syncGuildIntegration()

async src/client.ts:7556
syncGuildIntegration(guildId: string, integrationId: string): Promise<any>

syncGuildTemplate()

async src/client.ts:5675
syncGuildTemplate(guildId: string, templateId: string): Promise<any>