mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 01:10:07 +00:00
26 lines
767 B
TypeScript
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;
|
|
}
|