Prettified Code!

This commit is contained in:
itohatweb
2021-05-21 15:55:49 +00:00
committed by GitHub Action
parent 71a20fb0f4
commit 179add27c9
271 changed files with 889 additions and 3067 deletions
@@ -9,9 +9,5 @@ export async function batchEditSlashCommandPermissions(
guildId: bigint,
options: { id: string; permissions: ApplicationCommandPermissions[] }[]
) {
return await rest.runMethod(
"put",
endpoints.COMMANDS_PERMISSIONS(applicationId, guildId),
snakelize(options)
);
return await rest.runMethod("put", endpoints.COMMANDS_PERMISSIONS(applicationId, guildId), snakelize(options));
}
@@ -16,17 +16,12 @@ import { snakelize, validateSlashCommands } from "../../../util/utils.ts";
* Global commands are cached for **1 hour**. That means that new global commands will fan out slowly across all guilds, and will be guaranteed to be updated in an hour.
* Guild commands update **instantly**. We recommend you use guild commands for quick testing, and global commands when they're ready for public use.
*/
export async function createSlashCommand(
options: CreateGlobalApplicationCommand,
guildId?: bigint
) {
export async function createSlashCommand(options: CreateGlobalApplicationCommand, guildId?: bigint) {
validateSlashCommands([options], true);
return await rest.runMethod<ApplicationCommand>(
"post",
guildId
? endpoints.COMMANDS_GUILD(applicationId, guildId)
: endpoints.COMMANDS(applicationId),
guildId ? endpoints.COMMANDS_GUILD(applicationId, guildId) : endpoints.COMMANDS(applicationId),
snakelize(options)
);
}
@@ -6,8 +6,6 @@ import { endpoints } from "../../../util/constants.ts";
export async function deleteSlashCommand(id: bigint, guildId?: bigint) {
return await rest.runMethod<undefined>(
"delete",
guildId
? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, id)
: endpoints.COMMANDS_ID(applicationId, id)
guildId ? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, id) : endpoints.COMMANDS_ID(applicationId, id)
);
}
@@ -7,11 +7,7 @@ export async function deleteSlashResponse(token: string, messageId?: bigint) {
return await rest.runMethod<undefined>(
"delete",
messageId
? endpoints.INTERACTION_ID_TOKEN_MESSAGE_ID(
applicationId,
token,
messageId
)
? endpoints.INTERACTION_ID_TOKEN_MESSAGE_ID(applicationId, token, messageId)
: endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token)
);
}
@@ -10,9 +10,7 @@ export async function editSlashCommandPermissions(
commandId: bigint,
options: ApplicationCommandPermissions[]
) {
return await rest.runMethod(
"put",
endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId),
{ permissions: snakelize(options) }
);
return await rest.runMethod("put", endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId), {
permissions: snakelize(options),
});
}
@@ -7,10 +7,7 @@ import { DiscordAllowedMentionsTypes } from "../../../types/messages/allowed_men
import { endpoints } from "../../../util/constants.ts";
/** To edit your response to a slash command. If a messageId is not provided it will default to editing the original response. */
export async function editSlashResponse(
token: string,
options: DiscordenoEditWebhookMessage
) {
export async function editSlashResponse(token: string, options: DiscordenoEditWebhookMessage) {
if (options.content && options.content.length > 2000) {
throw Error(Errors.MESSAGE_MAX_LENGTH);
}
@@ -21,40 +18,22 @@ export async function editSlashResponse(
if (options.allowedMentions) {
if (options.allowedMentions.users?.length) {
if (
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.UserMentions
)
) {
options.allowedMentions.parse = options.allowedMentions.parse.filter(
(p) => p !== "users"
);
if (options.allowedMentions.parse?.includes(DiscordAllowedMentionsTypes.UserMentions)) {
options.allowedMentions.parse = options.allowedMentions.parse.filter((p) => p !== "users");
}
if (options.allowedMentions.users.length > 100) {
options.allowedMentions.users = options.allowedMentions.users.slice(
0,
100
);
options.allowedMentions.users = options.allowedMentions.users.slice(0, 100);
}
}
if (options.allowedMentions.roles?.length) {
if (
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.RoleMentions
)
) {
options.allowedMentions.parse = options.allowedMentions.parse.filter(
(p) => p !== "roles"
);
if (options.allowedMentions.parse?.includes(DiscordAllowedMentionsTypes.RoleMentions)) {
options.allowedMentions.parse = options.allowedMentions.parse.filter((p) => p !== "roles");
}
if (options.allowedMentions.roles.length > 100) {
options.allowedMentions.roles = options.allowedMentions.roles.slice(
0,
100
);
options.allowedMentions.roles = options.allowedMentions.roles.slice(0, 100);
}
}
}
@@ -4,10 +4,7 @@ import type { GuildApplicationCommandPermissions } from "../../../types/interact
import { endpoints } from "../../../util/constants.ts";
/** Fetches command permissions for a specific command for your application in a guild. Returns a GuildApplicationCommandPermissions object. */
export async function getSlashCommandPermission(
guildId: bigint,
commandId: bigint
) {
export async function getSlashCommandPermission(guildId: bigint, commandId: bigint) {
return await rest.runMethod<GuildApplicationCommandPermissions>(
"get",
endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId)
@@ -8,9 +8,7 @@ import { endpoints } from "../../../util/constants.ts";
export async function getSlashCommands(guildId?: bigint) {
const result = await rest.runMethod<ApplicationCommand[]>(
"get",
guildId
? endpoints.COMMANDS_GUILD(applicationId, guildId)
: endpoints.COMMANDS(applicationId)
guildId ? endpoints.COMMANDS_GUILD(applicationId, guildId) : endpoints.COMMANDS(applicationId)
);
return new Collection(result.map((command) => [command.name, command]));
@@ -8,11 +8,7 @@ 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: bigint,
options: EditGlobalApplicationCommand,
guildId?: bigint
) {
export async function upsertSlashCommand(commandId: bigint, options: EditGlobalApplicationCommand, guildId?: bigint) {
validateSlashCommands([options]);
return await rest.runMethod<ApplicationCommand>(
@@ -10,17 +10,12 @@ 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
) {
export async function upsertSlashCommands(options: EditGlobalApplicationCommand[], guildId?: bigint) {
validateSlashCommands(options);
return await rest.runMethod<ApplicationCommand[]>(
"put",
guildId
? endpoints.COMMANDS_GUILD(applicationId, guildId)
: endpoints.COMMANDS(applicationId),
guildId ? endpoints.COMMANDS_GUILD(applicationId, guildId) : endpoints.COMMANDS(applicationId),
options
);
}