mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat(core): Add support for role connections (#8930)
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
"@discordjs/rest": "workspace:^",
|
||||
"@discordjs/ws": "workspace:^",
|
||||
"@vladfrangu/async_event_emitter": "^2.1.2",
|
||||
"discord-api-types": "^0.37.20"
|
||||
"discord-api-types": "^0.37.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@favware/cliff-jumper": "^1.9.0",
|
||||
|
||||
40
packages/core/src/api/roleConnections.ts
Normal file
40
packages/core/src/api/roleConnections.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { REST } from '@discordjs/rest';
|
||||
import {
|
||||
Routes,
|
||||
type RESTGetAPIApplicationRoleConnectionMetadataResult,
|
||||
type RESTPutAPIApplicationRoleConnectionMetadataResult,
|
||||
type RESTPutAPIApplicationCommandPermissionsJSONBody,
|
||||
type Snowflake,
|
||||
} from 'discord-api-types/v10';
|
||||
|
||||
export class RoleConnectionsAPI {
|
||||
public constructor(private readonly rest: REST) {}
|
||||
|
||||
/**
|
||||
* Gets the role connection metadata records for the application
|
||||
*
|
||||
* @see {@link https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records}
|
||||
* @param applicationId - The id of the application to get role connection metadata records for
|
||||
*/
|
||||
public async getMetadataRecords(applicationId: Snowflake) {
|
||||
return this.rest.get(
|
||||
Routes.applicationRoleConnectionMetadata(applicationId),
|
||||
) as Promise<RESTGetAPIApplicationRoleConnectionMetadataResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the role connection metadata records for the application
|
||||
*
|
||||
* @see {@link https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records}
|
||||
* @param applicationId - The id of the application to update role connection metadata records for
|
||||
* @param options - The new role connection metadata records
|
||||
*/
|
||||
public async updateMetadataRecords(
|
||||
applicationId: Snowflake,
|
||||
options: RESTPutAPIApplicationCommandPermissionsJSONBody,
|
||||
) {
|
||||
return this.rest.put(Routes.applicationRoleConnectionMetadata(applicationId), {
|
||||
body: options,
|
||||
}) as Promise<RESTPutAPIApplicationRoleConnectionMetadataResult>;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import { makeURLSearchParams, type REST } from '@discordjs/rest';
|
||||
import {
|
||||
Routes,
|
||||
type RESTGetAPICurrentUserApplicationRoleConnectionResult,
|
||||
type RESTGetAPICurrentUserConnectionsResult,
|
||||
type RESTGetAPICurrentUserGuildsQuery,
|
||||
type RESTGetAPICurrentUserGuildsResult,
|
||||
type RESTGetAPICurrentUserResult,
|
||||
@@ -13,6 +15,8 @@ import {
|
||||
type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody,
|
||||
type RESTPatchAPIGuildVoiceStateCurrentMemberResult,
|
||||
type RESTPostAPICurrentUserCreateDMChannelResult,
|
||||
type RESTPutAPICurrentUserApplicationRoleConnectionJSONBody,
|
||||
type RESTPutAPICurrentUserApplicationRoleConnectionResult,
|
||||
type Snowflake,
|
||||
} from 'discord-api-types/v10';
|
||||
|
||||
@@ -119,4 +123,41 @@ export class UsersAPI {
|
||||
body: { recipient_id: userId },
|
||||
}) as Promise<RESTPostAPICurrentUserCreateDMChannelResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current user's connections
|
||||
*
|
||||
* @see {@link https://discord.com/developers/docs/resources/user#get-user-connections}
|
||||
*/
|
||||
public async getConnections() {
|
||||
return this.rest.get(Routes.userConnections()) as Promise<RESTGetAPICurrentUserConnectionsResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current user's active application role connection
|
||||
*
|
||||
* @see {@link https://discord.com/developers/docs/resources/user#get-user-application-role-connection}
|
||||
* @param applicationId - The id of the application
|
||||
*/
|
||||
public async getApplicationRoleConnection(applicationId: Snowflake) {
|
||||
return this.rest.get(
|
||||
Routes.userApplicationRoleConnection(applicationId),
|
||||
) as Promise<RESTGetAPICurrentUserApplicationRoleConnectionResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current user's application role connection
|
||||
*
|
||||
* @see {@link https://discord.com/developers/docs/resources/user#update-user-application-role-connection}
|
||||
* @param applicationId - The id of the application
|
||||
* @param options - The options to use when updating the application role connection
|
||||
*/
|
||||
public async updateApplicationRoleConnection(
|
||||
applicationId: Snowflake,
|
||||
options: RESTPutAPICurrentUserApplicationRoleConnectionJSONBody,
|
||||
) {
|
||||
return this.rest.put(Routes.userApplicationRoleConnection(applicationId), {
|
||||
body: options,
|
||||
}) as Promise<RESTPutAPICurrentUserApplicationRoleConnectionResult>;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user