@discordjs/core 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/http-only.d.mts +331 -44
- package/dist/http-only.d.ts +331 -44
- package/dist/http-only.js +257 -149
- package/dist/http-only.js.map +1 -1
- package/dist/http-only.mjs +256 -149
- package/dist/http-only.mjs.map +1 -1
- package/dist/index.d.mts +376 -44
- package/dist/index.d.ts +376 -44
- package/dist/index.js +372 -170
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +363 -163
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -20,14 +20,15 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
|
|
|
20
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
21
|
|
|
22
22
|
// src/index.ts
|
|
23
|
-
var
|
|
24
|
-
__export(
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, {
|
|
25
25
|
API: () => API,
|
|
26
26
|
ApplicationCommandsAPI: () => ApplicationCommandsAPI,
|
|
27
27
|
ApplicationsAPI: () => ApplicationsAPI,
|
|
28
28
|
ChannelsAPI: () => ChannelsAPI,
|
|
29
29
|
Client: () => Client,
|
|
30
30
|
GatewayAPI: () => GatewayAPI,
|
|
31
|
+
GatewayRateLimitError: () => import_util2.GatewayRateLimitError,
|
|
31
32
|
GuildsAPI: () => GuildsAPI,
|
|
32
33
|
InteractionsAPI: () => InteractionsAPI,
|
|
33
34
|
InvitesAPI: () => InvitesAPI,
|
|
@@ -35,6 +36,7 @@ __export(src_exports, {
|
|
|
35
36
|
OAuth2API: () => OAuth2API,
|
|
36
37
|
PollAPI: () => PollAPI,
|
|
37
38
|
RoleConnectionsAPI: () => RoleConnectionsAPI,
|
|
39
|
+
SoundboardSoundsAPI: () => SoundboardSoundsAPI,
|
|
38
40
|
StageInstancesAPI: () => StageInstancesAPI,
|
|
39
41
|
StickersAPI: () => StickersAPI,
|
|
40
42
|
ThreadsAPI: () => ThreadsAPI,
|
|
@@ -44,7 +46,7 @@ __export(src_exports, {
|
|
|
44
46
|
version: () => version,
|
|
45
47
|
withFiles: () => withFiles
|
|
46
48
|
});
|
|
47
|
-
module.exports = __toCommonJS(
|
|
49
|
+
module.exports = __toCommonJS(index_exports);
|
|
48
50
|
|
|
49
51
|
// src/api/applicationCommands.ts
|
|
50
52
|
var import_rest = require("@discordjs/rest");
|
|
@@ -792,6 +794,20 @@ var ChannelsAPI = class {
|
|
|
792
794
|
signal
|
|
793
795
|
});
|
|
794
796
|
}
|
|
797
|
+
/**
|
|
798
|
+
* Sends a soundboard sound in a channel
|
|
799
|
+
*
|
|
800
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound}
|
|
801
|
+
* @param channelId - The id of the channel to send the soundboard sound in
|
|
802
|
+
* @param body - The data for sending the soundboard sound
|
|
803
|
+
* @param options - The options for sending the soundboard sound
|
|
804
|
+
*/
|
|
805
|
+
async sendSoundboardSound(channelId, body, { signal } = {}) {
|
|
806
|
+
return this.rest.post(import_v103.Routes.sendSoundboardSound(channelId), {
|
|
807
|
+
body,
|
|
808
|
+
signal
|
|
809
|
+
});
|
|
810
|
+
}
|
|
795
811
|
/**
|
|
796
812
|
* Adds a recipient to a group DM channel
|
|
797
813
|
*
|
|
@@ -1012,7 +1028,7 @@ var GuildsAPI = class {
|
|
|
1012
1028
|
});
|
|
1013
1029
|
}
|
|
1014
1030
|
/**
|
|
1015
|
-
* Fetches
|
|
1031
|
+
* Fetches members of a guild.
|
|
1016
1032
|
*
|
|
1017
1033
|
* @see {@link https://discord.com/developers/docs/resources/guild#list-guild-members}
|
|
1018
1034
|
* @param guildId - The id of the guild
|
|
@@ -1883,6 +1899,73 @@ var GuildsAPI = class {
|
|
|
1883
1899
|
signal
|
|
1884
1900
|
});
|
|
1885
1901
|
}
|
|
1902
|
+
/**
|
|
1903
|
+
* Fetches all the soundboard sounds for a guild
|
|
1904
|
+
*
|
|
1905
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#list-guild-soundboard-sounds}
|
|
1906
|
+
* @param guildId - The id of the guild to fetch the soundboard sounds for
|
|
1907
|
+
* @param options - The options for fetching the soundboard sounds
|
|
1908
|
+
*/
|
|
1909
|
+
async getSoundboardSounds(guildId, { signal } = {}) {
|
|
1910
|
+
return this.rest.get(import_v106.Routes.guildSoundboardSounds(guildId), {
|
|
1911
|
+
signal
|
|
1912
|
+
});
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Fetches a soundboard sound for a guild
|
|
1916
|
+
*
|
|
1917
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#get-guild-soundboard-sound}
|
|
1918
|
+
* @param guildId - The id of the guild to fetch the soundboard sound for
|
|
1919
|
+
* @param soundId - The id of the soundboard sound to fetch
|
|
1920
|
+
* @param options - The options for fetching the soundboard sound
|
|
1921
|
+
*/
|
|
1922
|
+
async getSoundboardSound(guildId, soundId, { signal } = {}) {
|
|
1923
|
+
return this.rest.get(import_v106.Routes.guildSoundboardSound(guildId, soundId), {
|
|
1924
|
+
signal
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* Creates a new soundboard sound for a guild
|
|
1929
|
+
*
|
|
1930
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound}
|
|
1931
|
+
* @param guildId - The id of the guild to create the soundboard sound for
|
|
1932
|
+
* @param body - The data for creating the soundboard sound
|
|
1933
|
+
* @param options - The options for creating the soundboard sound
|
|
1934
|
+
*/
|
|
1935
|
+
async createSoundboardSound(guildId, body, { reason, signal } = {}) {
|
|
1936
|
+
return this.rest.post(import_v106.Routes.guildSoundboardSounds(guildId), {
|
|
1937
|
+
body,
|
|
1938
|
+
reason,
|
|
1939
|
+
signal
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Edits a soundboard sound for a guild
|
|
1944
|
+
*
|
|
1945
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound}
|
|
1946
|
+
* @param guildId - The id of the guild to edit the soundboard sound for
|
|
1947
|
+
* @param soundId - The id of the soundboard sound to edit
|
|
1948
|
+
* @param body - The data for editing the soundboard sound
|
|
1949
|
+
* @param options - The options for editing the soundboard sound
|
|
1950
|
+
*/
|
|
1951
|
+
async editSoundboardSound(guildId, soundId, body, { reason, signal } = {}) {
|
|
1952
|
+
return this.rest.patch(import_v106.Routes.guildSoundboardSound(guildId, soundId), {
|
|
1953
|
+
body,
|
|
1954
|
+
reason,
|
|
1955
|
+
signal
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* Deletes a soundboard sound for a guild
|
|
1960
|
+
*
|
|
1961
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#delete-guild-soundboard-sound}
|
|
1962
|
+
* @param guildId - The id of the guild to delete the soundboard sound for
|
|
1963
|
+
* @param soundId - The id of the soundboard sound to delete
|
|
1964
|
+
* @param options - The options for deleting the soundboard sound
|
|
1965
|
+
*/
|
|
1966
|
+
async deleteSoundboardSound(guildId, soundId, { reason, signal } = {}) {
|
|
1967
|
+
await this.rest.delete(import_v106.Routes.guildSoundboardSound(guildId, soundId), { reason, signal });
|
|
1968
|
+
}
|
|
1886
1969
|
/**
|
|
1887
1970
|
* Modifies incident actions for a guild.
|
|
1888
1971
|
*
|
|
@@ -1900,6 +1983,7 @@ var GuildsAPI = class {
|
|
|
1900
1983
|
};
|
|
1901
1984
|
|
|
1902
1985
|
// src/api/interactions.ts
|
|
1986
|
+
var import_rest4 = require("@discordjs/rest");
|
|
1903
1987
|
var import_v107 = require("discord-api-types/v10");
|
|
1904
1988
|
var InteractionsAPI = class {
|
|
1905
1989
|
constructor(rest, webhooks) {
|
|
@@ -1909,17 +1993,9 @@ var InteractionsAPI = class {
|
|
|
1909
1993
|
static {
|
|
1910
1994
|
__name(this, "InteractionsAPI");
|
|
1911
1995
|
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1916
|
-
* @param interactionId - The id of the interaction
|
|
1917
|
-
* @param interactionToken - The token of the interaction
|
|
1918
|
-
* @param body - The callback data for replying
|
|
1919
|
-
* @param options - The options for replying
|
|
1920
|
-
*/
|
|
1921
|
-
async reply(interactionId, interactionToken, { files, ...data }, { signal } = {}) {
|
|
1922
|
-
await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
1996
|
+
async reply(interactionId, interactionToken, { files, with_response, ...data }, { signal } = {}) {
|
|
1997
|
+
const response = await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
1998
|
+
query: (0, import_rest4.makeURLSearchParams)({ with_response }),
|
|
1923
1999
|
files,
|
|
1924
2000
|
auth: false,
|
|
1925
2001
|
body: {
|
|
@@ -1928,18 +2004,11 @@ var InteractionsAPI = class {
|
|
|
1928
2004
|
},
|
|
1929
2005
|
signal
|
|
1930
2006
|
});
|
|
2007
|
+
return with_response ? response : void 0;
|
|
1931
2008
|
}
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1936
|
-
* @param interactionId - The id of the interaction
|
|
1937
|
-
* @param interactionToken - The token of the interaction
|
|
1938
|
-
* @param data - The data for deferring the reply
|
|
1939
|
-
* @param options - The options for deferring
|
|
1940
|
-
*/
|
|
1941
|
-
async defer(interactionId, interactionToken, data, { signal } = {}) {
|
|
1942
|
-
await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2009
|
+
async defer(interactionId, interactionToken, { with_response, ...data } = {}, { signal } = {}) {
|
|
2010
|
+
const response = await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2011
|
+
query: (0, import_rest4.makeURLSearchParams)({ with_response }),
|
|
1943
2012
|
auth: false,
|
|
1944
2013
|
body: {
|
|
1945
2014
|
type: import_v107.InteractionResponseType.DeferredChannelMessageWithSource,
|
|
@@ -1947,23 +2016,18 @@ var InteractionsAPI = class {
|
|
|
1947
2016
|
},
|
|
1948
2017
|
signal
|
|
1949
2018
|
});
|
|
2019
|
+
return with_response ? response : void 0;
|
|
1950
2020
|
}
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1955
|
-
* @param interactionId - The id of the interaction
|
|
1956
|
-
* @param interactionToken - The token of the interaction
|
|
1957
|
-
* @param options - The options for deferring
|
|
1958
|
-
*/
|
|
1959
|
-
async deferMessageUpdate(interactionId, interactionToken, { signal } = {}) {
|
|
1960
|
-
await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2021
|
+
async deferMessageUpdate(interactionId, interactionToken, { with_response } = {}, { signal } = {}) {
|
|
2022
|
+
const response = await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2023
|
+
query: (0, import_rest4.makeURLSearchParams)({ with_response }),
|
|
1961
2024
|
auth: false,
|
|
1962
2025
|
body: {
|
|
1963
2026
|
type: import_v107.InteractionResponseType.DeferredMessageUpdate
|
|
1964
2027
|
},
|
|
1965
2028
|
signal
|
|
1966
2029
|
});
|
|
2030
|
+
return with_response ? response : void 0;
|
|
1967
2031
|
}
|
|
1968
2032
|
/**
|
|
1969
2033
|
* Reply to a deferred interaction
|
|
@@ -2023,17 +2087,9 @@ var InteractionsAPI = class {
|
|
|
2023
2087
|
async deleteReply(applicationId, interactionToken, messageId, { signal } = {}) {
|
|
2024
2088
|
await this.webhooks.deleteMessage(applicationId, interactionToken, messageId ?? "@original", {}, { signal });
|
|
2025
2089
|
}
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
2030
|
-
* @param interactionId - The id of the interaction
|
|
2031
|
-
* @param interactionToken - The token of the interaction
|
|
2032
|
-
* @param callbackData - The callback data for updating the interaction
|
|
2033
|
-
* @param options - The options for updating the interaction
|
|
2034
|
-
*/
|
|
2035
|
-
async updateMessage(interactionId, interactionToken, { files, ...data }, { signal } = {}) {
|
|
2036
|
-
await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2090
|
+
async updateMessage(interactionId, interactionToken, { files, with_response, ...data }, { signal } = {}) {
|
|
2091
|
+
const response = await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2092
|
+
query: (0, import_rest4.makeURLSearchParams)({ with_response }),
|
|
2037
2093
|
files,
|
|
2038
2094
|
auth: false,
|
|
2039
2095
|
body: {
|
|
@@ -2042,47 +2098,34 @@ var InteractionsAPI = class {
|
|
|
2042
2098
|
},
|
|
2043
2099
|
signal
|
|
2044
2100
|
});
|
|
2101
|
+
return with_response ? response : void 0;
|
|
2045
2102
|
}
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
2050
|
-
* @param interactionId - The id of the interaction
|
|
2051
|
-
* @param interactionToken - The token of the interaction
|
|
2052
|
-
* @param callbackData - The callback data for the autocomplete response
|
|
2053
|
-
* @param options - The options for sending the autocomplete response
|
|
2054
|
-
*/
|
|
2055
|
-
async createAutocompleteResponse(interactionId, interactionToken, callbackData, { signal } = {}) {
|
|
2056
|
-
await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2103
|
+
async createAutocompleteResponse(interactionId, interactionToken, { with_response, ...data }, { signal } = {}) {
|
|
2104
|
+
const response = await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2105
|
+
query: (0, import_rest4.makeURLSearchParams)({ with_response }),
|
|
2057
2106
|
auth: false,
|
|
2058
2107
|
body: {
|
|
2059
2108
|
type: import_v107.InteractionResponseType.ApplicationCommandAutocompleteResult,
|
|
2060
|
-
data
|
|
2109
|
+
data
|
|
2061
2110
|
},
|
|
2062
2111
|
signal
|
|
2063
2112
|
});
|
|
2113
|
+
return with_response ? response : void 0;
|
|
2064
2114
|
}
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
2069
|
-
* @param interactionId - The id of the interaction
|
|
2070
|
-
* @param interactionToken - The token of the interaction
|
|
2071
|
-
* @param callbackData - The modal callback data to send
|
|
2072
|
-
* @param options - The options for sending the modal
|
|
2073
|
-
*/
|
|
2074
|
-
async createModal(interactionId, interactionToken, callbackData, { signal } = {}) {
|
|
2075
|
-
await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2115
|
+
async createModal(interactionId, interactionToken, { with_response, ...data }, { signal } = {}) {
|
|
2116
|
+
const response = await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2117
|
+
query: (0, import_rest4.makeURLSearchParams)({ with_response }),
|
|
2076
2118
|
auth: false,
|
|
2077
2119
|
body: {
|
|
2078
2120
|
type: import_v107.InteractionResponseType.Modal,
|
|
2079
|
-
data
|
|
2121
|
+
data
|
|
2080
2122
|
},
|
|
2081
2123
|
signal
|
|
2082
2124
|
});
|
|
2125
|
+
return with_response ? response : void 0;
|
|
2083
2126
|
}
|
|
2084
2127
|
/**
|
|
2085
|
-
*
|
|
2128
|
+
* Launches an activity and returns an interaction callback object
|
|
2086
2129
|
*
|
|
2087
2130
|
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
2088
2131
|
* @param interactionId - The id of the interaction
|
|
@@ -2099,10 +2142,21 @@ var InteractionsAPI = class {
|
|
|
2099
2142
|
signal
|
|
2100
2143
|
});
|
|
2101
2144
|
}
|
|
2145
|
+
async launchActivity(interactionId, interactionToken, { with_response } = {}, { signal } = {}) {
|
|
2146
|
+
const response = await this.rest.post(import_v107.Routes.interactionCallback(interactionId, interactionToken), {
|
|
2147
|
+
query: (0, import_rest4.makeURLSearchParams)({ with_response }),
|
|
2148
|
+
auth: false,
|
|
2149
|
+
body: {
|
|
2150
|
+
type: import_v107.InteractionResponseType.LaunchActivity
|
|
2151
|
+
},
|
|
2152
|
+
signal
|
|
2153
|
+
});
|
|
2154
|
+
return with_response ? response : void 0;
|
|
2155
|
+
}
|
|
2102
2156
|
};
|
|
2103
2157
|
|
|
2104
2158
|
// src/api/invite.ts
|
|
2105
|
-
var
|
|
2159
|
+
var import_rest5 = require("@discordjs/rest");
|
|
2106
2160
|
var import_v108 = require("discord-api-types/v10");
|
|
2107
2161
|
var InvitesAPI = class {
|
|
2108
2162
|
constructor(rest) {
|
|
@@ -2121,7 +2175,7 @@ var InvitesAPI = class {
|
|
|
2121
2175
|
*/
|
|
2122
2176
|
async get(code, query = {}, { signal } = {}) {
|
|
2123
2177
|
return this.rest.get(import_v108.Routes.invite(code), {
|
|
2124
|
-
query: (0,
|
|
2178
|
+
query: (0, import_rest5.makeURLSearchParams)(query),
|
|
2125
2179
|
signal
|
|
2126
2180
|
});
|
|
2127
2181
|
}
|
|
@@ -2138,7 +2192,7 @@ var InvitesAPI = class {
|
|
|
2138
2192
|
};
|
|
2139
2193
|
|
|
2140
2194
|
// src/api/monetization.ts
|
|
2141
|
-
var
|
|
2195
|
+
var import_rest6 = require("@discordjs/rest");
|
|
2142
2196
|
var import_v109 = require("discord-api-types/v10");
|
|
2143
2197
|
var MonetizationAPI = class {
|
|
2144
2198
|
constructor(rest) {
|
|
@@ -2150,30 +2204,71 @@ var MonetizationAPI = class {
|
|
|
2150
2204
|
/**
|
|
2151
2205
|
* Fetches the SKUs for an application.
|
|
2152
2206
|
*
|
|
2153
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2207
|
+
* @see {@link https://discord.com/developers/docs/resources/sku#list-skus}
|
|
2208
|
+
* @param applicationId - The application id to fetch SKUs for
|
|
2154
2209
|
* @param options - The options for fetching the SKUs.
|
|
2155
2210
|
*/
|
|
2156
2211
|
async getSKUs(applicationId, { signal } = {}) {
|
|
2157
2212
|
return this.rest.get(import_v109.Routes.skus(applicationId), { signal });
|
|
2158
2213
|
}
|
|
2214
|
+
/**
|
|
2215
|
+
* Fetches subscriptions for an SKU.
|
|
2216
|
+
*
|
|
2217
|
+
* @see {@link https://discord.com/developers/docs/resources/subscription#list-sku-subscriptions}
|
|
2218
|
+
* @param skuId - The SKU id to fetch subscriptions for
|
|
2219
|
+
* @param query - The query options for fetching subscriptions
|
|
2220
|
+
* @param options - The options for fetching subscriptions
|
|
2221
|
+
*/
|
|
2222
|
+
async getSKUSubscriptions(skuId, query = {}, { signal } = {}) {
|
|
2223
|
+
return this.rest.get(import_v109.Routes.skuSubscriptions(skuId), {
|
|
2224
|
+
signal,
|
|
2225
|
+
query: (0, import_rest6.makeURLSearchParams)(query)
|
|
2226
|
+
});
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Fetches a subscription for an SKU.
|
|
2230
|
+
*
|
|
2231
|
+
* @see {@link https://discord.com/developers/docs/resources/subscription#get-sku-subscription}
|
|
2232
|
+
* @param skuId - The SKU id to fetch subscription for
|
|
2233
|
+
* @param subscriptionId - The subscription id to fetch
|
|
2234
|
+
* @param options - The options for fetching the subscription
|
|
2235
|
+
*/
|
|
2236
|
+
async getSKUSubscription(skuId, subscriptionId, { signal } = {}) {
|
|
2237
|
+
return this.rest.get(import_v109.Routes.skuSubscription(skuId, subscriptionId), {
|
|
2238
|
+
signal
|
|
2239
|
+
});
|
|
2240
|
+
}
|
|
2159
2241
|
/**
|
|
2160
2242
|
* Fetches the entitlements for an application.
|
|
2161
2243
|
*
|
|
2162
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2244
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#list-entitlements}
|
|
2163
2245
|
* @param applicationId - The application id to fetch entitlements for
|
|
2164
2246
|
* @param query - The query options for fetching entitlements
|
|
2165
2247
|
* @param options - The options for fetching entitlements
|
|
2166
2248
|
*/
|
|
2167
|
-
async getEntitlements(applicationId, query, { signal } = {}) {
|
|
2249
|
+
async getEntitlements(applicationId, query = {}, { signal } = {}) {
|
|
2168
2250
|
return this.rest.get(import_v109.Routes.entitlements(applicationId), {
|
|
2169
2251
|
signal,
|
|
2170
|
-
query: (0,
|
|
2252
|
+
query: (0, import_rest6.makeURLSearchParams)(query)
|
|
2253
|
+
});
|
|
2254
|
+
}
|
|
2255
|
+
/**
|
|
2256
|
+
* Fetches an entitlement for an application.
|
|
2257
|
+
*
|
|
2258
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#get-entitlement}
|
|
2259
|
+
* @param applicationId - The application id to fetch the entitlement for
|
|
2260
|
+
* @param entitlementId - The entitlement id to fetch
|
|
2261
|
+
* @param options - The options for fetching the entitlement
|
|
2262
|
+
*/
|
|
2263
|
+
async getEntitlement(applicationId, entitlementId, { signal } = {}) {
|
|
2264
|
+
return this.rest.get(import_v109.Routes.entitlement(applicationId, entitlementId), {
|
|
2265
|
+
signal
|
|
2171
2266
|
});
|
|
2172
2267
|
}
|
|
2173
2268
|
/**
|
|
2174
2269
|
* Creates a test entitlement for an application's SKU.
|
|
2175
2270
|
*
|
|
2176
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2271
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#create-test-entitlement}
|
|
2177
2272
|
* @param applicationId - The application id to create the entitlement for
|
|
2178
2273
|
* @param body - The data for creating the entitlement
|
|
2179
2274
|
* @param options - The options for creating the entitlement
|
|
@@ -2187,7 +2282,7 @@ var MonetizationAPI = class {
|
|
|
2187
2282
|
/**
|
|
2188
2283
|
* Deletes a test entitlement for an application's SKU.
|
|
2189
2284
|
*
|
|
2190
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2285
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#delete-test-entitlement}
|
|
2191
2286
|
* @param applicationId - The application id to delete the entitlement for
|
|
2192
2287
|
* @param entitlementId - The entitlement id to delete
|
|
2193
2288
|
* @param options - The options for deleting the entitlement
|
|
@@ -2198,7 +2293,7 @@ var MonetizationAPI = class {
|
|
|
2198
2293
|
/**
|
|
2199
2294
|
* Marks a given entitlement for the user as consumed. Only available for One-Time Purchase consumable SKUs.
|
|
2200
2295
|
*
|
|
2201
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2296
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#consume-an-entitlement}
|
|
2202
2297
|
* @param applicationId - The application id to consume the entitlement for
|
|
2203
2298
|
* @param entitlementId - The entitlement id to consume
|
|
2204
2299
|
* @param options - The options for consuming the entitlement
|
|
@@ -2209,7 +2304,7 @@ var MonetizationAPI = class {
|
|
|
2209
2304
|
};
|
|
2210
2305
|
|
|
2211
2306
|
// src/api/oauth2.ts
|
|
2212
|
-
var
|
|
2307
|
+
var import_rest7 = require("@discordjs/rest");
|
|
2213
2308
|
var import_v1010 = require("discord-api-types/v10");
|
|
2214
2309
|
var OAuth2API = class {
|
|
2215
2310
|
constructor(rest) {
|
|
@@ -2226,7 +2321,7 @@ var OAuth2API = class {
|
|
|
2226
2321
|
*/
|
|
2227
2322
|
generateAuthorizationURL(options) {
|
|
2228
2323
|
const url = new URL(`${import_v1010.RouteBases.api}${import_v1010.Routes.oauth2Authorization()}`);
|
|
2229
|
-
url.search = (0,
|
|
2324
|
+
url.search = (0, import_rest7.makeURLSearchParams)(options).toString();
|
|
2230
2325
|
return url.toString();
|
|
2231
2326
|
}
|
|
2232
2327
|
/**
|
|
@@ -2238,7 +2333,7 @@ var OAuth2API = class {
|
|
|
2238
2333
|
*/
|
|
2239
2334
|
async tokenExchange(body, { signal } = {}) {
|
|
2240
2335
|
return this.rest.post(import_v1010.Routes.oauth2TokenExchange(), {
|
|
2241
|
-
body: (0,
|
|
2336
|
+
body: (0, import_rest7.makeURLSearchParams)(body),
|
|
2242
2337
|
passThroughBody: true,
|
|
2243
2338
|
headers: {
|
|
2244
2339
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -2256,7 +2351,7 @@ var OAuth2API = class {
|
|
|
2256
2351
|
*/
|
|
2257
2352
|
async refreshToken(body, { signal } = {}) {
|
|
2258
2353
|
return this.rest.post(import_v1010.Routes.oauth2TokenExchange(), {
|
|
2259
|
-
body: (0,
|
|
2354
|
+
body: (0, import_rest7.makeURLSearchParams)(body),
|
|
2260
2355
|
passThroughBody: true,
|
|
2261
2356
|
headers: {
|
|
2262
2357
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -2276,7 +2371,7 @@ var OAuth2API = class {
|
|
|
2276
2371
|
*/
|
|
2277
2372
|
async getToken(body, { signal } = {}) {
|
|
2278
2373
|
return this.rest.post(import_v1010.Routes.oauth2TokenExchange(), {
|
|
2279
|
-
body: (0,
|
|
2374
|
+
body: (0, import_rest7.makeURLSearchParams)(body),
|
|
2280
2375
|
passThroughBody: true,
|
|
2281
2376
|
headers: {
|
|
2282
2377
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -2318,7 +2413,7 @@ var OAuth2API = class {
|
|
|
2318
2413
|
*/
|
|
2319
2414
|
async revokeToken(applicationId, applicationSecret, body, { signal } = {}) {
|
|
2320
2415
|
await this.rest.post(import_v1010.Routes.oauth2TokenRevocation(), {
|
|
2321
|
-
body: (0,
|
|
2416
|
+
body: (0, import_rest7.makeURLSearchParams)(body),
|
|
2322
2417
|
passThroughBody: true,
|
|
2323
2418
|
headers: {
|
|
2324
2419
|
Authorization: `Basic ${btoa(`${applicationId}:${applicationSecret}`)}`,
|
|
@@ -2331,7 +2426,7 @@ var OAuth2API = class {
|
|
|
2331
2426
|
};
|
|
2332
2427
|
|
|
2333
2428
|
// src/api/poll.ts
|
|
2334
|
-
var
|
|
2429
|
+
var import_rest8 = require("@discordjs/rest");
|
|
2335
2430
|
var import_v1011 = require("discord-api-types/v10");
|
|
2336
2431
|
var PollAPI = class {
|
|
2337
2432
|
constructor(rest) {
|
|
@@ -2350,10 +2445,10 @@ var PollAPI = class {
|
|
|
2350
2445
|
* @param query - The query for getting the list of voters
|
|
2351
2446
|
* @param options - The options for getting the list of voters
|
|
2352
2447
|
*/
|
|
2353
|
-
async getAnswerVoters(channelId, messageId, answerId, query, { signal } = {}) {
|
|
2448
|
+
async getAnswerVoters(channelId, messageId, answerId, query = {}, { signal } = {}) {
|
|
2354
2449
|
return this.rest.get(import_v1011.Routes.pollAnswerVoters(channelId, messageId, answerId), {
|
|
2355
2450
|
signal,
|
|
2356
|
-
query: (0,
|
|
2451
|
+
query: (0, import_rest8.makeURLSearchParams)(query)
|
|
2357
2452
|
});
|
|
2358
2453
|
}
|
|
2359
2454
|
/**
|
|
@@ -2408,8 +2503,30 @@ var RoleConnectionsAPI = class {
|
|
|
2408
2503
|
}
|
|
2409
2504
|
};
|
|
2410
2505
|
|
|
2411
|
-
// src/api/
|
|
2506
|
+
// src/api/soundboardSounds.ts
|
|
2412
2507
|
var import_v1013 = require("discord-api-types/v10");
|
|
2508
|
+
var SoundboardSoundsAPI = class {
|
|
2509
|
+
constructor(rest) {
|
|
2510
|
+
this.rest = rest;
|
|
2511
|
+
}
|
|
2512
|
+
static {
|
|
2513
|
+
__name(this, "SoundboardSoundsAPI");
|
|
2514
|
+
}
|
|
2515
|
+
/**
|
|
2516
|
+
* Fetches all the soundboard default sounds.
|
|
2517
|
+
*
|
|
2518
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#list-default-soundboard-sounds}
|
|
2519
|
+
* @param options - The options for fetching the soundboard default sounds.
|
|
2520
|
+
*/
|
|
2521
|
+
async getSoundboardDefaultSounds({ signal } = {}) {
|
|
2522
|
+
return this.rest.get(import_v1013.Routes.soundboardDefaultSounds(), {
|
|
2523
|
+
signal
|
|
2524
|
+
});
|
|
2525
|
+
}
|
|
2526
|
+
};
|
|
2527
|
+
|
|
2528
|
+
// src/api/stageInstances.ts
|
|
2529
|
+
var import_v1014 = require("discord-api-types/v10");
|
|
2413
2530
|
var StageInstancesAPI = class {
|
|
2414
2531
|
constructor(rest) {
|
|
2415
2532
|
this.rest = rest;
|
|
@@ -2425,7 +2542,7 @@ var StageInstancesAPI = class {
|
|
|
2425
2542
|
* @param options - The options for creating the new stage instance
|
|
2426
2543
|
*/
|
|
2427
2544
|
async create(body, { reason, signal } = {}) {
|
|
2428
|
-
return this.rest.post(
|
|
2545
|
+
return this.rest.post(import_v1014.Routes.stageInstances(), {
|
|
2429
2546
|
body,
|
|
2430
2547
|
reason,
|
|
2431
2548
|
signal
|
|
@@ -2439,7 +2556,7 @@ var StageInstancesAPI = class {
|
|
|
2439
2556
|
* @param options - The options for fetching the stage instance
|
|
2440
2557
|
*/
|
|
2441
2558
|
async get(channelId, { signal } = {}) {
|
|
2442
|
-
return this.rest.get(
|
|
2559
|
+
return this.rest.get(import_v1014.Routes.stageInstance(channelId), { signal });
|
|
2443
2560
|
}
|
|
2444
2561
|
/**
|
|
2445
2562
|
* Edits a stage instance
|
|
@@ -2450,7 +2567,7 @@ var StageInstancesAPI = class {
|
|
|
2450
2567
|
* @param options - The options for editing the stage instance
|
|
2451
2568
|
*/
|
|
2452
2569
|
async edit(channelId, body, { reason, signal } = {}) {
|
|
2453
|
-
return this.rest.patch(
|
|
2570
|
+
return this.rest.patch(import_v1014.Routes.stageInstance(channelId), {
|
|
2454
2571
|
body,
|
|
2455
2572
|
reason,
|
|
2456
2573
|
signal
|
|
@@ -2464,12 +2581,12 @@ var StageInstancesAPI = class {
|
|
|
2464
2581
|
* @param options - The options for deleting the stage instance
|
|
2465
2582
|
*/
|
|
2466
2583
|
async delete(channelId, { reason, signal } = {}) {
|
|
2467
|
-
await this.rest.delete(
|
|
2584
|
+
await this.rest.delete(import_v1014.Routes.stageInstance(channelId), { reason, signal });
|
|
2468
2585
|
}
|
|
2469
2586
|
};
|
|
2470
2587
|
|
|
2471
2588
|
// src/api/sticker.ts
|
|
2472
|
-
var
|
|
2589
|
+
var import_v1015 = require("discord-api-types/v10");
|
|
2473
2590
|
var StickersAPI = class {
|
|
2474
2591
|
constructor(rest) {
|
|
2475
2592
|
this.rest = rest;
|
|
@@ -2485,7 +2602,7 @@ var StickersAPI = class {
|
|
|
2485
2602
|
* @param options - The options for fetching the sticker pack
|
|
2486
2603
|
*/
|
|
2487
2604
|
async getStickerPack(packId, { signal } = {}) {
|
|
2488
|
-
return this.rest.get(
|
|
2605
|
+
return this.rest.get(import_v1015.Routes.stickerPack(packId), { signal });
|
|
2489
2606
|
}
|
|
2490
2607
|
/**
|
|
2491
2608
|
* Fetches all of the sticker packs
|
|
@@ -2494,7 +2611,7 @@ var StickersAPI = class {
|
|
|
2494
2611
|
* @param options - The options for fetching the sticker packs
|
|
2495
2612
|
*/
|
|
2496
2613
|
async getStickers({ signal } = {}) {
|
|
2497
|
-
return this.rest.get(
|
|
2614
|
+
return this.rest.get(import_v1015.Routes.stickerPacks(), { signal });
|
|
2498
2615
|
}
|
|
2499
2616
|
/**
|
|
2500
2617
|
* Fetches all of the sticker packs
|
|
@@ -2514,12 +2631,12 @@ var StickersAPI = class {
|
|
|
2514
2631
|
* @param options - The options for fetching the sticker
|
|
2515
2632
|
*/
|
|
2516
2633
|
async get(stickerId, { signal } = {}) {
|
|
2517
|
-
return this.rest.get(
|
|
2634
|
+
return this.rest.get(import_v1015.Routes.sticker(stickerId), { signal });
|
|
2518
2635
|
}
|
|
2519
2636
|
};
|
|
2520
2637
|
|
|
2521
2638
|
// src/api/thread.ts
|
|
2522
|
-
var
|
|
2639
|
+
var import_v1016 = require("discord-api-types/v10");
|
|
2523
2640
|
var ThreadsAPI = class {
|
|
2524
2641
|
constructor(rest) {
|
|
2525
2642
|
this.rest = rest;
|
|
@@ -2535,7 +2652,7 @@ var ThreadsAPI = class {
|
|
|
2535
2652
|
* @param options - The options for joining the thread
|
|
2536
2653
|
*/
|
|
2537
2654
|
async join(threadId, { signal } = {}) {
|
|
2538
|
-
await this.rest.put(
|
|
2655
|
+
await this.rest.put(import_v1016.Routes.threadMembers(threadId, "@me"), { signal });
|
|
2539
2656
|
}
|
|
2540
2657
|
/**
|
|
2541
2658
|
* Adds a member to a thread
|
|
@@ -2546,7 +2663,7 @@ var ThreadsAPI = class {
|
|
|
2546
2663
|
* @param options - The options for adding the member to the thread
|
|
2547
2664
|
*/
|
|
2548
2665
|
async addMember(threadId, userId, { signal } = {}) {
|
|
2549
|
-
await this.rest.put(
|
|
2666
|
+
await this.rest.put(import_v1016.Routes.threadMembers(threadId, userId), { signal });
|
|
2550
2667
|
}
|
|
2551
2668
|
/**
|
|
2552
2669
|
* Removes the current user from a thread
|
|
@@ -2556,7 +2673,7 @@ var ThreadsAPI = class {
|
|
|
2556
2673
|
* @param options - The options for leaving the thread
|
|
2557
2674
|
*/
|
|
2558
2675
|
async leave(threadId, { signal } = {}) {
|
|
2559
|
-
await this.rest.delete(
|
|
2676
|
+
await this.rest.delete(import_v1016.Routes.threadMembers(threadId, "@me"), { signal });
|
|
2560
2677
|
}
|
|
2561
2678
|
/**
|
|
2562
2679
|
* Removes a member from a thread
|
|
@@ -2567,7 +2684,7 @@ var ThreadsAPI = class {
|
|
|
2567
2684
|
* @param options - The options for removing the member from the thread
|
|
2568
2685
|
*/
|
|
2569
2686
|
async removeMember(threadId, userId, { signal } = {}) {
|
|
2570
|
-
await this.rest.delete(
|
|
2687
|
+
await this.rest.delete(import_v1016.Routes.threadMembers(threadId, userId), { signal });
|
|
2571
2688
|
}
|
|
2572
2689
|
/**
|
|
2573
2690
|
* Fetches a member of a thread
|
|
@@ -2578,7 +2695,7 @@ var ThreadsAPI = class {
|
|
|
2578
2695
|
* @param options - The options for fetching the member
|
|
2579
2696
|
*/
|
|
2580
2697
|
async getMember(threadId, userId, { signal } = {}) {
|
|
2581
|
-
return this.rest.get(
|
|
2698
|
+
return this.rest.get(import_v1016.Routes.threadMembers(threadId, userId), { signal });
|
|
2582
2699
|
}
|
|
2583
2700
|
/**
|
|
2584
2701
|
* Fetches all members of a thread
|
|
@@ -2588,13 +2705,13 @@ var ThreadsAPI = class {
|
|
|
2588
2705
|
* @param options - The options for fetching the members
|
|
2589
2706
|
*/
|
|
2590
2707
|
async getAllMembers(threadId, { signal } = {}) {
|
|
2591
|
-
return this.rest.get(
|
|
2708
|
+
return this.rest.get(import_v1016.Routes.threadMembers(threadId), { signal });
|
|
2592
2709
|
}
|
|
2593
2710
|
};
|
|
2594
2711
|
|
|
2595
2712
|
// src/api/user.ts
|
|
2596
|
-
var
|
|
2597
|
-
var
|
|
2713
|
+
var import_rest9 = require("@discordjs/rest");
|
|
2714
|
+
var import_v1017 = require("discord-api-types/v10");
|
|
2598
2715
|
var UsersAPI = class {
|
|
2599
2716
|
constructor(rest) {
|
|
2600
2717
|
this.rest = rest;
|
|
@@ -2610,7 +2727,7 @@ var UsersAPI = class {
|
|
|
2610
2727
|
* @param options - The options for fetching the user
|
|
2611
2728
|
*/
|
|
2612
2729
|
async get(userId, { signal } = {}) {
|
|
2613
|
-
return this.rest.get(
|
|
2730
|
+
return this.rest.get(import_v1017.Routes.user(userId), { signal });
|
|
2614
2731
|
}
|
|
2615
2732
|
/**
|
|
2616
2733
|
* Returns the user object of the requester's account
|
|
@@ -2619,7 +2736,7 @@ var UsersAPI = class {
|
|
|
2619
2736
|
* @param options - The options for fetching the current user
|
|
2620
2737
|
*/
|
|
2621
2738
|
async getCurrent({ signal } = {}) {
|
|
2622
|
-
return this.rest.get(
|
|
2739
|
+
return this.rest.get(import_v1017.Routes.user("@me"), { signal });
|
|
2623
2740
|
}
|
|
2624
2741
|
/**
|
|
2625
2742
|
* Returns a list of partial guild objects the current user is a member of
|
|
@@ -2629,8 +2746,8 @@ var UsersAPI = class {
|
|
|
2629
2746
|
* @param options - The options for fetching the guilds
|
|
2630
2747
|
*/
|
|
2631
2748
|
async getGuilds(query = {}, { signal } = {}) {
|
|
2632
|
-
return this.rest.get(
|
|
2633
|
-
query: (0,
|
|
2749
|
+
return this.rest.get(import_v1017.Routes.userGuilds(), {
|
|
2750
|
+
query: (0, import_rest9.makeURLSearchParams)(query),
|
|
2634
2751
|
signal
|
|
2635
2752
|
});
|
|
2636
2753
|
}
|
|
@@ -2642,7 +2759,7 @@ var UsersAPI = class {
|
|
|
2642
2759
|
* @param options - The options for leaving the guild
|
|
2643
2760
|
*/
|
|
2644
2761
|
async leaveGuild(guildId, { signal } = {}) {
|
|
2645
|
-
await this.rest.delete(
|
|
2762
|
+
await this.rest.delete(import_v1017.Routes.userGuild(guildId), { signal });
|
|
2646
2763
|
}
|
|
2647
2764
|
/**
|
|
2648
2765
|
* Edits the current user
|
|
@@ -2652,7 +2769,7 @@ var UsersAPI = class {
|
|
|
2652
2769
|
* @param options - The options for editing the user
|
|
2653
2770
|
*/
|
|
2654
2771
|
async edit(body, { signal } = {}) {
|
|
2655
|
-
return this.rest.patch(
|
|
2772
|
+
return this.rest.patch(import_v1017.Routes.user("@me"), { body, signal });
|
|
2656
2773
|
}
|
|
2657
2774
|
/**
|
|
2658
2775
|
* Fetches the guild member for the current user
|
|
@@ -2662,7 +2779,7 @@ var UsersAPI = class {
|
|
|
2662
2779
|
* @param options - The options for fetching the guild member
|
|
2663
2780
|
*/
|
|
2664
2781
|
async getGuildMember(guildId, { signal } = {}) {
|
|
2665
|
-
return this.rest.get(
|
|
2782
|
+
return this.rest.get(import_v1017.Routes.userGuildMember(guildId), { signal });
|
|
2666
2783
|
}
|
|
2667
2784
|
/**
|
|
2668
2785
|
* Edits the guild member for the current user
|
|
@@ -2673,7 +2790,7 @@ var UsersAPI = class {
|
|
|
2673
2790
|
* @param options - The options for editing the guild member
|
|
2674
2791
|
*/
|
|
2675
2792
|
async editCurrentGuildMember(guildId, body = {}, { reason, signal } = {}) {
|
|
2676
|
-
return this.rest.patch(
|
|
2793
|
+
return this.rest.patch(import_v1017.Routes.guildMember(guildId, "@me"), {
|
|
2677
2794
|
reason,
|
|
2678
2795
|
body,
|
|
2679
2796
|
signal
|
|
@@ -2687,7 +2804,7 @@ var UsersAPI = class {
|
|
|
2687
2804
|
* @param options - The options for opening the DM
|
|
2688
2805
|
*/
|
|
2689
2806
|
async createDM(userId, { signal } = {}) {
|
|
2690
|
-
return this.rest.post(
|
|
2807
|
+
return this.rest.post(import_v1017.Routes.userChannels(), {
|
|
2691
2808
|
body: { recipient_id: userId },
|
|
2692
2809
|
signal
|
|
2693
2810
|
});
|
|
@@ -2699,7 +2816,7 @@ var UsersAPI = class {
|
|
|
2699
2816
|
* @param options - The options for fetching the user's connections
|
|
2700
2817
|
*/
|
|
2701
2818
|
async getConnections({ signal } = {}) {
|
|
2702
|
-
return this.rest.get(
|
|
2819
|
+
return this.rest.get(import_v1017.Routes.userConnections(), { signal });
|
|
2703
2820
|
}
|
|
2704
2821
|
/**
|
|
2705
2822
|
* Gets the current user's active application role connection
|
|
@@ -2709,7 +2826,7 @@ var UsersAPI = class {
|
|
|
2709
2826
|
* @param options - The options for fetching the role connections
|
|
2710
2827
|
*/
|
|
2711
2828
|
async getApplicationRoleConnection(applicationId, { signal } = {}) {
|
|
2712
|
-
return this.rest.get(
|
|
2829
|
+
return this.rest.get(import_v1017.Routes.userApplicationRoleConnection(applicationId), {
|
|
2713
2830
|
signal
|
|
2714
2831
|
});
|
|
2715
2832
|
}
|
|
@@ -2722,7 +2839,7 @@ var UsersAPI = class {
|
|
|
2722
2839
|
* @param options - The options for updating the application role connection
|
|
2723
2840
|
*/
|
|
2724
2841
|
async updateApplicationRoleConnection(applicationId, body, { signal } = {}) {
|
|
2725
|
-
return this.rest.put(
|
|
2842
|
+
return this.rest.put(import_v1017.Routes.userApplicationRoleConnection(applicationId), {
|
|
2726
2843
|
body,
|
|
2727
2844
|
signal
|
|
2728
2845
|
});
|
|
@@ -2730,8 +2847,8 @@ var UsersAPI = class {
|
|
|
2730
2847
|
};
|
|
2731
2848
|
|
|
2732
2849
|
// src/api/webhook.ts
|
|
2733
|
-
var
|
|
2734
|
-
var
|
|
2850
|
+
var import_rest10 = require("@discordjs/rest");
|
|
2851
|
+
var import_v1018 = require("discord-api-types/v10");
|
|
2735
2852
|
var WebhooksAPI = class {
|
|
2736
2853
|
constructor(rest) {
|
|
2737
2854
|
this.rest = rest;
|
|
@@ -2748,7 +2865,7 @@ var WebhooksAPI = class {
|
|
|
2748
2865
|
* @param options - The options for fetching the webhook
|
|
2749
2866
|
*/
|
|
2750
2867
|
async get(id, { token, signal } = {}) {
|
|
2751
|
-
return this.rest.get(
|
|
2868
|
+
return this.rest.get(import_v1018.Routes.webhook(id, token), {
|
|
2752
2869
|
signal,
|
|
2753
2870
|
auth: !token
|
|
2754
2871
|
});
|
|
@@ -2763,7 +2880,7 @@ var WebhooksAPI = class {
|
|
|
2763
2880
|
* @param options - The options for editing the webhook
|
|
2764
2881
|
*/
|
|
2765
2882
|
async edit(id, body, { token, reason, signal } = {}) {
|
|
2766
|
-
return this.rest.patch(
|
|
2883
|
+
return this.rest.patch(import_v1018.Routes.webhook(id, token), {
|
|
2767
2884
|
reason,
|
|
2768
2885
|
body,
|
|
2769
2886
|
signal,
|
|
@@ -2779,7 +2896,7 @@ var WebhooksAPI = class {
|
|
|
2779
2896
|
* @param options - The options for deleting the webhook
|
|
2780
2897
|
*/
|
|
2781
2898
|
async delete(id, { token, reason, signal } = {}) {
|
|
2782
|
-
await this.rest.delete(
|
|
2899
|
+
await this.rest.delete(import_v1018.Routes.webhook(id, token), {
|
|
2783
2900
|
reason,
|
|
2784
2901
|
signal,
|
|
2785
2902
|
auth: !token
|
|
@@ -2794,15 +2911,9 @@ var WebhooksAPI = class {
|
|
|
2794
2911
|
* @param body - The data for executing the webhook
|
|
2795
2912
|
* @param options - The options for executing the webhook
|
|
2796
2913
|
*/
|
|
2797
|
-
async execute(id, token, {
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
with_components,
|
|
2801
|
-
files,
|
|
2802
|
-
...body
|
|
2803
|
-
}, { signal } = {}) {
|
|
2804
|
-
return this.rest.post(import_v1017.Routes.webhook(id, token), {
|
|
2805
|
-
query: (0, import_rest9.makeURLSearchParams)({ wait, thread_id, with_components }),
|
|
2914
|
+
async execute(id, token, { wait, thread_id, with_components, files, ...body }, { signal } = {}) {
|
|
2915
|
+
return this.rest.post(import_v1018.Routes.webhook(id, token), {
|
|
2916
|
+
query: (0, import_rest10.makeURLSearchParams)({ wait, thread_id, with_components }),
|
|
2806
2917
|
files,
|
|
2807
2918
|
body,
|
|
2808
2919
|
auth: false,
|
|
@@ -2821,8 +2932,8 @@ var WebhooksAPI = class {
|
|
|
2821
2932
|
* @param options - The options for executing the webhook
|
|
2822
2933
|
*/
|
|
2823
2934
|
async executeSlack(id, token, body, query = {}, { signal } = {}) {
|
|
2824
|
-
await this.rest.post(
|
|
2825
|
-
query: (0,
|
|
2935
|
+
await this.rest.post(import_v1018.Routes.webhookPlatform(id, token, "slack"), {
|
|
2936
|
+
query: (0, import_rest10.makeURLSearchParams)(query),
|
|
2826
2937
|
body,
|
|
2827
2938
|
auth: false,
|
|
2828
2939
|
signal
|
|
@@ -2839,8 +2950,8 @@ var WebhooksAPI = class {
|
|
|
2839
2950
|
* @param options - The options for executing the webhook
|
|
2840
2951
|
*/
|
|
2841
2952
|
async executeGitHub(id, token, body, query = {}, { signal } = {}) {
|
|
2842
|
-
await this.rest.post(
|
|
2843
|
-
query: (0,
|
|
2953
|
+
await this.rest.post(import_v1018.Routes.webhookPlatform(id, token, "github"), {
|
|
2954
|
+
query: (0, import_rest10.makeURLSearchParams)(query),
|
|
2844
2955
|
body,
|
|
2845
2956
|
signal,
|
|
2846
2957
|
auth: false
|
|
@@ -2857,8 +2968,8 @@ var WebhooksAPI = class {
|
|
|
2857
2968
|
* @param options - The options for fetching the message
|
|
2858
2969
|
*/
|
|
2859
2970
|
async getMessage(id, token, messageId, query = {}, { signal } = {}) {
|
|
2860
|
-
return this.rest.get(
|
|
2861
|
-
query: (0,
|
|
2971
|
+
return this.rest.get(import_v1018.Routes.webhookMessage(id, token, messageId), {
|
|
2972
|
+
query: (0, import_rest10.makeURLSearchParams)(query),
|
|
2862
2973
|
auth: false,
|
|
2863
2974
|
signal
|
|
2864
2975
|
});
|
|
@@ -2873,14 +2984,9 @@ var WebhooksAPI = class {
|
|
|
2873
2984
|
* @param body - The data for editing the message
|
|
2874
2985
|
* @param options - The options for editing the message
|
|
2875
2986
|
*/
|
|
2876
|
-
async editMessage(id, token, messageId, {
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
files,
|
|
2880
|
-
...body
|
|
2881
|
-
}, { signal } = {}) {
|
|
2882
|
-
return this.rest.patch(import_v1017.Routes.webhookMessage(id, token, messageId), {
|
|
2883
|
-
query: (0, import_rest9.makeURLSearchParams)({ thread_id, with_components }),
|
|
2987
|
+
async editMessage(id, token, messageId, { thread_id, with_components, files, ...body }, { signal } = {}) {
|
|
2988
|
+
return this.rest.patch(import_v1018.Routes.webhookMessage(id, token, messageId), {
|
|
2989
|
+
query: (0, import_rest10.makeURLSearchParams)({ thread_id, with_components }),
|
|
2884
2990
|
auth: false,
|
|
2885
2991
|
body,
|
|
2886
2992
|
signal,
|
|
@@ -2898,8 +3004,8 @@ var WebhooksAPI = class {
|
|
|
2898
3004
|
* @param options - The options for deleting the message
|
|
2899
3005
|
*/
|
|
2900
3006
|
async deleteMessage(id, token, messageId, query = {}, { signal } = {}) {
|
|
2901
|
-
await this.rest.delete(
|
|
2902
|
-
query: (0,
|
|
3007
|
+
await this.rest.delete(import_v1018.Routes.webhookMessage(id, token, messageId), {
|
|
3008
|
+
query: (0, import_rest10.makeURLSearchParams)(query),
|
|
2903
3009
|
auth: false,
|
|
2904
3010
|
signal
|
|
2905
3011
|
});
|
|
@@ -2920,6 +3026,7 @@ var API = class {
|
|
|
2920
3026
|
this.oauth2 = new OAuth2API(rest);
|
|
2921
3027
|
this.poll = new PollAPI(rest);
|
|
2922
3028
|
this.roleConnections = new RoleConnectionsAPI(rest);
|
|
3029
|
+
this.soundboardSounds = new SoundboardSoundsAPI(rest);
|
|
2923
3030
|
this.stageInstances = new StageInstancesAPI(rest);
|
|
2924
3031
|
this.stickers = new StickersAPI(rest);
|
|
2925
3032
|
this.threads = new ThreadsAPI(rest);
|
|
@@ -2942,6 +3049,7 @@ var API = class {
|
|
|
2942
3049
|
oauth2;
|
|
2943
3050
|
poll;
|
|
2944
3051
|
roleConnections;
|
|
3052
|
+
soundboardSounds;
|
|
2945
3053
|
stageInstances;
|
|
2946
3054
|
stickers;
|
|
2947
3055
|
threads;
|
|
@@ -2956,7 +3064,11 @@ var import_util = require("@discordjs/util");
|
|
|
2956
3064
|
var import_ws = require("@discordjs/ws");
|
|
2957
3065
|
var import_snowflake = require("@sapphire/snowflake");
|
|
2958
3066
|
var import_async_event_emitter = require("@vladfrangu/async_event_emitter");
|
|
2959
|
-
var
|
|
3067
|
+
var import_v1019 = require("discord-api-types/v10");
|
|
3068
|
+
function createTimer(controller, timeout) {
|
|
3069
|
+
return (0, import_node_timers.setTimeout)(() => controller.abort(), timeout);
|
|
3070
|
+
}
|
|
3071
|
+
__name(createTimer, "createTimer");
|
|
2960
3072
|
var Client = class extends import_async_event_emitter.AsyncEventEmitter {
|
|
2961
3073
|
static {
|
|
2962
3074
|
__name(this, "Client");
|
|
@@ -2991,12 +3103,21 @@ var Client = class extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
2991
3103
|
const shardId = (0, import_util.calculateShardId)(options.guild_id, await this.gateway.getShardCount());
|
|
2992
3104
|
const nonce = options.nonce ?? import_snowflake.DiscordSnowflake.generate().toString();
|
|
2993
3105
|
const controller = new AbortController();
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
3106
|
+
let timer = createTimer(controller, timeout);
|
|
3107
|
+
const onRatelimit = /* @__PURE__ */ __name(({ data }) => {
|
|
3108
|
+
if (data.meta.nonce === nonce) {
|
|
3109
|
+
controller.abort(new import_util.GatewayRateLimitError(data, options));
|
|
3110
|
+
}
|
|
3111
|
+
}, "onRatelimit");
|
|
3112
|
+
const cleanup = /* @__PURE__ */ __name(() => {
|
|
3113
|
+
if (timer) {
|
|
3114
|
+
(0, import_node_timers.clearTimeout)(timer);
|
|
3115
|
+
}
|
|
3116
|
+
this.off(import_v1019.GatewayDispatchEvents.RateLimited, onRatelimit);
|
|
3117
|
+
}, "cleanup");
|
|
3118
|
+
this.on(import_v1019.GatewayDispatchEvents.RateLimited, onRatelimit);
|
|
2998
3119
|
await this.gateway.send(shardId, {
|
|
2999
|
-
op:
|
|
3120
|
+
op: import_v1019.GatewayOpcodes.RequestGuildMembers,
|
|
3000
3121
|
// eslint-disable-next-line id-length
|
|
3001
3122
|
d: {
|
|
3002
3123
|
...options,
|
|
@@ -3004,7 +3125,7 @@ var Client = class extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
3004
3125
|
}
|
|
3005
3126
|
});
|
|
3006
3127
|
try {
|
|
3007
|
-
const iterator = import_async_event_emitter.AsyncEventEmitter.on(this,
|
|
3128
|
+
const iterator = import_async_event_emitter.AsyncEventEmitter.on(this, import_v1019.GatewayDispatchEvents.GuildMembersChunk, {
|
|
3008
3129
|
signal: controller.signal
|
|
3009
3130
|
});
|
|
3010
3131
|
for await (const [{ data }] of iterator) {
|
|
@@ -3019,21 +3140,19 @@ var Client = class extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
3019
3140
|
chunkIndex: data.chunk_index,
|
|
3020
3141
|
chunkCount: data.chunk_count
|
|
3021
3142
|
};
|
|
3022
|
-
if (data.chunk_index >= data.chunk_count - 1)
|
|
3023
|
-
|
|
3024
|
-
} else {
|
|
3025
|
-
timer = createTimer();
|
|
3026
|
-
}
|
|
3143
|
+
if (data.chunk_index >= data.chunk_count - 1) break;
|
|
3144
|
+
timer = createTimer(controller, timeout);
|
|
3027
3145
|
}
|
|
3028
3146
|
} catch (error) {
|
|
3029
3147
|
if (error instanceof Error && error.name === "AbortError") {
|
|
3148
|
+
if (error.cause instanceof import_util.GatewayRateLimitError) {
|
|
3149
|
+
throw error.cause;
|
|
3150
|
+
}
|
|
3030
3151
|
throw new Error("Request timed out");
|
|
3031
3152
|
}
|
|
3032
3153
|
throw error;
|
|
3033
3154
|
} finally {
|
|
3034
|
-
|
|
3035
|
-
(0, import_node_timers.clearTimeout)(timer);
|
|
3036
|
-
}
|
|
3155
|
+
cleanup();
|
|
3037
3156
|
}
|
|
3038
3157
|
}
|
|
3039
3158
|
/**
|
|
@@ -3060,6 +3179,86 @@ var Client = class extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
3060
3179
|
}
|
|
3061
3180
|
return { members, nonce, notFound, presences };
|
|
3062
3181
|
}
|
|
3182
|
+
/**
|
|
3183
|
+
* Requests soundboard sounds from the gateway and returns an async iterator that yields the data from each soundboard sounds event.
|
|
3184
|
+
*
|
|
3185
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds}
|
|
3186
|
+
* @param options - The options for the request
|
|
3187
|
+
* @param timeout - The timeout for waiting for each soundboard sounds
|
|
3188
|
+
* @example
|
|
3189
|
+
* Requesting soundboard sounds for specific guilds
|
|
3190
|
+
* ```ts
|
|
3191
|
+
* for await (const { guildId, soundboardSounds } of this.requestSoundboardSoundsIterator({
|
|
3192
|
+
* guild_ids: ['1234567890', '9876543210'],
|
|
3193
|
+
* })) {
|
|
3194
|
+
* console.log(`Soundboard sounds for guild ${guildId}:`, soundboardSounds);
|
|
3195
|
+
* }
|
|
3196
|
+
* ```
|
|
3197
|
+
*/
|
|
3198
|
+
async *requestSoundboardSoundsIterator(options, timeout = 1e4) {
|
|
3199
|
+
const shardCount = await this.gateway.getShardCount();
|
|
3200
|
+
const shardIds = Map.groupBy(options.guild_ids, (guildId) => (0, import_util.calculateShardId)(guildId, shardCount));
|
|
3201
|
+
const controller = new AbortController();
|
|
3202
|
+
let timer = createTimer(controller, timeout);
|
|
3203
|
+
for (const [shardId, guildIds] of shardIds) {
|
|
3204
|
+
await this.gateway.send(shardId, {
|
|
3205
|
+
op: import_v1019.GatewayOpcodes.RequestSoundboardSounds,
|
|
3206
|
+
// eslint-disable-next-line id-length
|
|
3207
|
+
d: {
|
|
3208
|
+
...options,
|
|
3209
|
+
guild_ids: guildIds
|
|
3210
|
+
}
|
|
3211
|
+
});
|
|
3212
|
+
}
|
|
3213
|
+
try {
|
|
3214
|
+
const iterator = import_async_event_emitter.AsyncEventEmitter.on(this, import_v1019.GatewayDispatchEvents.SoundboardSounds, {
|
|
3215
|
+
signal: controller.signal
|
|
3216
|
+
});
|
|
3217
|
+
const guildIds = new Set(options.guild_ids);
|
|
3218
|
+
for await (const [{ data }] of iterator) {
|
|
3219
|
+
if (!guildIds.has(data.guild_id)) continue;
|
|
3220
|
+
(0, import_node_timers.clearTimeout)(timer);
|
|
3221
|
+
timer = void 0;
|
|
3222
|
+
yield {
|
|
3223
|
+
guildId: data.guild_id,
|
|
3224
|
+
soundboardSounds: data.soundboard_sounds
|
|
3225
|
+
};
|
|
3226
|
+
guildIds.delete(data.guild_id);
|
|
3227
|
+
if (guildIds.size === 0) break;
|
|
3228
|
+
timer = createTimer(controller, timeout);
|
|
3229
|
+
}
|
|
3230
|
+
} catch (error) {
|
|
3231
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
3232
|
+
throw new Error("Request timed out");
|
|
3233
|
+
}
|
|
3234
|
+
throw error;
|
|
3235
|
+
} finally {
|
|
3236
|
+
if (timer) {
|
|
3237
|
+
(0, import_node_timers.clearTimeout)(timer);
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
/**
|
|
3242
|
+
* Requests soundboard sounds from the gateway.
|
|
3243
|
+
*
|
|
3244
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds}
|
|
3245
|
+
* @param options - The options for the request
|
|
3246
|
+
* @param timeout - The timeout for waiting for each soundboard sounds event
|
|
3247
|
+
* @example
|
|
3248
|
+
* Requesting soundboard sounds for specific guilds
|
|
3249
|
+
* ```ts
|
|
3250
|
+
* const soundboardSounds = await client.requestSoundboardSounds({ guild_ids: ['1234567890', '9876543210'], });
|
|
3251
|
+
*
|
|
3252
|
+
* console.log(soundboardSounds.get('1234567890'));
|
|
3253
|
+
* ```
|
|
3254
|
+
*/
|
|
3255
|
+
async requestSoundboardSounds(options, timeout = 1e4) {
|
|
3256
|
+
const soundboardSounds = /* @__PURE__ */ new Map();
|
|
3257
|
+
for await (const data of this.requestSoundboardSoundsIterator(options, timeout)) {
|
|
3258
|
+
soundboardSounds.set(data.guildId, data.soundboardSounds);
|
|
3259
|
+
}
|
|
3260
|
+
return soundboardSounds;
|
|
3261
|
+
}
|
|
3063
3262
|
/**
|
|
3064
3263
|
* Updates the voice state of the bot user
|
|
3065
3264
|
*
|
|
@@ -3069,7 +3268,7 @@ var Client = class extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
3069
3268
|
async updateVoiceState(options) {
|
|
3070
3269
|
const shardId = (0, import_util.calculateShardId)(options.guild_id, await this.gateway.getShardCount());
|
|
3071
3270
|
await this.gateway.send(shardId, {
|
|
3072
|
-
op:
|
|
3271
|
+
op: import_v1019.GatewayOpcodes.VoiceStateUpdate,
|
|
3073
3272
|
// eslint-disable-next-line id-length
|
|
3074
3273
|
d: options
|
|
3075
3274
|
});
|
|
@@ -3082,7 +3281,7 @@ var Client = class extends import_async_event_emitter.AsyncEventEmitter {
|
|
|
3082
3281
|
*/
|
|
3083
3282
|
async updatePresence(shardId, options) {
|
|
3084
3283
|
await this.gateway.send(shardId, {
|
|
3085
|
-
op:
|
|
3284
|
+
op: import_v1019.GatewayOpcodes.PresenceUpdate,
|
|
3086
3285
|
// eslint-disable-next-line id-length
|
|
3087
3286
|
d: options
|
|
3088
3287
|
});
|
|
@@ -3114,8 +3313,9 @@ function withFiles(files, options) {
|
|
|
3114
3313
|
__name(withFiles, "withFiles");
|
|
3115
3314
|
|
|
3116
3315
|
// src/index.ts
|
|
3117
|
-
__reExport(
|
|
3118
|
-
var
|
|
3316
|
+
__reExport(index_exports, require("discord-api-types/v10"), module.exports);
|
|
3317
|
+
var import_util2 = require("@discordjs/util");
|
|
3318
|
+
var version = "2.4.0";
|
|
3119
3319
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3120
3320
|
0 && (module.exports = {
|
|
3121
3321
|
API,
|
|
@@ -3124,6 +3324,7 @@ var version = "2.3.0";
|
|
|
3124
3324
|
ChannelsAPI,
|
|
3125
3325
|
Client,
|
|
3126
3326
|
GatewayAPI,
|
|
3327
|
+
GatewayRateLimitError,
|
|
3127
3328
|
GuildsAPI,
|
|
3128
3329
|
InteractionsAPI,
|
|
3129
3330
|
InvitesAPI,
|
|
@@ -3131,6 +3332,7 @@ var version = "2.3.0";
|
|
|
3131
3332
|
OAuth2API,
|
|
3132
3333
|
PollAPI,
|
|
3133
3334
|
RoleConnectionsAPI,
|
|
3335
|
+
SoundboardSoundsAPI,
|
|
3134
3336
|
StageInstancesAPI,
|
|
3135
3337
|
StickersAPI,
|
|
3136
3338
|
ThreadsAPI,
|