mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 00:37:22 +00:00
feat: Add bulk update lobby members endpoint (#5231)
This commit is contained in:
@@ -5,6 +5,7 @@ import type {
|
|||||||
AtLeastOne,
|
AtLeastOne,
|
||||||
BeginGuildPrune,
|
BeginGuildPrune,
|
||||||
BigString,
|
BigString,
|
||||||
|
BulkUpdateLobbyMember,
|
||||||
Camelize,
|
Camelize,
|
||||||
CreateApplicationCommand,
|
CreateApplicationCommand,
|
||||||
CreateApplicationEmoji,
|
CreateApplicationEmoji,
|
||||||
@@ -619,6 +620,9 @@ export function createBotHelpers<TProps extends TransformersDesiredProperties, T
|
|||||||
addMemberToLobby: async (lobbyId, userId, options) => {
|
addMemberToLobby: async (lobbyId, userId, options) => {
|
||||||
return bot.transformers.lobbyMember(bot, snakelize(await bot.rest.addMemberToLobby(lobbyId, userId, options)));
|
return bot.transformers.lobbyMember(bot, snakelize(await bot.rest.addMemberToLobby(lobbyId, userId, options)));
|
||||||
},
|
},
|
||||||
|
bulkUpdateLobbyMembers: async (lobbyId, options) => {
|
||||||
|
return (await bot.rest.bulkUpdateLobbyMembers(lobbyId, options)).map((res) => bot.transformers.lobbyMember(bot, snakelize(res)));
|
||||||
|
},
|
||||||
linkChannelToLobby: async (lobbyId, bearerToken, options) => {
|
linkChannelToLobby: async (lobbyId, bearerToken, options) => {
|
||||||
return bot.transformers.lobby(bot, snakelize(await bot.rest.linkChannelToLobby(lobbyId, bearerToken, options)));
|
return bot.transformers.lobby(bot, snakelize(await bot.rest.linkChannelToLobby(lobbyId, bearerToken, options)));
|
||||||
},
|
},
|
||||||
@@ -1169,6 +1173,7 @@ export type BotHelpers<TProps extends TransformersDesiredProperties, TBehavior e
|
|||||||
getLobby: (lobbyId: BigString) => Promise<SetupDesiredProps<Lobby, TProps, TBehavior>>;
|
getLobby: (lobbyId: BigString) => Promise<SetupDesiredProps<Lobby, TProps, TBehavior>>;
|
||||||
modifyLobby: (lobbyId: BigString, options: ModifyLobby) => Promise<SetupDesiredProps<Lobby, TProps, TBehavior>>;
|
modifyLobby: (lobbyId: BigString, options: ModifyLobby) => Promise<SetupDesiredProps<Lobby, TProps, TBehavior>>;
|
||||||
addMemberToLobby: (lobbyId: BigString, userId: BigString, options: AddLobbyMember) => Promise<SetupDesiredProps<LobbyMember, TProps, TBehavior>>;
|
addMemberToLobby: (lobbyId: BigString, userId: BigString, options: AddLobbyMember) => Promise<SetupDesiredProps<LobbyMember, TProps, TBehavior>>;
|
||||||
|
bulkUpdateLobbyMembers: (lobbyId: BigString, options: BulkUpdateLobbyMember[]) => Promise<SetupDesiredProps<LobbyMember, TProps, TBehavior>[]>;
|
||||||
linkChannelToLobby: (lobbyId: BigString, bearerToken: string, options: LinkChannelToLobby) => Promise<SetupDesiredProps<Lobby, TProps, TBehavior>>;
|
linkChannelToLobby: (lobbyId: BigString, bearerToken: string, options: LinkChannelToLobby) => Promise<SetupDesiredProps<Lobby, TProps, TBehavior>>;
|
||||||
unlinkChannelToLobby: (lobbyId: BigString, bearerToken: string) => Promise<SetupDesiredProps<Lobby, TProps, TBehavior>>;
|
unlinkChannelToLobby: (lobbyId: BigString, bearerToken: string) => Promise<SetupDesiredProps<Lobby, TProps, TBehavior>>;
|
||||||
updateLobbyMessageModerationMetadata: (lobbyId: BigString, messageId: BigString, options: Record<string, string>) => Promise<void>;
|
updateLobbyMessageModerationMetadata: (lobbyId: BigString, messageId: BigString, options: Record<string, string>) => Promise<void>;
|
||||||
|
|||||||
@@ -1904,6 +1904,12 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async bulkUpdateLobbyMembers(lobbyId, options) {
|
||||||
|
return await rest.post<DiscordLobbyMember[]>(rest.routes.lobby.membersBulk(lobbyId), {
|
||||||
|
body: options,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
async removeMemberFromLobby(lobbyId, userId) {
|
async removeMemberFromLobby(lobbyId, userId) {
|
||||||
return await rest.delete(rest.routes.lobby.member(lobbyId, userId));
|
return await rest.delete(rest.routes.lobby.member(lobbyId, userId));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -695,6 +695,10 @@ export function createRoutes(disableURIEncode: boolean = false): RestRoutes {
|
|||||||
return `/lobbies/${encode(lobbyId)}/channel-linking`;
|
return `/lobbies/${encode(lobbyId)}/channel-linking`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
membersBulk: (lobbyId) => {
|
||||||
|
return `/lobbies/${encode(lobbyId)}/members/bulk`;
|
||||||
|
},
|
||||||
|
|
||||||
moderationMetadata: (lobbyId, messageId) => {
|
moderationMetadata: (lobbyId, messageId) => {
|
||||||
return `/lobbies/${encode(lobbyId)}/messages/${encode(messageId)}/moderation-metadata`;
|
return `/lobbies/${encode(lobbyId)}/messages/${encode(messageId)}/moderation-metadata`;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type {
|
|||||||
AtLeastOne,
|
AtLeastOne,
|
||||||
BeginGuildPrune,
|
BeginGuildPrune,
|
||||||
BigString,
|
BigString,
|
||||||
|
BulkUpdateLobbyMember,
|
||||||
Camelize,
|
Camelize,
|
||||||
ChannelTypes,
|
ChannelTypes,
|
||||||
CreateApplicationCommand,
|
CreateApplicationCommand,
|
||||||
@@ -3257,6 +3258,22 @@ export interface RestManager {
|
|||||||
* @returns The lobby member object
|
* @returns The lobby member object
|
||||||
*/
|
*/
|
||||||
addMemberToLobby: (lobbyId: BigString, userId: BigString, options: AddLobbyMember) => Promise<Camelize<DiscordLobbyMember>>;
|
addMemberToLobby: (lobbyId: BigString, userId: BigString, options: AddLobbyMember) => Promise<Camelize<DiscordLobbyMember>>;
|
||||||
|
/**
|
||||||
|
* Adds, updates, or removes up to 25 members from the specified lobby in a single request.
|
||||||
|
*
|
||||||
|
* @param lobbyId - The ID of the lobby to add, update, or remove members from
|
||||||
|
* @param options - The options to add, update, or remove members from the lobby
|
||||||
|
* @returns Returns an array of lobby member objects for the upserted members. Removed members are not included in the response.
|
||||||
|
*
|
||||||
|
* @remarks
|
||||||
|
* Members with `remove_member: false` (the default) are upserted — added if not present, or updated with the provided metadata and flags if already a member. Members with `remove_member: true` are removed.
|
||||||
|
*
|
||||||
|
* Users unknown to Discord will return a 404 UNKNOWN_USER error.
|
||||||
|
* Users that fail permission checks or who have already reached the maximum number of lobbies per application (and are not already a member of this lobby) are silently dropped from the upsert set.
|
||||||
|
*
|
||||||
|
* @see {@link https://docs.discord.com/developers/resources/lobby#bulk-update-lobby-members}
|
||||||
|
*/
|
||||||
|
bulkUpdateLobbyMembers: (lobbyId: BigString, options: BulkUpdateLobbyMember[]) => Promise<Camelize<DiscordLobbyMember>[]>;
|
||||||
/**
|
/**
|
||||||
* Removes the provided user from the specified lobby. It is safe to call this even if the user is no longer a member of the lobby, but will fail if the lobby does not exist.
|
* Removes the provided user from the specified lobby. It is safe to call this even if the user is no longer a member of the lobby, but will fail if the lobby does not exist.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -316,6 +316,8 @@ export interface RestRoutes {
|
|||||||
leave: (lobbyId: BigString) => string;
|
leave: (lobbyId: BigString) => string;
|
||||||
/** Route to link a lobby */
|
/** Route to link a lobby */
|
||||||
link: (lobbyId: BigString) => string;
|
link: (lobbyId: BigString) => string;
|
||||||
|
/** Route to bulk update members of a lobby */
|
||||||
|
membersBulk: (lobbyId: BigString) => string;
|
||||||
/** Route to set the lobby moderation metadata */
|
/** Route to set the lobby moderation metadata */
|
||||||
moderationMetadata: (lobbyId: BigString, messageId: BigString) => string;
|
moderationMetadata: (lobbyId: BigString, messageId: BigString) => string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -45,6 +45,26 @@ export interface AddLobbyMember {
|
|||||||
flags?: number;
|
flags?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** https://docs.discord.com/developers/resources/lobby#bulk-update-lobby-members */
|
||||||
|
export interface BulkUpdateLobbyMember {
|
||||||
|
/** Discord user id of the user to add, update, or remove */
|
||||||
|
id: BigString;
|
||||||
|
/** Optional dictionary of string key/value pairs. The max total length is 1000. */
|
||||||
|
metadata?: Record<string, string> | null;
|
||||||
|
/**
|
||||||
|
* Lobby member flags combined as a bitfield
|
||||||
|
*
|
||||||
|
* @see {@link DiscordLobbyMemberFlags}
|
||||||
|
*/
|
||||||
|
flags?: number;
|
||||||
|
/**
|
||||||
|
* if `true`, the user is removed from the lobby instead of upserted.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
removeMember?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/** https://docs.discord.com/developers/resources/lobby#link-channel-to-lobby */
|
/** https://docs.discord.com/developers/resources/lobby#link-channel-to-lobby */
|
||||||
export interface LinkChannelToLobby {
|
export interface LinkChannelToLobby {
|
||||||
/** The id of the channel to link to the lobby. If not provided, will unlink any currently linked channels from the lobby. */
|
/** The id of the channel to link to the lobby. If not provided, will unlink any currently linked channels from the lobby. */
|
||||||
|
|||||||
Reference in New Issue
Block a user