mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 16:57:22 +00:00
Merge pull request #1098 from discordeno/fix-1086
fix(helpers): upsertSlashCommands requires at least the name of the command to edit
This commit is contained in:
@@ -2,6 +2,7 @@ import { applicationId } from "../../../bot.ts";
|
||||
import { rest } from "../../../rest/rest.ts";
|
||||
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
|
||||
import type { EditGlobalApplicationCommand } from "../../../types/interactions/commands/edit_global_application_command.ts";
|
||||
import { MakeRequired } from "../../../types/util.ts";
|
||||
import { endpoints } from "../../../util/constants.ts";
|
||||
import { validateSlashCommands } from "../../../util/utils.ts";
|
||||
|
||||
@@ -10,8 +11,11 @@ import { validateSlashCommands } from "../../../util/utils.ts";
|
||||
*
|
||||
* **NOTE:** Any slash commands that are not specified in this function will be **deleted**. If you don't provide the commandId and rename your command, the command gets a new Id.
|
||||
*/
|
||||
export async function upsertSlashCommands(options: EditGlobalApplicationCommand[], guildId?: bigint) {
|
||||
options = validateSlashCommands(options);
|
||||
export async function upsertSlashCommands(
|
||||
options: MakeRequired<EditGlobalApplicationCommand, "name">[],
|
||||
guildId?: bigint
|
||||
) {
|
||||
options = validateSlashCommands(options) as MakeRequired<EditGlobalApplicationCommand, "name">[];
|
||||
|
||||
return await rest.runMethod<ApplicationCommand[]>(
|
||||
"put",
|
||||
|
||||
@@ -151,3 +151,5 @@ export type CamelCasedPropertiesDeep<Value> = Value extends Function
|
||||
};
|
||||
|
||||
export type AtLeastOne<T, U = { [K in keyof T]: Pick<T, K> }> = Partial<T> & U[keyof U];
|
||||
|
||||
export type MakeRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
||||
|
||||
Reference in New Issue
Block a user