mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
feat: add {add,remove}GroupDMRecipient methods (#11135)
* feat: add `{add,delete}GroupDMRecipient methods`
* fix: requested changes
---------
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
34
packages/core/scripts/check-routes.mjs
Normal file
34
packages/core/scripts/check-routes.mjs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import { Routes } from 'discord-api-types/v10';
|
||||||
|
import { glob, readFile } from 'node:fs/promises';
|
||||||
|
|
||||||
|
const usedRoutes = new Set();
|
||||||
|
|
||||||
|
const ignoredRoutes = new Set([
|
||||||
|
// Deprecated
|
||||||
|
'channelPins',
|
||||||
|
'channelPin',
|
||||||
|
'guilds',
|
||||||
|
'guildCurrentMemberNickname',
|
||||||
|
'guildMFA',
|
||||||
|
'nitroStickerPacks',
|
||||||
|
]);
|
||||||
|
|
||||||
|
for await (const file of glob('src/api/*.ts')) {
|
||||||
|
const content = await readFile(file, 'utf-8');
|
||||||
|
|
||||||
|
const routes = content.matchAll(/Routes\.([\w\d_]+)/g);
|
||||||
|
for (const route of routes) {
|
||||||
|
usedRoutes.add(route[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const unusedRoutes = Object.keys(Routes).filter((route) => !usedRoutes.has(route) && !ignoredRoutes.has(route));
|
||||||
|
|
||||||
|
if (unusedRoutes.length > 0) {
|
||||||
|
console.warn('The following routes are not implemented:');
|
||||||
|
for (const route of unusedRoutes) {
|
||||||
|
console.warn(` - ${route}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('No missing routes.');
|
||||||
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
/* eslint-disable jsdoc/check-param-names */
|
/* eslint-disable jsdoc/check-param-names */
|
||||||
|
|
||||||
import { makeURLSearchParams, type RawFile, type REST, type RequestData } from '@discordjs/rest';
|
import { makeURLSearchParams, type RawFile, type RequestData, type REST } from '@discordjs/rest';
|
||||||
import {
|
import {
|
||||||
Routes,
|
Routes,
|
||||||
type RESTPostAPIChannelWebhookJSONBody,
|
type APIThreadChannel,
|
||||||
type RESTPostAPIChannelWebhookResult,
|
|
||||||
type RESTDeleteAPIChannelResult,
|
type RESTDeleteAPIChannelResult,
|
||||||
type RESTGetAPIChannelInvitesResult,
|
type RESTGetAPIChannelInvitesResult,
|
||||||
type RESTGetAPIChannelMessageReactionUsersQuery,
|
type RESTGetAPIChannelMessageReactionUsersQuery,
|
||||||
@@ -17,8 +16,8 @@ import {
|
|||||||
type RESTGetAPIChannelThreadsArchivedQuery,
|
type RESTGetAPIChannelThreadsArchivedQuery,
|
||||||
type RESTGetAPIChannelUsersThreadsArchivedResult,
|
type RESTGetAPIChannelUsersThreadsArchivedResult,
|
||||||
type RESTGetAPIChannelWebhooksResult,
|
type RESTGetAPIChannelWebhooksResult,
|
||||||
type RESTPatchAPIChannelMessageJSONBody,
|
|
||||||
type RESTPatchAPIChannelJSONBody,
|
type RESTPatchAPIChannelJSONBody,
|
||||||
|
type RESTPatchAPIChannelMessageJSONBody,
|
||||||
type RESTPatchAPIChannelMessageResult,
|
type RESTPatchAPIChannelMessageResult,
|
||||||
type RESTPatchAPIChannelResult,
|
type RESTPatchAPIChannelResult,
|
||||||
type RESTPostAPIChannelFollowersResult,
|
type RESTPostAPIChannelFollowersResult,
|
||||||
@@ -27,12 +26,14 @@ import {
|
|||||||
type RESTPostAPIChannelMessageCrosspostResult,
|
type RESTPostAPIChannelMessageCrosspostResult,
|
||||||
type RESTPostAPIChannelMessageJSONBody,
|
type RESTPostAPIChannelMessageJSONBody,
|
||||||
type RESTPostAPIChannelMessageResult,
|
type RESTPostAPIChannelMessageResult,
|
||||||
type RESTPutAPIChannelPermissionJSONBody,
|
|
||||||
type Snowflake,
|
|
||||||
type RESTPostAPIChannelThreadsJSONBody,
|
type RESTPostAPIChannelThreadsJSONBody,
|
||||||
type RESTPostAPIChannelThreadsResult,
|
type RESTPostAPIChannelThreadsResult,
|
||||||
type APIThreadChannel,
|
type RESTPostAPIChannelWebhookJSONBody,
|
||||||
|
type RESTPostAPIChannelWebhookResult,
|
||||||
type RESTPostAPIGuildForumThreadsJSONBody,
|
type RESTPostAPIGuildForumThreadsJSONBody,
|
||||||
|
type RESTPutAPIChannelPermissionJSONBody,
|
||||||
|
type RESTPutAPIChannelRecipientJSONBody,
|
||||||
|
type Snowflake,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
|
|
||||||
export interface StartForumThreadOptions extends RESTPostAPIGuildForumThreadsJSONBody {
|
export interface StartForumThreadOptions extends RESTPostAPIGuildForumThreadsJSONBody {
|
||||||
@@ -593,4 +594,43 @@ export class ChannelsAPI {
|
|||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a recipient to a group DM channel
|
||||||
|
*
|
||||||
|
* @see {@link https://discord.com/developers/docs/resources/channel#group-dm-add-recipient}
|
||||||
|
* @param channelId - The id of the channel to add the recipient to
|
||||||
|
* @param userId - The id of the user to add as a recipient
|
||||||
|
* @param body - The data for adding the recipient
|
||||||
|
* @param options - The options for adding the recipient
|
||||||
|
*/
|
||||||
|
public async addGroupDMRecipient(
|
||||||
|
channelId: Snowflake,
|
||||||
|
userId: Snowflake,
|
||||||
|
body: RESTPutAPIChannelRecipientJSONBody,
|
||||||
|
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||||
|
) {
|
||||||
|
await this.rest.put(Routes.channelRecipient(channelId, userId), {
|
||||||
|
body,
|
||||||
|
signal,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a recipient from a group DM channel
|
||||||
|
*
|
||||||
|
* @see {@link https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient}
|
||||||
|
* @param channelId - The id of the channel to remove the recipient from
|
||||||
|
* @param userId - The id of the user to remove as a recipient
|
||||||
|
* @param options - The options for removing the recipient
|
||||||
|
*/
|
||||||
|
public async removeGroupDMRecipient(
|
||||||
|
channelId: Snowflake,
|
||||||
|
userId: Snowflake,
|
||||||
|
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||||
|
) {
|
||||||
|
await this.rest.delete(Routes.channelRecipient(channelId, userId), {
|
||||||
|
signal,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user