Prettified Code!

This commit is contained in:
itohatweb
2021-05-21 15:51:33 +00:00
committed by GitHub Action
parent fe4ab8517b
commit 3549cdeb63
279 changed files with 1617 additions and 1768 deletions
@@ -7,11 +7,11 @@ import { snakelize } from "../../../util/utils.ts";
/** Batch edits permissions for all commands in a guild. Takes an array of partial GuildApplicationCommandPermissions objects including `id` and `permissions`. */
export async function batchEditSlashCommandPermissions(
guildId: bigint,
options: { id: string; permissions: ApplicationCommandPermissions[] }[],
options: { id: string; permissions: ApplicationCommandPermissions[] }[]
) {
return await rest.runMethod(
"put",
endpoints.COMMANDS_PERMISSIONS(applicationId, guildId),
snakelize(options),
snakelize(options)
);
}
@@ -18,7 +18,7 @@ import { snakelize, validateSlashCommands } from "../../../util/utils.ts";
*/
export async function createSlashCommand(
options: CreateGlobalApplicationCommand,
guildId?: bigint,
guildId?: bigint
) {
validateSlashCommands([options], true);
@@ -27,6 +27,6 @@ export async function createSlashCommand(
guildId
? endpoints.COMMANDS_GUILD(applicationId, guildId)
: endpoints.COMMANDS(applicationId),
snakelize(options),
snakelize(options)
);
}
@@ -3,14 +3,11 @@ import { rest } from "../../../rest/rest.ts";
import { endpoints } from "../../../util/constants.ts";
/** Deletes a slash command. */
export async function deleteSlashCommand(
id: bigint,
guildId?: bigint,
) {
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),
: endpoints.COMMANDS_ID(applicationId, id)
);
}
@@ -3,18 +3,15 @@ import { rest } from "../../../rest/rest.ts";
import { endpoints } from "../../../util/constants.ts";
/** To delete your response to a slash command. If a message id is not provided, it will default to deleting the original response. */
export async function deleteSlashResponse(
token: string,
messageId?: bigint,
) {
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_ORIGINAL_ID_TOKEN(applicationId, token),
applicationId,
token,
messageId
)
: endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token)
);
}
@@ -8,11 +8,11 @@ import { snakelize } from "../../../util/utils.ts";
export async function editSlashCommandPermissions(
guildId: bigint,
commandId: bigint,
options: ApplicationCommandPermissions[],
options: ApplicationCommandPermissions[]
) {
return await rest.runMethod(
"put",
endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId),
{ permissions: snakelize(options) },
{ permissions: snakelize(options) }
);
}
@@ -9,7 +9,7 @@ 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,
options: DiscordenoEditWebhookMessage
) {
if (options.content && options.content.length > 2000) {
throw Error(Errors.MESSAGE_MAX_LENGTH);
@@ -23,18 +23,18 @@ export async function editSlashResponse(
if (options.allowedMentions.users?.length) {
if (
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.UserMentions,
DiscordAllowedMentionsTypes.UserMentions
)
) {
options.allowedMentions.parse = options.allowedMentions.parse.filter(
(p) => p !== "users",
(p) => p !== "users"
);
}
if (options.allowedMentions.users.length > 100) {
options.allowedMentions.users = options.allowedMentions.users.slice(
0,
100,
100
);
}
}
@@ -42,18 +42,18 @@ export async function editSlashResponse(
if (options.allowedMentions.roles?.length) {
if (
options.allowedMentions.parse?.includes(
DiscordAllowedMentionsTypes.RoleMentions,
DiscordAllowedMentionsTypes.RoleMentions
)
) {
options.allowedMentions.parse = options.allowedMentions.parse.filter(
(p) => p !== "roles",
(p) => p !== "roles"
);
}
if (options.allowedMentions.roles.length > 100) {
options.allowedMentions.roles = options.allowedMentions.roles.slice(
0,
100,
100
);
}
}
@@ -64,14 +64,12 @@ export async function editSlashResponse(
options.messageId
? endpoints.WEBHOOK_MESSAGE(applicationId, token, options.messageId)
: endpoints.INTERACTION_ORIGINAL_ID_TOKEN(applicationId, token),
options,
options
);
// If the original message was edited, this will not return a message
if (!options.messageId) return result as undefined;
const message = await structures.createDiscordenoMessage(
result,
);
const message = await structures.createDiscordenoMessage(result);
return message;
}
@@ -9,6 +9,6 @@ export async function getSlashCommand(commandId: bigint, guildId?: bigint) {
"get",
guildId
? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, commandId)
: endpoints.COMMANDS_ID(applicationId, commandId),
: endpoints.COMMANDS_ID(applicationId, commandId)
);
}
@@ -6,10 +6,10 @@ 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,
commandId: bigint
) {
return await rest.runMethod<GuildApplicationCommandPermissions>(
"get",
endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId),
endpoints.COMMANDS_PERMISSION(applicationId, guildId, commandId)
);
}
@@ -7,6 +7,6 @@ import { endpoints } from "../../../util/constants.ts";
export async function getSlashCommandPermissions(guildId: bigint) {
return await rest.runMethod<GuildApplicationCommandPermissions[]>(
"get",
endpoints.COMMANDS_PERMISSIONS(applicationId, guildId),
endpoints.COMMANDS_PERMISSIONS(applicationId, guildId)
);
}
@@ -10,7 +10,7 @@ export async function getSlashCommands(guildId?: bigint) {
"get",
guildId
? endpoints.COMMANDS_GUILD(applicationId, guildId)
: endpoints.COMMANDS(applicationId),
: endpoints.COMMANDS(applicationId)
);
return new Collection(result.map((command) => [command.name, command]));
@@ -11,7 +11,7 @@ import { validateSlashCommands } from "../../../util/utils.ts";
export async function upsertSlashCommand(
commandId: bigint,
options: EditGlobalApplicationCommand,
guildId?: bigint,
guildId?: bigint
) {
validateSlashCommands([options]);
@@ -20,6 +20,6 @@ export async function upsertSlashCommand(
guildId
? endpoints.COMMANDS_GUILD_ID(applicationId, guildId, commandId)
: endpoints.COMMANDS_ID(applicationId, commandId),
options,
options
);
}
@@ -12,7 +12,7 @@ import { validateSlashCommands } from "../../../util/utils.ts";
*/
export async function upsertSlashCommands(
options: EditGlobalApplicationCommand[],
guildId?: bigint,
guildId?: bigint
) {
validateSlashCommands(options);
@@ -21,6 +21,6 @@ export async function upsertSlashCommands(
guildId
? endpoints.COMMANDS_GUILD(applicationId, guildId)
: endpoints.COMMANDS(applicationId),
options,
options
);
}