mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
fix(rest): Add support for getGuilds with bot token (#3360)
* Add support for getGuilds with bot token * Update manager.ts * Fix prettier error
This commit is contained in:
@@ -1098,12 +1098,16 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getGuilds(token, options) {
|
async getGuilds(token, options) {
|
||||||
return await rest.get<DiscordPartialGuild[]>(rest.routes.guilds.userGuilds(options), {
|
const makeRequestOptions: MakeRequestOptions | undefined = token
|
||||||
headers: {
|
? {
|
||||||
authorization: `Bearer ${token}`,
|
headers: {
|
||||||
},
|
authorization: `Bearer ${token}`,
|
||||||
unauthorized: true,
|
},
|
||||||
})
|
unauthorized: true,
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
|
||||||
|
return await rest.get<DiscordPartialGuild[]>(rest.routes.guilds.userGuilds(options), makeRequestOptions)
|
||||||
},
|
},
|
||||||
|
|
||||||
async getGuildApplicationCommand(commandId, guildId) {
|
async getGuildApplicationCommand(commandId, guildId) {
|
||||||
|
|||||||
@@ -1794,16 +1794,16 @@ export interface RestManager {
|
|||||||
/**
|
/**
|
||||||
* Get the user guilds.
|
* Get the user guilds.
|
||||||
*
|
*
|
||||||
* @param bearerToken - The access token of the user
|
* @param bearerToken - The access token of the user, if unspecified the bot token is used instead
|
||||||
* @param options - The parameters for the fetching of the guild.
|
* @param options - The parameters for the fetching of the guild.
|
||||||
* @returns An instance of {@link Guild}.
|
* @returns An instance of {@link Guild}.
|
||||||
*
|
*
|
||||||
* @remarks
|
* @remarks
|
||||||
* The access tokens needs to have the `guilds` scope
|
* If used with an access token, the token needs to have the `guilds` scope
|
||||||
*
|
*
|
||||||
* @see {@link https://discord.com/developers/docs/resources/user#get-current-user-guilds}
|
* @see {@link https://discord.com/developers/docs/resources/user#get-current-user-guilds}
|
||||||
*/
|
*/
|
||||||
getGuilds: (bearerToken: string, options?: GetUserGuilds) => Promise<CamelizedDiscordPartialGuild[]>
|
getGuilds: (bearerToken?: string, options?: GetUserGuilds) => Promise<CamelizedDiscordPartialGuild[]>
|
||||||
/**
|
/**
|
||||||
* Gets a guild application command by its ID.
|
* Gets a guild application command by its ID.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user