@discordjs/core 2.3.0 → 2.5.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 +349 -53
- package/dist/http-only.d.ts +349 -53
- package/dist/http-only.js +272 -150
- package/dist/http-only.js.map +1 -1
- package/dist/http-only.mjs +274 -151
- package/dist/http-only.mjs.map +1 -1
- package/dist/index.d.mts +394 -53
- package/dist/index.d.ts +394 -53
- package/dist/index.js +387 -171
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +381 -165
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
package/dist/index.mjs
CHANGED
|
@@ -753,6 +753,20 @@ var ChannelsAPI = class {
|
|
|
753
753
|
signal
|
|
754
754
|
});
|
|
755
755
|
}
|
|
756
|
+
/**
|
|
757
|
+
* Sends a soundboard sound in a channel
|
|
758
|
+
*
|
|
759
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#send-soundboard-sound}
|
|
760
|
+
* @param channelId - The id of the channel to send the soundboard sound in
|
|
761
|
+
* @param body - The data for sending the soundboard sound
|
|
762
|
+
* @param options - The options for sending the soundboard sound
|
|
763
|
+
*/
|
|
764
|
+
async sendSoundboardSound(channelId, body, { signal } = {}) {
|
|
765
|
+
return this.rest.post(Routes3.sendSoundboardSound(channelId), {
|
|
766
|
+
body,
|
|
767
|
+
signal
|
|
768
|
+
});
|
|
769
|
+
}
|
|
756
770
|
/**
|
|
757
771
|
* Adds a recipient to a group DM channel
|
|
758
772
|
*
|
|
@@ -977,7 +991,7 @@ var GuildsAPI = class {
|
|
|
977
991
|
});
|
|
978
992
|
}
|
|
979
993
|
/**
|
|
980
|
-
* Fetches
|
|
994
|
+
* Fetches members of a guild.
|
|
981
995
|
*
|
|
982
996
|
* @see {@link https://discord.com/developers/docs/resources/guild#list-guild-members}
|
|
983
997
|
* @param guildId - The id of the guild
|
|
@@ -1730,6 +1744,20 @@ var GuildsAPI = class {
|
|
|
1730
1744
|
signal
|
|
1731
1745
|
});
|
|
1732
1746
|
}
|
|
1747
|
+
/**
|
|
1748
|
+
* Searches for messages.
|
|
1749
|
+
*
|
|
1750
|
+
* @see {@link https://docs.discord.com/developers/resources/message#search-guild-messages}
|
|
1751
|
+
* @param guildId - The id of the guild to search in
|
|
1752
|
+
* @param query - The query to search for
|
|
1753
|
+
* @param options - The options for searching for messages
|
|
1754
|
+
*/
|
|
1755
|
+
async searchForMessages(guildId, query, { signal } = {}) {
|
|
1756
|
+
return this.rest.get(Routes6.guildMessagesSearch(guildId), {
|
|
1757
|
+
query: makeURLSearchParams3(query),
|
|
1758
|
+
signal
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1733
1761
|
/**
|
|
1734
1762
|
* Edits a guild member
|
|
1735
1763
|
*
|
|
@@ -1848,6 +1876,73 @@ var GuildsAPI = class {
|
|
|
1848
1876
|
signal
|
|
1849
1877
|
});
|
|
1850
1878
|
}
|
|
1879
|
+
/**
|
|
1880
|
+
* Fetches all the soundboard sounds for a guild
|
|
1881
|
+
*
|
|
1882
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#list-guild-soundboard-sounds}
|
|
1883
|
+
* @param guildId - The id of the guild to fetch the soundboard sounds for
|
|
1884
|
+
* @param options - The options for fetching the soundboard sounds
|
|
1885
|
+
*/
|
|
1886
|
+
async getSoundboardSounds(guildId, { signal } = {}) {
|
|
1887
|
+
return this.rest.get(Routes6.guildSoundboardSounds(guildId), {
|
|
1888
|
+
signal
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* Fetches a soundboard sound for a guild
|
|
1893
|
+
*
|
|
1894
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#get-guild-soundboard-sound}
|
|
1895
|
+
* @param guildId - The id of the guild to fetch the soundboard sound for
|
|
1896
|
+
* @param soundId - The id of the soundboard sound to fetch
|
|
1897
|
+
* @param options - The options for fetching the soundboard sound
|
|
1898
|
+
*/
|
|
1899
|
+
async getSoundboardSound(guildId, soundId, { signal } = {}) {
|
|
1900
|
+
return this.rest.get(Routes6.guildSoundboardSound(guildId, soundId), {
|
|
1901
|
+
signal
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Creates a new soundboard sound for a guild
|
|
1906
|
+
*
|
|
1907
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#create-guild-soundboard-sound}
|
|
1908
|
+
* @param guildId - The id of the guild to create the soundboard sound for
|
|
1909
|
+
* @param body - The data for creating the soundboard sound
|
|
1910
|
+
* @param options - The options for creating the soundboard sound
|
|
1911
|
+
*/
|
|
1912
|
+
async createSoundboardSound(guildId, body, { reason, signal } = {}) {
|
|
1913
|
+
return this.rest.post(Routes6.guildSoundboardSounds(guildId), {
|
|
1914
|
+
body,
|
|
1915
|
+
reason,
|
|
1916
|
+
signal
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* Edits a soundboard sound for a guild
|
|
1921
|
+
*
|
|
1922
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#modify-guild-soundboard-sound}
|
|
1923
|
+
* @param guildId - The id of the guild to edit the soundboard sound for
|
|
1924
|
+
* @param soundId - The id of the soundboard sound to edit
|
|
1925
|
+
* @param body - The data for editing the soundboard sound
|
|
1926
|
+
* @param options - The options for editing the soundboard sound
|
|
1927
|
+
*/
|
|
1928
|
+
async editSoundboardSound(guildId, soundId, body, { reason, signal } = {}) {
|
|
1929
|
+
return this.rest.patch(Routes6.guildSoundboardSound(guildId, soundId), {
|
|
1930
|
+
body,
|
|
1931
|
+
reason,
|
|
1932
|
+
signal
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Deletes a soundboard sound for a guild
|
|
1937
|
+
*
|
|
1938
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#delete-guild-soundboard-sound}
|
|
1939
|
+
* @param guildId - The id of the guild to delete the soundboard sound for
|
|
1940
|
+
* @param soundId - The id of the soundboard sound to delete
|
|
1941
|
+
* @param options - The options for deleting the soundboard sound
|
|
1942
|
+
*/
|
|
1943
|
+
async deleteSoundboardSound(guildId, soundId, { reason, signal } = {}) {
|
|
1944
|
+
await this.rest.delete(Routes6.guildSoundboardSound(guildId, soundId), { reason, signal });
|
|
1945
|
+
}
|
|
1851
1946
|
/**
|
|
1852
1947
|
* Modifies incident actions for a guild.
|
|
1853
1948
|
*
|
|
@@ -1865,6 +1960,7 @@ var GuildsAPI = class {
|
|
|
1865
1960
|
};
|
|
1866
1961
|
|
|
1867
1962
|
// src/api/interactions.ts
|
|
1963
|
+
import { makeURLSearchParams as makeURLSearchParams4 } from "@discordjs/rest";
|
|
1868
1964
|
import {
|
|
1869
1965
|
InteractionResponseType,
|
|
1870
1966
|
Routes as Routes7
|
|
@@ -1877,17 +1973,9 @@ var InteractionsAPI = class {
|
|
|
1877
1973
|
static {
|
|
1878
1974
|
__name(this, "InteractionsAPI");
|
|
1879
1975
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1884
|
-
* @param interactionId - The id of the interaction
|
|
1885
|
-
* @param interactionToken - The token of the interaction
|
|
1886
|
-
* @param body - The callback data for replying
|
|
1887
|
-
* @param options - The options for replying
|
|
1888
|
-
*/
|
|
1889
|
-
async reply(interactionId, interactionToken, { files, ...data }, { signal } = {}) {
|
|
1890
|
-
await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
1976
|
+
async reply(interactionId, interactionToken, { files, with_response, ...data }, { signal } = {}) {
|
|
1977
|
+
const response = await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
1978
|
+
query: makeURLSearchParams4({ with_response }),
|
|
1891
1979
|
files,
|
|
1892
1980
|
auth: false,
|
|
1893
1981
|
body: {
|
|
@@ -1896,18 +1984,11 @@ var InteractionsAPI = class {
|
|
|
1896
1984
|
},
|
|
1897
1985
|
signal
|
|
1898
1986
|
});
|
|
1987
|
+
return with_response ? response : void 0;
|
|
1899
1988
|
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1904
|
-
* @param interactionId - The id of the interaction
|
|
1905
|
-
* @param interactionToken - The token of the interaction
|
|
1906
|
-
* @param data - The data for deferring the reply
|
|
1907
|
-
* @param options - The options for deferring
|
|
1908
|
-
*/
|
|
1909
|
-
async defer(interactionId, interactionToken, data, { signal } = {}) {
|
|
1910
|
-
await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
1989
|
+
async defer(interactionId, interactionToken, { with_response, ...data } = {}, { signal } = {}) {
|
|
1990
|
+
const response = await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
1991
|
+
query: makeURLSearchParams4({ with_response }),
|
|
1911
1992
|
auth: false,
|
|
1912
1993
|
body: {
|
|
1913
1994
|
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
|
@@ -1915,23 +1996,18 @@ var InteractionsAPI = class {
|
|
|
1915
1996
|
},
|
|
1916
1997
|
signal
|
|
1917
1998
|
});
|
|
1999
|
+
return with_response ? response : void 0;
|
|
1918
2000
|
}
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1923
|
-
* @param interactionId - The id of the interaction
|
|
1924
|
-
* @param interactionToken - The token of the interaction
|
|
1925
|
-
* @param options - The options for deferring
|
|
1926
|
-
*/
|
|
1927
|
-
async deferMessageUpdate(interactionId, interactionToken, { signal } = {}) {
|
|
1928
|
-
await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
2001
|
+
async deferMessageUpdate(interactionId, interactionToken, { with_response } = {}, { signal } = {}) {
|
|
2002
|
+
const response = await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
2003
|
+
query: makeURLSearchParams4({ with_response }),
|
|
1929
2004
|
auth: false,
|
|
1930
2005
|
body: {
|
|
1931
2006
|
type: InteractionResponseType.DeferredMessageUpdate
|
|
1932
2007
|
},
|
|
1933
2008
|
signal
|
|
1934
2009
|
});
|
|
2010
|
+
return with_response ? response : void 0;
|
|
1935
2011
|
}
|
|
1936
2012
|
/**
|
|
1937
2013
|
* Reply to a deferred interaction
|
|
@@ -1991,17 +2067,9 @@ var InteractionsAPI = class {
|
|
|
1991
2067
|
async deleteReply(applicationId, interactionToken, messageId, { signal } = {}) {
|
|
1992
2068
|
await this.webhooks.deleteMessage(applicationId, interactionToken, messageId ?? "@original", {}, { signal });
|
|
1993
2069
|
}
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
1998
|
-
* @param interactionId - The id of the interaction
|
|
1999
|
-
* @param interactionToken - The token of the interaction
|
|
2000
|
-
* @param callbackData - The callback data for updating the interaction
|
|
2001
|
-
* @param options - The options for updating the interaction
|
|
2002
|
-
*/
|
|
2003
|
-
async updateMessage(interactionId, interactionToken, { files, ...data }, { signal } = {}) {
|
|
2004
|
-
await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
2070
|
+
async updateMessage(interactionId, interactionToken, { files, with_response, ...data }, { signal } = {}) {
|
|
2071
|
+
const response = await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
2072
|
+
query: makeURLSearchParams4({ with_response }),
|
|
2005
2073
|
files,
|
|
2006
2074
|
auth: false,
|
|
2007
2075
|
body: {
|
|
@@ -2010,47 +2078,34 @@ var InteractionsAPI = class {
|
|
|
2010
2078
|
},
|
|
2011
2079
|
signal
|
|
2012
2080
|
});
|
|
2081
|
+
return with_response ? response : void 0;
|
|
2013
2082
|
}
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
2018
|
-
* @param interactionId - The id of the interaction
|
|
2019
|
-
* @param interactionToken - The token of the interaction
|
|
2020
|
-
* @param callbackData - The callback data for the autocomplete response
|
|
2021
|
-
* @param options - The options for sending the autocomplete response
|
|
2022
|
-
*/
|
|
2023
|
-
async createAutocompleteResponse(interactionId, interactionToken, callbackData, { signal } = {}) {
|
|
2024
|
-
await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
2083
|
+
async createAutocompleteResponse(interactionId, interactionToken, { with_response, ...data }, { signal } = {}) {
|
|
2084
|
+
const response = await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
2085
|
+
query: makeURLSearchParams4({ with_response }),
|
|
2025
2086
|
auth: false,
|
|
2026
2087
|
body: {
|
|
2027
2088
|
type: InteractionResponseType.ApplicationCommandAutocompleteResult,
|
|
2028
|
-
data
|
|
2089
|
+
data
|
|
2029
2090
|
},
|
|
2030
2091
|
signal
|
|
2031
2092
|
});
|
|
2093
|
+
return with_response ? response : void 0;
|
|
2032
2094
|
}
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
2037
|
-
* @param interactionId - The id of the interaction
|
|
2038
|
-
* @param interactionToken - The token of the interaction
|
|
2039
|
-
* @param callbackData - The modal callback data to send
|
|
2040
|
-
* @param options - The options for sending the modal
|
|
2041
|
-
*/
|
|
2042
|
-
async createModal(interactionId, interactionToken, callbackData, { signal } = {}) {
|
|
2043
|
-
await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
2095
|
+
async createModal(interactionId, interactionToken, { with_response, ...data }, { signal } = {}) {
|
|
2096
|
+
const response = await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
2097
|
+
query: makeURLSearchParams4({ with_response }),
|
|
2044
2098
|
auth: false,
|
|
2045
2099
|
body: {
|
|
2046
2100
|
type: InteractionResponseType.Modal,
|
|
2047
|
-
data
|
|
2101
|
+
data
|
|
2048
2102
|
},
|
|
2049
2103
|
signal
|
|
2050
2104
|
});
|
|
2105
|
+
return with_response ? response : void 0;
|
|
2051
2106
|
}
|
|
2052
2107
|
/**
|
|
2053
|
-
*
|
|
2108
|
+
* Launches an activity and returns an interaction callback object
|
|
2054
2109
|
*
|
|
2055
2110
|
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
|
|
2056
2111
|
* @param interactionId - The id of the interaction
|
|
@@ -2067,11 +2122,24 @@ var InteractionsAPI = class {
|
|
|
2067
2122
|
signal
|
|
2068
2123
|
});
|
|
2069
2124
|
}
|
|
2125
|
+
async launchActivity(interactionId, interactionToken, { with_response } = {}, { signal } = {}) {
|
|
2126
|
+
const response = await this.rest.post(Routes7.interactionCallback(interactionId, interactionToken), {
|
|
2127
|
+
query: makeURLSearchParams4({ with_response }),
|
|
2128
|
+
auth: false,
|
|
2129
|
+
body: {
|
|
2130
|
+
type: InteractionResponseType.LaunchActivity
|
|
2131
|
+
},
|
|
2132
|
+
signal
|
|
2133
|
+
});
|
|
2134
|
+
return with_response ? response : void 0;
|
|
2135
|
+
}
|
|
2070
2136
|
};
|
|
2071
2137
|
|
|
2072
2138
|
// src/api/invite.ts
|
|
2073
|
-
import { makeURLSearchParams as
|
|
2074
|
-
import {
|
|
2139
|
+
import { makeURLSearchParams as makeURLSearchParams5 } from "@discordjs/rest";
|
|
2140
|
+
import {
|
|
2141
|
+
Routes as Routes8
|
|
2142
|
+
} from "discord-api-types/v10";
|
|
2075
2143
|
var InvitesAPI = class {
|
|
2076
2144
|
constructor(rest) {
|
|
2077
2145
|
this.rest = rest;
|
|
@@ -2089,7 +2157,7 @@ var InvitesAPI = class {
|
|
|
2089
2157
|
*/
|
|
2090
2158
|
async get(code, query = {}, { signal } = {}) {
|
|
2091
2159
|
return this.rest.get(Routes8.invite(code), {
|
|
2092
|
-
query:
|
|
2160
|
+
query: makeURLSearchParams5(query),
|
|
2093
2161
|
signal
|
|
2094
2162
|
});
|
|
2095
2163
|
}
|
|
@@ -2101,12 +2169,12 @@ var InvitesAPI = class {
|
|
|
2101
2169
|
* @param options - The options for deleting the invite
|
|
2102
2170
|
*/
|
|
2103
2171
|
async delete(code, { reason, signal } = {}) {
|
|
2104
|
-
|
|
2172
|
+
return this.rest.delete(Routes8.invite(code), { reason, signal });
|
|
2105
2173
|
}
|
|
2106
2174
|
};
|
|
2107
2175
|
|
|
2108
2176
|
// src/api/monetization.ts
|
|
2109
|
-
import { makeURLSearchParams as
|
|
2177
|
+
import { makeURLSearchParams as makeURLSearchParams6 } from "@discordjs/rest";
|
|
2110
2178
|
import {
|
|
2111
2179
|
Routes as Routes9
|
|
2112
2180
|
} from "discord-api-types/v10";
|
|
@@ -2120,30 +2188,71 @@ var MonetizationAPI = class {
|
|
|
2120
2188
|
/**
|
|
2121
2189
|
* Fetches the SKUs for an application.
|
|
2122
2190
|
*
|
|
2123
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2191
|
+
* @see {@link https://discord.com/developers/docs/resources/sku#list-skus}
|
|
2192
|
+
* @param applicationId - The application id to fetch SKUs for
|
|
2124
2193
|
* @param options - The options for fetching the SKUs.
|
|
2125
2194
|
*/
|
|
2126
2195
|
async getSKUs(applicationId, { signal } = {}) {
|
|
2127
2196
|
return this.rest.get(Routes9.skus(applicationId), { signal });
|
|
2128
2197
|
}
|
|
2198
|
+
/**
|
|
2199
|
+
* Fetches subscriptions for an SKU.
|
|
2200
|
+
*
|
|
2201
|
+
* @see {@link https://discord.com/developers/docs/resources/subscription#list-sku-subscriptions}
|
|
2202
|
+
* @param skuId - The SKU id to fetch subscriptions for
|
|
2203
|
+
* @param query - The query options for fetching subscriptions
|
|
2204
|
+
* @param options - The options for fetching subscriptions
|
|
2205
|
+
*/
|
|
2206
|
+
async getSKUSubscriptions(skuId, query = {}, { signal } = {}) {
|
|
2207
|
+
return this.rest.get(Routes9.skuSubscriptions(skuId), {
|
|
2208
|
+
signal,
|
|
2209
|
+
query: makeURLSearchParams6(query)
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
/**
|
|
2213
|
+
* Fetches a subscription for an SKU.
|
|
2214
|
+
*
|
|
2215
|
+
* @see {@link https://discord.com/developers/docs/resources/subscription#get-sku-subscription}
|
|
2216
|
+
* @param skuId - The SKU id to fetch subscription for
|
|
2217
|
+
* @param subscriptionId - The subscription id to fetch
|
|
2218
|
+
* @param options - The options for fetching the subscription
|
|
2219
|
+
*/
|
|
2220
|
+
async getSKUSubscription(skuId, subscriptionId, { signal } = {}) {
|
|
2221
|
+
return this.rest.get(Routes9.skuSubscription(skuId, subscriptionId), {
|
|
2222
|
+
signal
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2129
2225
|
/**
|
|
2130
2226
|
* Fetches the entitlements for an application.
|
|
2131
2227
|
*
|
|
2132
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2228
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#list-entitlements}
|
|
2133
2229
|
* @param applicationId - The application id to fetch entitlements for
|
|
2134
2230
|
* @param query - The query options for fetching entitlements
|
|
2135
2231
|
* @param options - The options for fetching entitlements
|
|
2136
2232
|
*/
|
|
2137
|
-
async getEntitlements(applicationId, query, { signal } = {}) {
|
|
2233
|
+
async getEntitlements(applicationId, query = {}, { signal } = {}) {
|
|
2138
2234
|
return this.rest.get(Routes9.entitlements(applicationId), {
|
|
2139
2235
|
signal,
|
|
2140
|
-
query:
|
|
2236
|
+
query: makeURLSearchParams6(query)
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
/**
|
|
2240
|
+
* Fetches an entitlement for an application.
|
|
2241
|
+
*
|
|
2242
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#get-entitlement}
|
|
2243
|
+
* @param applicationId - The application id to fetch the entitlement for
|
|
2244
|
+
* @param entitlementId - The entitlement id to fetch
|
|
2245
|
+
* @param options - The options for fetching the entitlement
|
|
2246
|
+
*/
|
|
2247
|
+
async getEntitlement(applicationId, entitlementId, { signal } = {}) {
|
|
2248
|
+
return this.rest.get(Routes9.entitlement(applicationId, entitlementId), {
|
|
2249
|
+
signal
|
|
2141
2250
|
});
|
|
2142
2251
|
}
|
|
2143
2252
|
/**
|
|
2144
2253
|
* Creates a test entitlement for an application's SKU.
|
|
2145
2254
|
*
|
|
2146
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2255
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#create-test-entitlement}
|
|
2147
2256
|
* @param applicationId - The application id to create the entitlement for
|
|
2148
2257
|
* @param body - The data for creating the entitlement
|
|
2149
2258
|
* @param options - The options for creating the entitlement
|
|
@@ -2157,7 +2266,7 @@ var MonetizationAPI = class {
|
|
|
2157
2266
|
/**
|
|
2158
2267
|
* Deletes a test entitlement for an application's SKU.
|
|
2159
2268
|
*
|
|
2160
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2269
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#delete-test-entitlement}
|
|
2161
2270
|
* @param applicationId - The application id to delete the entitlement for
|
|
2162
2271
|
* @param entitlementId - The entitlement id to delete
|
|
2163
2272
|
* @param options - The options for deleting the entitlement
|
|
@@ -2168,7 +2277,7 @@ var MonetizationAPI = class {
|
|
|
2168
2277
|
/**
|
|
2169
2278
|
* Marks a given entitlement for the user as consumed. Only available for One-Time Purchase consumable SKUs.
|
|
2170
2279
|
*
|
|
2171
|
-
* @see {@link https://discord.com/developers/docs/
|
|
2280
|
+
* @see {@link https://discord.com/developers/docs/resources/entitlement#consume-an-entitlement}
|
|
2172
2281
|
* @param applicationId - The application id to consume the entitlement for
|
|
2173
2282
|
* @param entitlementId - The entitlement id to consume
|
|
2174
2283
|
* @param options - The options for consuming the entitlement
|
|
@@ -2179,7 +2288,7 @@ var MonetizationAPI = class {
|
|
|
2179
2288
|
};
|
|
2180
2289
|
|
|
2181
2290
|
// src/api/oauth2.ts
|
|
2182
|
-
import { makeURLSearchParams as
|
|
2291
|
+
import { makeURLSearchParams as makeURLSearchParams7 } from "@discordjs/rest";
|
|
2183
2292
|
import {
|
|
2184
2293
|
Routes as Routes10,
|
|
2185
2294
|
RouteBases
|
|
@@ -2199,7 +2308,7 @@ var OAuth2API = class {
|
|
|
2199
2308
|
*/
|
|
2200
2309
|
generateAuthorizationURL(options) {
|
|
2201
2310
|
const url = new URL(`${RouteBases.api}${Routes10.oauth2Authorization()}`);
|
|
2202
|
-
url.search =
|
|
2311
|
+
url.search = makeURLSearchParams7(options).toString();
|
|
2203
2312
|
return url.toString();
|
|
2204
2313
|
}
|
|
2205
2314
|
/**
|
|
@@ -2211,7 +2320,7 @@ var OAuth2API = class {
|
|
|
2211
2320
|
*/
|
|
2212
2321
|
async tokenExchange(body, { signal } = {}) {
|
|
2213
2322
|
return this.rest.post(Routes10.oauth2TokenExchange(), {
|
|
2214
|
-
body:
|
|
2323
|
+
body: makeURLSearchParams7(body),
|
|
2215
2324
|
passThroughBody: true,
|
|
2216
2325
|
headers: {
|
|
2217
2326
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -2229,7 +2338,7 @@ var OAuth2API = class {
|
|
|
2229
2338
|
*/
|
|
2230
2339
|
async refreshToken(body, { signal } = {}) {
|
|
2231
2340
|
return this.rest.post(Routes10.oauth2TokenExchange(), {
|
|
2232
|
-
body:
|
|
2341
|
+
body: makeURLSearchParams7(body),
|
|
2233
2342
|
passThroughBody: true,
|
|
2234
2343
|
headers: {
|
|
2235
2344
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -2249,7 +2358,7 @@ var OAuth2API = class {
|
|
|
2249
2358
|
*/
|
|
2250
2359
|
async getToken(body, { signal } = {}) {
|
|
2251
2360
|
return this.rest.post(Routes10.oauth2TokenExchange(), {
|
|
2252
|
-
body:
|
|
2361
|
+
body: makeURLSearchParams7(body),
|
|
2253
2362
|
passThroughBody: true,
|
|
2254
2363
|
headers: {
|
|
2255
2364
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
@@ -2291,7 +2400,7 @@ var OAuth2API = class {
|
|
|
2291
2400
|
*/
|
|
2292
2401
|
async revokeToken(applicationId, applicationSecret, body, { signal } = {}) {
|
|
2293
2402
|
await this.rest.post(Routes10.oauth2TokenRevocation(), {
|
|
2294
|
-
body:
|
|
2403
|
+
body: makeURLSearchParams7(body),
|
|
2295
2404
|
passThroughBody: true,
|
|
2296
2405
|
headers: {
|
|
2297
2406
|
Authorization: `Basic ${btoa(`${applicationId}:${applicationSecret}`)}`,
|
|
@@ -2304,7 +2413,7 @@ var OAuth2API = class {
|
|
|
2304
2413
|
};
|
|
2305
2414
|
|
|
2306
2415
|
// src/api/poll.ts
|
|
2307
|
-
import { makeURLSearchParams as
|
|
2416
|
+
import { makeURLSearchParams as makeURLSearchParams8 } from "@discordjs/rest";
|
|
2308
2417
|
import {
|
|
2309
2418
|
Routes as Routes11
|
|
2310
2419
|
} from "discord-api-types/v10";
|
|
@@ -2325,10 +2434,10 @@ var PollAPI = class {
|
|
|
2325
2434
|
* @param query - The query for getting the list of voters
|
|
2326
2435
|
* @param options - The options for getting the list of voters
|
|
2327
2436
|
*/
|
|
2328
|
-
async getAnswerVoters(channelId, messageId, answerId, query, { signal } = {}) {
|
|
2437
|
+
async getAnswerVoters(channelId, messageId, answerId, query = {}, { signal } = {}) {
|
|
2329
2438
|
return this.rest.get(Routes11.pollAnswerVoters(channelId, messageId, answerId), {
|
|
2330
2439
|
signal,
|
|
2331
|
-
query:
|
|
2440
|
+
query: makeURLSearchParams8(query)
|
|
2332
2441
|
});
|
|
2333
2442
|
}
|
|
2334
2443
|
/**
|
|
@@ -2385,9 +2494,31 @@ var RoleConnectionsAPI = class {
|
|
|
2385
2494
|
}
|
|
2386
2495
|
};
|
|
2387
2496
|
|
|
2497
|
+
// src/api/soundboardSounds.ts
|
|
2498
|
+
import { Routes as Routes13 } from "discord-api-types/v10";
|
|
2499
|
+
var SoundboardSoundsAPI = class {
|
|
2500
|
+
constructor(rest) {
|
|
2501
|
+
this.rest = rest;
|
|
2502
|
+
}
|
|
2503
|
+
static {
|
|
2504
|
+
__name(this, "SoundboardSoundsAPI");
|
|
2505
|
+
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Fetches all the soundboard default sounds.
|
|
2508
|
+
*
|
|
2509
|
+
* @see {@link https://discord.com/developers/docs/resources/soundboard#list-default-soundboard-sounds}
|
|
2510
|
+
* @param options - The options for fetching the soundboard default sounds.
|
|
2511
|
+
*/
|
|
2512
|
+
async getSoundboardDefaultSounds({ signal } = {}) {
|
|
2513
|
+
return this.rest.get(Routes13.soundboardDefaultSounds(), {
|
|
2514
|
+
signal
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2517
|
+
};
|
|
2518
|
+
|
|
2388
2519
|
// src/api/stageInstances.ts
|
|
2389
2520
|
import {
|
|
2390
|
-
Routes as
|
|
2521
|
+
Routes as Routes14
|
|
2391
2522
|
} from "discord-api-types/v10";
|
|
2392
2523
|
var StageInstancesAPI = class {
|
|
2393
2524
|
constructor(rest) {
|
|
@@ -2404,7 +2535,7 @@ var StageInstancesAPI = class {
|
|
|
2404
2535
|
* @param options - The options for creating the new stage instance
|
|
2405
2536
|
*/
|
|
2406
2537
|
async create(body, { reason, signal } = {}) {
|
|
2407
|
-
return this.rest.post(
|
|
2538
|
+
return this.rest.post(Routes14.stageInstances(), {
|
|
2408
2539
|
body,
|
|
2409
2540
|
reason,
|
|
2410
2541
|
signal
|
|
@@ -2418,7 +2549,7 @@ var StageInstancesAPI = class {
|
|
|
2418
2549
|
* @param options - The options for fetching the stage instance
|
|
2419
2550
|
*/
|
|
2420
2551
|
async get(channelId, { signal } = {}) {
|
|
2421
|
-
return this.rest.get(
|
|
2552
|
+
return this.rest.get(Routes14.stageInstance(channelId), { signal });
|
|
2422
2553
|
}
|
|
2423
2554
|
/**
|
|
2424
2555
|
* Edits a stage instance
|
|
@@ -2429,7 +2560,7 @@ var StageInstancesAPI = class {
|
|
|
2429
2560
|
* @param options - The options for editing the stage instance
|
|
2430
2561
|
*/
|
|
2431
2562
|
async edit(channelId, body, { reason, signal } = {}) {
|
|
2432
|
-
return this.rest.patch(
|
|
2563
|
+
return this.rest.patch(Routes14.stageInstance(channelId), {
|
|
2433
2564
|
body,
|
|
2434
2565
|
reason,
|
|
2435
2566
|
signal
|
|
@@ -2443,13 +2574,13 @@ var StageInstancesAPI = class {
|
|
|
2443
2574
|
* @param options - The options for deleting the stage instance
|
|
2444
2575
|
*/
|
|
2445
2576
|
async delete(channelId, { reason, signal } = {}) {
|
|
2446
|
-
await this.rest.delete(
|
|
2577
|
+
await this.rest.delete(Routes14.stageInstance(channelId), { reason, signal });
|
|
2447
2578
|
}
|
|
2448
2579
|
};
|
|
2449
2580
|
|
|
2450
2581
|
// src/api/sticker.ts
|
|
2451
2582
|
import {
|
|
2452
|
-
Routes as
|
|
2583
|
+
Routes as Routes15
|
|
2453
2584
|
} from "discord-api-types/v10";
|
|
2454
2585
|
var StickersAPI = class {
|
|
2455
2586
|
constructor(rest) {
|
|
@@ -2466,7 +2597,7 @@ var StickersAPI = class {
|
|
|
2466
2597
|
* @param options - The options for fetching the sticker pack
|
|
2467
2598
|
*/
|
|
2468
2599
|
async getStickerPack(packId, { signal } = {}) {
|
|
2469
|
-
return this.rest.get(
|
|
2600
|
+
return this.rest.get(Routes15.stickerPack(packId), { signal });
|
|
2470
2601
|
}
|
|
2471
2602
|
/**
|
|
2472
2603
|
* Fetches all of the sticker packs
|
|
@@ -2475,7 +2606,7 @@ var StickersAPI = class {
|
|
|
2475
2606
|
* @param options - The options for fetching the sticker packs
|
|
2476
2607
|
*/
|
|
2477
2608
|
async getStickers({ signal } = {}) {
|
|
2478
|
-
return this.rest.get(
|
|
2609
|
+
return this.rest.get(Routes15.stickerPacks(), { signal });
|
|
2479
2610
|
}
|
|
2480
2611
|
/**
|
|
2481
2612
|
* Fetches all of the sticker packs
|
|
@@ -2495,13 +2626,13 @@ var StickersAPI = class {
|
|
|
2495
2626
|
* @param options - The options for fetching the sticker
|
|
2496
2627
|
*/
|
|
2497
2628
|
async get(stickerId, { signal } = {}) {
|
|
2498
|
-
return this.rest.get(
|
|
2629
|
+
return this.rest.get(Routes15.sticker(stickerId), { signal });
|
|
2499
2630
|
}
|
|
2500
2631
|
};
|
|
2501
2632
|
|
|
2502
2633
|
// src/api/thread.ts
|
|
2503
2634
|
import {
|
|
2504
|
-
Routes as
|
|
2635
|
+
Routes as Routes16
|
|
2505
2636
|
} from "discord-api-types/v10";
|
|
2506
2637
|
var ThreadsAPI = class {
|
|
2507
2638
|
constructor(rest) {
|
|
@@ -2518,7 +2649,7 @@ var ThreadsAPI = class {
|
|
|
2518
2649
|
* @param options - The options for joining the thread
|
|
2519
2650
|
*/
|
|
2520
2651
|
async join(threadId, { signal } = {}) {
|
|
2521
|
-
await this.rest.put(
|
|
2652
|
+
await this.rest.put(Routes16.threadMembers(threadId, "@me"), { signal });
|
|
2522
2653
|
}
|
|
2523
2654
|
/**
|
|
2524
2655
|
* Adds a member to a thread
|
|
@@ -2529,7 +2660,7 @@ var ThreadsAPI = class {
|
|
|
2529
2660
|
* @param options - The options for adding the member to the thread
|
|
2530
2661
|
*/
|
|
2531
2662
|
async addMember(threadId, userId, { signal } = {}) {
|
|
2532
|
-
await this.rest.put(
|
|
2663
|
+
await this.rest.put(Routes16.threadMembers(threadId, userId), { signal });
|
|
2533
2664
|
}
|
|
2534
2665
|
/**
|
|
2535
2666
|
* Removes the current user from a thread
|
|
@@ -2539,7 +2670,7 @@ var ThreadsAPI = class {
|
|
|
2539
2670
|
* @param options - The options for leaving the thread
|
|
2540
2671
|
*/
|
|
2541
2672
|
async leave(threadId, { signal } = {}) {
|
|
2542
|
-
await this.rest.delete(
|
|
2673
|
+
await this.rest.delete(Routes16.threadMembers(threadId, "@me"), { signal });
|
|
2543
2674
|
}
|
|
2544
2675
|
/**
|
|
2545
2676
|
* Removes a member from a thread
|
|
@@ -2550,7 +2681,7 @@ var ThreadsAPI = class {
|
|
|
2550
2681
|
* @param options - The options for removing the member from the thread
|
|
2551
2682
|
*/
|
|
2552
2683
|
async removeMember(threadId, userId, { signal } = {}) {
|
|
2553
|
-
await this.rest.delete(
|
|
2684
|
+
await this.rest.delete(Routes16.threadMembers(threadId, userId), { signal });
|
|
2554
2685
|
}
|
|
2555
2686
|
/**
|
|
2556
2687
|
* Fetches a member of a thread
|
|
@@ -2561,7 +2692,7 @@ var ThreadsAPI = class {
|
|
|
2561
2692
|
* @param options - The options for fetching the member
|
|
2562
2693
|
*/
|
|
2563
2694
|
async getMember(threadId, userId, { signal } = {}) {
|
|
2564
|
-
return this.rest.get(
|
|
2695
|
+
return this.rest.get(Routes16.threadMembers(threadId, userId), { signal });
|
|
2565
2696
|
}
|
|
2566
2697
|
/**
|
|
2567
2698
|
* Fetches all members of a thread
|
|
@@ -2571,14 +2702,14 @@ var ThreadsAPI = class {
|
|
|
2571
2702
|
* @param options - The options for fetching the members
|
|
2572
2703
|
*/
|
|
2573
2704
|
async getAllMembers(threadId, { signal } = {}) {
|
|
2574
|
-
return this.rest.get(
|
|
2705
|
+
return this.rest.get(Routes16.threadMembers(threadId), { signal });
|
|
2575
2706
|
}
|
|
2576
2707
|
};
|
|
2577
2708
|
|
|
2578
2709
|
// src/api/user.ts
|
|
2579
|
-
import { makeURLSearchParams as
|
|
2710
|
+
import { makeURLSearchParams as makeURLSearchParams9 } from "@discordjs/rest";
|
|
2580
2711
|
import {
|
|
2581
|
-
Routes as
|
|
2712
|
+
Routes as Routes17
|
|
2582
2713
|
} from "discord-api-types/v10";
|
|
2583
2714
|
var UsersAPI = class {
|
|
2584
2715
|
constructor(rest) {
|
|
@@ -2595,7 +2726,7 @@ var UsersAPI = class {
|
|
|
2595
2726
|
* @param options - The options for fetching the user
|
|
2596
2727
|
*/
|
|
2597
2728
|
async get(userId, { signal } = {}) {
|
|
2598
|
-
return this.rest.get(
|
|
2729
|
+
return this.rest.get(Routes17.user(userId), { signal });
|
|
2599
2730
|
}
|
|
2600
2731
|
/**
|
|
2601
2732
|
* Returns the user object of the requester's account
|
|
@@ -2604,7 +2735,7 @@ var UsersAPI = class {
|
|
|
2604
2735
|
* @param options - The options for fetching the current user
|
|
2605
2736
|
*/
|
|
2606
2737
|
async getCurrent({ signal } = {}) {
|
|
2607
|
-
return this.rest.get(
|
|
2738
|
+
return this.rest.get(Routes17.user("@me"), { signal });
|
|
2608
2739
|
}
|
|
2609
2740
|
/**
|
|
2610
2741
|
* Returns a list of partial guild objects the current user is a member of
|
|
@@ -2614,8 +2745,8 @@ var UsersAPI = class {
|
|
|
2614
2745
|
* @param options - The options for fetching the guilds
|
|
2615
2746
|
*/
|
|
2616
2747
|
async getGuilds(query = {}, { signal } = {}) {
|
|
2617
|
-
return this.rest.get(
|
|
2618
|
-
query:
|
|
2748
|
+
return this.rest.get(Routes17.userGuilds(), {
|
|
2749
|
+
query: makeURLSearchParams9(query),
|
|
2619
2750
|
signal
|
|
2620
2751
|
});
|
|
2621
2752
|
}
|
|
@@ -2627,7 +2758,7 @@ var UsersAPI = class {
|
|
|
2627
2758
|
* @param options - The options for leaving the guild
|
|
2628
2759
|
*/
|
|
2629
2760
|
async leaveGuild(guildId, { signal } = {}) {
|
|
2630
|
-
await this.rest.delete(
|
|
2761
|
+
await this.rest.delete(Routes17.userGuild(guildId), { signal });
|
|
2631
2762
|
}
|
|
2632
2763
|
/**
|
|
2633
2764
|
* Edits the current user
|
|
@@ -2637,7 +2768,7 @@ var UsersAPI = class {
|
|
|
2637
2768
|
* @param options - The options for editing the user
|
|
2638
2769
|
*/
|
|
2639
2770
|
async edit(body, { signal } = {}) {
|
|
2640
|
-
return this.rest.patch(
|
|
2771
|
+
return this.rest.patch(Routes17.user("@me"), { body, signal });
|
|
2641
2772
|
}
|
|
2642
2773
|
/**
|
|
2643
2774
|
* Fetches the guild member for the current user
|
|
@@ -2647,7 +2778,7 @@ var UsersAPI = class {
|
|
|
2647
2778
|
* @param options - The options for fetching the guild member
|
|
2648
2779
|
*/
|
|
2649
2780
|
async getGuildMember(guildId, { signal } = {}) {
|
|
2650
|
-
return this.rest.get(
|
|
2781
|
+
return this.rest.get(Routes17.userGuildMember(guildId), { signal });
|
|
2651
2782
|
}
|
|
2652
2783
|
/**
|
|
2653
2784
|
* Edits the guild member for the current user
|
|
@@ -2658,7 +2789,7 @@ var UsersAPI = class {
|
|
|
2658
2789
|
* @param options - The options for editing the guild member
|
|
2659
2790
|
*/
|
|
2660
2791
|
async editCurrentGuildMember(guildId, body = {}, { reason, signal } = {}) {
|
|
2661
|
-
return this.rest.patch(
|
|
2792
|
+
return this.rest.patch(Routes17.guildMember(guildId, "@me"), {
|
|
2662
2793
|
reason,
|
|
2663
2794
|
body,
|
|
2664
2795
|
signal
|
|
@@ -2672,7 +2803,7 @@ var UsersAPI = class {
|
|
|
2672
2803
|
* @param options - The options for opening the DM
|
|
2673
2804
|
*/
|
|
2674
2805
|
async createDM(userId, { signal } = {}) {
|
|
2675
|
-
return this.rest.post(
|
|
2806
|
+
return this.rest.post(Routes17.userChannels(), {
|
|
2676
2807
|
body: { recipient_id: userId },
|
|
2677
2808
|
signal
|
|
2678
2809
|
});
|
|
@@ -2684,7 +2815,7 @@ var UsersAPI = class {
|
|
|
2684
2815
|
* @param options - The options for fetching the user's connections
|
|
2685
2816
|
*/
|
|
2686
2817
|
async getConnections({ signal } = {}) {
|
|
2687
|
-
return this.rest.get(
|
|
2818
|
+
return this.rest.get(Routes17.userConnections(), { signal });
|
|
2688
2819
|
}
|
|
2689
2820
|
/**
|
|
2690
2821
|
* Gets the current user's active application role connection
|
|
@@ -2694,7 +2825,7 @@ var UsersAPI = class {
|
|
|
2694
2825
|
* @param options - The options for fetching the role connections
|
|
2695
2826
|
*/
|
|
2696
2827
|
async getApplicationRoleConnection(applicationId, { signal } = {}) {
|
|
2697
|
-
return this.rest.get(
|
|
2828
|
+
return this.rest.get(Routes17.userApplicationRoleConnection(applicationId), {
|
|
2698
2829
|
signal
|
|
2699
2830
|
});
|
|
2700
2831
|
}
|
|
@@ -2707,7 +2838,7 @@ var UsersAPI = class {
|
|
|
2707
2838
|
* @param options - The options for updating the application role connection
|
|
2708
2839
|
*/
|
|
2709
2840
|
async updateApplicationRoleConnection(applicationId, body, { signal } = {}) {
|
|
2710
|
-
return this.rest.put(
|
|
2841
|
+
return this.rest.put(Routes17.userApplicationRoleConnection(applicationId), {
|
|
2711
2842
|
body,
|
|
2712
2843
|
signal
|
|
2713
2844
|
});
|
|
@@ -2715,9 +2846,9 @@ var UsersAPI = class {
|
|
|
2715
2846
|
};
|
|
2716
2847
|
|
|
2717
2848
|
// src/api/webhook.ts
|
|
2718
|
-
import { makeURLSearchParams as
|
|
2849
|
+
import { makeURLSearchParams as makeURLSearchParams10 } from "@discordjs/rest";
|
|
2719
2850
|
import {
|
|
2720
|
-
Routes as
|
|
2851
|
+
Routes as Routes18
|
|
2721
2852
|
} from "discord-api-types/v10";
|
|
2722
2853
|
var WebhooksAPI = class {
|
|
2723
2854
|
constructor(rest) {
|
|
@@ -2735,7 +2866,7 @@ var WebhooksAPI = class {
|
|
|
2735
2866
|
* @param options - The options for fetching the webhook
|
|
2736
2867
|
*/
|
|
2737
2868
|
async get(id, { token, signal } = {}) {
|
|
2738
|
-
return this.rest.get(
|
|
2869
|
+
return this.rest.get(Routes18.webhook(id, token), {
|
|
2739
2870
|
signal,
|
|
2740
2871
|
auth: !token
|
|
2741
2872
|
});
|
|
@@ -2750,7 +2881,7 @@ var WebhooksAPI = class {
|
|
|
2750
2881
|
* @param options - The options for editing the webhook
|
|
2751
2882
|
*/
|
|
2752
2883
|
async edit(id, body, { token, reason, signal } = {}) {
|
|
2753
|
-
return this.rest.patch(
|
|
2884
|
+
return this.rest.patch(Routes18.webhook(id, token), {
|
|
2754
2885
|
reason,
|
|
2755
2886
|
body,
|
|
2756
2887
|
signal,
|
|
@@ -2766,7 +2897,7 @@ var WebhooksAPI = class {
|
|
|
2766
2897
|
* @param options - The options for deleting the webhook
|
|
2767
2898
|
*/
|
|
2768
2899
|
async delete(id, { token, reason, signal } = {}) {
|
|
2769
|
-
await this.rest.delete(
|
|
2900
|
+
await this.rest.delete(Routes18.webhook(id, token), {
|
|
2770
2901
|
reason,
|
|
2771
2902
|
signal,
|
|
2772
2903
|
auth: !token
|
|
@@ -2781,15 +2912,9 @@ var WebhooksAPI = class {
|
|
|
2781
2912
|
* @param body - The data for executing the webhook
|
|
2782
2913
|
* @param options - The options for executing the webhook
|
|
2783
2914
|
*/
|
|
2784
|
-
async execute(id, token, {
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
with_components,
|
|
2788
|
-
files,
|
|
2789
|
-
...body
|
|
2790
|
-
}, { signal } = {}) {
|
|
2791
|
-
return this.rest.post(Routes17.webhook(id, token), {
|
|
2792
|
-
query: makeURLSearchParams9({ wait, thread_id, with_components }),
|
|
2915
|
+
async execute(id, token, { wait, thread_id, with_components, files, ...body }, { signal } = {}) {
|
|
2916
|
+
return this.rest.post(Routes18.webhook(id, token), {
|
|
2917
|
+
query: makeURLSearchParams10({ wait, thread_id, with_components }),
|
|
2793
2918
|
files,
|
|
2794
2919
|
body,
|
|
2795
2920
|
auth: false,
|
|
@@ -2808,8 +2933,8 @@ var WebhooksAPI = class {
|
|
|
2808
2933
|
* @param options - The options for executing the webhook
|
|
2809
2934
|
*/
|
|
2810
2935
|
async executeSlack(id, token, body, query = {}, { signal } = {}) {
|
|
2811
|
-
await this.rest.post(
|
|
2812
|
-
query:
|
|
2936
|
+
await this.rest.post(Routes18.webhookPlatform(id, token, "slack"), {
|
|
2937
|
+
query: makeURLSearchParams10(query),
|
|
2813
2938
|
body,
|
|
2814
2939
|
auth: false,
|
|
2815
2940
|
signal
|
|
@@ -2826,8 +2951,8 @@ var WebhooksAPI = class {
|
|
|
2826
2951
|
* @param options - The options for executing the webhook
|
|
2827
2952
|
*/
|
|
2828
2953
|
async executeGitHub(id, token, body, query = {}, { signal } = {}) {
|
|
2829
|
-
await this.rest.post(
|
|
2830
|
-
query:
|
|
2954
|
+
await this.rest.post(Routes18.webhookPlatform(id, token, "github"), {
|
|
2955
|
+
query: makeURLSearchParams10(query),
|
|
2831
2956
|
body,
|
|
2832
2957
|
signal,
|
|
2833
2958
|
auth: false
|
|
@@ -2844,8 +2969,8 @@ var WebhooksAPI = class {
|
|
|
2844
2969
|
* @param options - The options for fetching the message
|
|
2845
2970
|
*/
|
|
2846
2971
|
async getMessage(id, token, messageId, query = {}, { signal } = {}) {
|
|
2847
|
-
return this.rest.get(
|
|
2848
|
-
query:
|
|
2972
|
+
return this.rest.get(Routes18.webhookMessage(id, token, messageId), {
|
|
2973
|
+
query: makeURLSearchParams10(query),
|
|
2849
2974
|
auth: false,
|
|
2850
2975
|
signal
|
|
2851
2976
|
});
|
|
@@ -2860,14 +2985,9 @@ var WebhooksAPI = class {
|
|
|
2860
2985
|
* @param body - The data for editing the message
|
|
2861
2986
|
* @param options - The options for editing the message
|
|
2862
2987
|
*/
|
|
2863
|
-
async editMessage(id, token, messageId, {
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
files,
|
|
2867
|
-
...body
|
|
2868
|
-
}, { signal } = {}) {
|
|
2869
|
-
return this.rest.patch(Routes17.webhookMessage(id, token, messageId), {
|
|
2870
|
-
query: makeURLSearchParams9({ thread_id, with_components }),
|
|
2988
|
+
async editMessage(id, token, messageId, { thread_id, with_components, files, ...body }, { signal } = {}) {
|
|
2989
|
+
return this.rest.patch(Routes18.webhookMessage(id, token, messageId), {
|
|
2990
|
+
query: makeURLSearchParams10({ thread_id, with_components }),
|
|
2871
2991
|
auth: false,
|
|
2872
2992
|
body,
|
|
2873
2993
|
signal,
|
|
@@ -2885,8 +3005,8 @@ var WebhooksAPI = class {
|
|
|
2885
3005
|
* @param options - The options for deleting the message
|
|
2886
3006
|
*/
|
|
2887
3007
|
async deleteMessage(id, token, messageId, query = {}, { signal } = {}) {
|
|
2888
|
-
await this.rest.delete(
|
|
2889
|
-
query:
|
|
3008
|
+
await this.rest.delete(Routes18.webhookMessage(id, token, messageId), {
|
|
3009
|
+
query: makeURLSearchParams10(query),
|
|
2890
3010
|
auth: false,
|
|
2891
3011
|
signal
|
|
2892
3012
|
});
|
|
@@ -2907,6 +3027,7 @@ var API = class {
|
|
|
2907
3027
|
this.oauth2 = new OAuth2API(rest);
|
|
2908
3028
|
this.poll = new PollAPI(rest);
|
|
2909
3029
|
this.roleConnections = new RoleConnectionsAPI(rest);
|
|
3030
|
+
this.soundboardSounds = new SoundboardSoundsAPI(rest);
|
|
2910
3031
|
this.stageInstances = new StageInstancesAPI(rest);
|
|
2911
3032
|
this.stickers = new StickersAPI(rest);
|
|
2912
3033
|
this.threads = new ThreadsAPI(rest);
|
|
@@ -2929,6 +3050,7 @@ var API = class {
|
|
|
2929
3050
|
oauth2;
|
|
2930
3051
|
poll;
|
|
2931
3052
|
roleConnections;
|
|
3053
|
+
soundboardSounds;
|
|
2932
3054
|
stageInstances;
|
|
2933
3055
|
stickers;
|
|
2934
3056
|
threads;
|
|
@@ -2938,8 +3060,8 @@ var API = class {
|
|
|
2938
3060
|
};
|
|
2939
3061
|
|
|
2940
3062
|
// src/client.ts
|
|
2941
|
-
import { clearTimeout, setTimeout } from "
|
|
2942
|
-
import { calculateShardId } from "@discordjs/util";
|
|
3063
|
+
import { clearTimeout, setTimeout } from "timers";
|
|
3064
|
+
import { calculateShardId, GatewayRateLimitError } from "@discordjs/util";
|
|
2943
3065
|
import { WebSocketShardEvents } from "@discordjs/ws";
|
|
2944
3066
|
import { DiscordSnowflake } from "@sapphire/snowflake";
|
|
2945
3067
|
import { AsyncEventEmitter } from "@vladfrangu/async_event_emitter";
|
|
@@ -2947,6 +3069,10 @@ import {
|
|
|
2947
3069
|
GatewayDispatchEvents,
|
|
2948
3070
|
GatewayOpcodes
|
|
2949
3071
|
} from "discord-api-types/v10";
|
|
3072
|
+
function createTimer(controller, timeout) {
|
|
3073
|
+
return setTimeout(() => controller.abort(), timeout);
|
|
3074
|
+
}
|
|
3075
|
+
__name(createTimer, "createTimer");
|
|
2950
3076
|
var Client = class extends AsyncEventEmitter {
|
|
2951
3077
|
static {
|
|
2952
3078
|
__name(this, "Client");
|
|
@@ -2981,10 +3107,19 @@ var Client = class extends AsyncEventEmitter {
|
|
|
2981
3107
|
const shardId = calculateShardId(options.guild_id, await this.gateway.getShardCount());
|
|
2982
3108
|
const nonce = options.nonce ?? DiscordSnowflake.generate().toString();
|
|
2983
3109
|
const controller = new AbortController();
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
3110
|
+
let timer = createTimer(controller, timeout);
|
|
3111
|
+
const onRatelimit = /* @__PURE__ */ __name(({ data }) => {
|
|
3112
|
+
if (data.meta.nonce === nonce) {
|
|
3113
|
+
controller.abort(new GatewayRateLimitError(data, options));
|
|
3114
|
+
}
|
|
3115
|
+
}, "onRatelimit");
|
|
3116
|
+
const cleanup = /* @__PURE__ */ __name(() => {
|
|
3117
|
+
if (timer) {
|
|
3118
|
+
clearTimeout(timer);
|
|
3119
|
+
}
|
|
3120
|
+
this.off(GatewayDispatchEvents.RateLimited, onRatelimit);
|
|
3121
|
+
}, "cleanup");
|
|
3122
|
+
this.on(GatewayDispatchEvents.RateLimited, onRatelimit);
|
|
2988
3123
|
await this.gateway.send(shardId, {
|
|
2989
3124
|
op: GatewayOpcodes.RequestGuildMembers,
|
|
2990
3125
|
// eslint-disable-next-line id-length
|
|
@@ -3009,21 +3144,19 @@ var Client = class extends AsyncEventEmitter {
|
|
|
3009
3144
|
chunkIndex: data.chunk_index,
|
|
3010
3145
|
chunkCount: data.chunk_count
|
|
3011
3146
|
};
|
|
3012
|
-
if (data.chunk_index >= data.chunk_count - 1)
|
|
3013
|
-
|
|
3014
|
-
} else {
|
|
3015
|
-
timer = createTimer();
|
|
3016
|
-
}
|
|
3147
|
+
if (data.chunk_index >= data.chunk_count - 1) break;
|
|
3148
|
+
timer = createTimer(controller, timeout);
|
|
3017
3149
|
}
|
|
3018
3150
|
} catch (error) {
|
|
3019
3151
|
if (error instanceof Error && error.name === "AbortError") {
|
|
3152
|
+
if (error.cause instanceof GatewayRateLimitError) {
|
|
3153
|
+
throw error.cause;
|
|
3154
|
+
}
|
|
3020
3155
|
throw new Error("Request timed out");
|
|
3021
3156
|
}
|
|
3022
3157
|
throw error;
|
|
3023
3158
|
} finally {
|
|
3024
|
-
|
|
3025
|
-
clearTimeout(timer);
|
|
3026
|
-
}
|
|
3159
|
+
cleanup();
|
|
3027
3160
|
}
|
|
3028
3161
|
}
|
|
3029
3162
|
/**
|
|
@@ -3050,6 +3183,86 @@ var Client = class extends AsyncEventEmitter {
|
|
|
3050
3183
|
}
|
|
3051
3184
|
return { members, nonce, notFound, presences };
|
|
3052
3185
|
}
|
|
3186
|
+
/**
|
|
3187
|
+
* Requests soundboard sounds from the gateway and returns an async iterator that yields the data from each soundboard sounds event.
|
|
3188
|
+
*
|
|
3189
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds}
|
|
3190
|
+
* @param options - The options for the request
|
|
3191
|
+
* @param timeout - The timeout for waiting for each soundboard sounds
|
|
3192
|
+
* @example
|
|
3193
|
+
* Requesting soundboard sounds for specific guilds
|
|
3194
|
+
* ```ts
|
|
3195
|
+
* for await (const { guildId, soundboardSounds } of this.requestSoundboardSoundsIterator({
|
|
3196
|
+
* guild_ids: ['1234567890', '9876543210'],
|
|
3197
|
+
* })) {
|
|
3198
|
+
* console.log(`Soundboard sounds for guild ${guildId}:`, soundboardSounds);
|
|
3199
|
+
* }
|
|
3200
|
+
* ```
|
|
3201
|
+
*/
|
|
3202
|
+
async *requestSoundboardSoundsIterator(options, timeout = 1e4) {
|
|
3203
|
+
const shardCount = await this.gateway.getShardCount();
|
|
3204
|
+
const shardIds = Map.groupBy(options.guild_ids, (guildId) => calculateShardId(guildId, shardCount));
|
|
3205
|
+
const controller = new AbortController();
|
|
3206
|
+
let timer = createTimer(controller, timeout);
|
|
3207
|
+
for (const [shardId, guildIds] of shardIds) {
|
|
3208
|
+
await this.gateway.send(shardId, {
|
|
3209
|
+
op: GatewayOpcodes.RequestSoundboardSounds,
|
|
3210
|
+
// eslint-disable-next-line id-length
|
|
3211
|
+
d: {
|
|
3212
|
+
...options,
|
|
3213
|
+
guild_ids: guildIds
|
|
3214
|
+
}
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
try {
|
|
3218
|
+
const iterator = AsyncEventEmitter.on(this, GatewayDispatchEvents.SoundboardSounds, {
|
|
3219
|
+
signal: controller.signal
|
|
3220
|
+
});
|
|
3221
|
+
const guildIds = new Set(options.guild_ids);
|
|
3222
|
+
for await (const [{ data }] of iterator) {
|
|
3223
|
+
if (!guildIds.has(data.guild_id)) continue;
|
|
3224
|
+
clearTimeout(timer);
|
|
3225
|
+
timer = void 0;
|
|
3226
|
+
yield {
|
|
3227
|
+
guildId: data.guild_id,
|
|
3228
|
+
soundboardSounds: data.soundboard_sounds
|
|
3229
|
+
};
|
|
3230
|
+
guildIds.delete(data.guild_id);
|
|
3231
|
+
if (guildIds.size === 0) break;
|
|
3232
|
+
timer = createTimer(controller, timeout);
|
|
3233
|
+
}
|
|
3234
|
+
} catch (error) {
|
|
3235
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
3236
|
+
throw new Error("Request timed out");
|
|
3237
|
+
}
|
|
3238
|
+
throw error;
|
|
3239
|
+
} finally {
|
|
3240
|
+
if (timer) {
|
|
3241
|
+
clearTimeout(timer);
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Requests soundboard sounds from the gateway.
|
|
3247
|
+
*
|
|
3248
|
+
* @see {@link https://discord.com/developers/docs/topics/gateway-events#request-soundboard-sounds}
|
|
3249
|
+
* @param options - The options for the request
|
|
3250
|
+
* @param timeout - The timeout for waiting for each soundboard sounds event
|
|
3251
|
+
* @example
|
|
3252
|
+
* Requesting soundboard sounds for specific guilds
|
|
3253
|
+
* ```ts
|
|
3254
|
+
* const soundboardSounds = await client.requestSoundboardSounds({ guild_ids: ['1234567890', '9876543210'], });
|
|
3255
|
+
*
|
|
3256
|
+
* console.log(soundboardSounds.get('1234567890'));
|
|
3257
|
+
* ```
|
|
3258
|
+
*/
|
|
3259
|
+
async requestSoundboardSounds(options, timeout = 1e4) {
|
|
3260
|
+
const soundboardSounds = /* @__PURE__ */ new Map();
|
|
3261
|
+
for await (const data of this.requestSoundboardSoundsIterator(options, timeout)) {
|
|
3262
|
+
soundboardSounds.set(data.guildId, data.soundboardSounds);
|
|
3263
|
+
}
|
|
3264
|
+
return soundboardSounds;
|
|
3265
|
+
}
|
|
3053
3266
|
/**
|
|
3054
3267
|
* Updates the voice state of the bot user
|
|
3055
3268
|
*
|
|
@@ -3105,7 +3318,8 @@ __name(withFiles, "withFiles");
|
|
|
3105
3318
|
|
|
3106
3319
|
// src/index.ts
|
|
3107
3320
|
export * from "discord-api-types/v10";
|
|
3108
|
-
|
|
3321
|
+
import { GatewayRateLimitError as GatewayRateLimitError2 } from "@discordjs/util";
|
|
3322
|
+
var version = "2.5.0";
|
|
3109
3323
|
export {
|
|
3110
3324
|
API,
|
|
3111
3325
|
ApplicationCommandsAPI,
|
|
@@ -3113,6 +3327,7 @@ export {
|
|
|
3113
3327
|
ChannelsAPI,
|
|
3114
3328
|
Client,
|
|
3115
3329
|
GatewayAPI,
|
|
3330
|
+
GatewayRateLimitError2 as GatewayRateLimitError,
|
|
3116
3331
|
GuildsAPI,
|
|
3117
3332
|
InteractionsAPI,
|
|
3118
3333
|
InvitesAPI,
|
|
@@ -3120,6 +3335,7 @@ export {
|
|
|
3120
3335
|
OAuth2API,
|
|
3121
3336
|
PollAPI,
|
|
3122
3337
|
RoleConnectionsAPI,
|
|
3338
|
+
SoundboardSoundsAPI,
|
|
3123
3339
|
StageInstancesAPI,
|
|
3124
3340
|
StickersAPI,
|
|
3125
3341
|
ThreadsAPI,
|