From 5bb6b2626ebc9f59ca364cca5efb5a2213017191 Mon Sep 17 00:00:00 2001 From: ITOH Date: Sun, 15 Aug 2021 12:03:14 +0200 Subject: [PATCH 1/2] add(types): MakeRequired util --- src/types/util.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/util.ts b/src/types/util.ts index c25e6f7fd..7766eb40a 100644 --- a/src/types/util.ts +++ b/src/types/util.ts @@ -151,3 +151,5 @@ export type CamelCasedPropertiesDeep = Value extends Function }; export type AtLeastOne }> = Partial & U[keyof U]; + +export type MakeRequired = T & { [P in K]-?: T[P] }; From 9e5bded859fdc8fefecb3618daa10eae9d5fa1a5 Mon Sep 17 00:00:00 2001 From: ITOH Date: Sun, 15 Aug 2021 12:03:31 +0200 Subject: [PATCH 2/2] fix(helpers): upsertSlashCommands needs name of the commands to edit --- .../interactions/commands/upsert_slash_commands.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/helpers/interactions/commands/upsert_slash_commands.ts b/src/helpers/interactions/commands/upsert_slash_commands.ts index ff7bb29d3..a3604c7cd 100644 --- a/src/helpers/interactions/commands/upsert_slash_commands.ts +++ b/src/helpers/interactions/commands/upsert_slash_commands.ts @@ -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[], + guildId?: bigint +) { + options = validateSlashCommands(options) as MakeRequired[]; return await rest.runMethod( "put",