Files
discordeno/src/helpers/commands/upsert_slash_command.ts
ayntee e9cbbbff7c refactor(helpers): separate functions into files (#667)
* refactor(helpers): separate functions into files

* idk

* idk
2021-03-13 08:10:31 -05:00

26 lines
767 B
TypeScript

import { applicationID } from "../../bot.ts";
import { RequestManager } from "../../rest/request_manager.ts";
import { UpsertSlashCommandOptions } from "../../types/mod.ts";
import { endpoints } from "../../util/constants.ts";
import { validateSlashCommands } from "../../util/utils.ts";
/**
* Edit an existing slash command. If this command did not exist, it will create it.
*/
export async function upsertSlashCommand(
commandID: string,
options: UpsertSlashCommandOptions,
guildID?: string,
) {
validateSlashCommands([options]);
const result = await RequestManager.patch(
guildID
? endpoints.COMMANDS_GUILD_ID(applicationID, guildID, commandID)
: endpoints.COMMANDS_ID(applicationID, commandID),
options,
);
return result;
}