change: prettier code

This commit is contained in:
TriForMine
2021-10-21 17:07:31 +00:00
committed by GitHub Action
parent a8ccf05e8b
commit baf8583976
16 changed files with 132 additions and 99 deletions
@@ -7,5 +7,10 @@ export async function batchEditSlashCommandPermissions(
guildId: bigint, guildId: bigint,
options: { id: string; permissions: ApplicationCommandPermissions[] }[] options: { id: string; permissions: ApplicationCommandPermissions[] }[]
) { ) {
return await bot.rest.runMethod(bot.rest,"put", bot.constants.endpoints.COMMANDS_PERMISSIONS(bot.applicationId, guildId), options); return await bot.rest.runMethod(
bot.rest,
"put",
bot.constants.endpoints.COMMANDS_PERMISSIONS(bot.applicationId, guildId),
options
);
} }
@@ -19,7 +19,9 @@ export async function createSlashCommand(bot: Bot, options: CreateGlobalApplicat
return await bot.rest.runMethod<ApplicationCommand>( return await bot.rest.runMethod<ApplicationCommand>(
bot.rest, bot.rest,
"post", "post",
guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId), guildId
? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId)
: bot.constants.endpoints.COMMANDS(bot.applicationId),
options options
); );
} }
@@ -5,6 +5,8 @@ export async function deleteSlashCommand(bot: Bot, id: bigint, guildId?: bigint)
return await bot.rest.runMethod<undefined>( return await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"delete", "delete",
guildId ? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, id) : bot.constants.endpoints.COMMANDS_ID(bot.applicationId, id) guildId
? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, id)
: bot.constants.endpoints.COMMANDS_ID(bot.applicationId, id)
); );
} }
@@ -8,7 +8,12 @@ export async function editSlashCommandPermissions(
commandId: bigint, commandId: bigint,
options: ApplicationCommandPermissions[] options: ApplicationCommandPermissions[]
) { ) {
return await bot.rest.runMethod(bot.rest,"put", bot.constants.endpoints.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId), { return await bot.rest.runMethod(
bot.rest,
"put",
bot.constants.endpoints.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId),
{
permissions: options, permissions: options,
}); }
);
} }
@@ -48,12 +48,14 @@ export async function editSlashResponse(bot: Bot, token: string, options: Discor
content: options.content, content: options.content,
embeds: options.embeds, embeds: options.embeds,
file: options.file, file: options.file,
allowed_mentions: options.allowedMentions ? { allowed_mentions: options.allowedMentions
? {
parse: options.allowedMentions.parse, parse: options.allowedMentions.parse,
roles: options.allowedMentions.roles, roles: options.allowedMentions.roles,
users: options.allowedMentions.users, users: options.allowedMentions.users,
replied_user: options.allowedMentions.repliedUser replied_user: options.allowedMentions.repliedUser,
} : undefined, }
: undefined,
attachments: options.attachments, attachments: options.attachments,
// TODO: Snakelize components?? // TODO: Snakelize components??
components: options.components, components: options.components,
@@ -7,13 +7,19 @@ export async function getSlashCommands(bot: Bot, guildId?: bigint) {
const result = await bot.rest.runMethod<ApplicationCommand[]>( const result = await bot.rest.runMethod<ApplicationCommand[]>(
bot.rest, bot.rest,
"get", "get",
guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId) guildId
? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId)
: bot.constants.endpoints.COMMANDS(bot.applicationId)
); );
return new Collection( return new Collection(
result.map((command) => [ result.map((command) => [
command.name, command.name,
{ ...command, id: bot.transformers.snowflake(command.id), applicationId: bot.transformers.snowflake(command.applicationId) }, {
...command,
id: bot.transformers.snowflake(command.id),
applicationId: bot.transformers.snowflake(command.applicationId),
},
]) ])
); );
} }
@@ -5,7 +5,12 @@ import type {Bot} from "../../../bot.ts";
/** /**
* Edit an existing slash command. If this command did not exist, it will create it. * Edit an existing slash command. If this command did not exist, it will create it.
*/ */
export async function upsertSlashCommand(bot: Bot, commandId: bigint, options: EditGlobalApplicationCommand, guildId?: bigint) { export async function upsertSlashCommand(
bot: Bot,
commandId: bigint,
options: EditGlobalApplicationCommand,
guildId?: bigint
) {
[options] = bot.utils.validateSlashCommands([options]); [options] = bot.utils.validateSlashCommands([options]);
return await bot.rest.runMethod<ApplicationCommand>( return await bot.rest.runMethod<ApplicationCommand>(
@@ -18,7 +18,9 @@ export async function upsertSlashCommands(
return await bot.rest.runMethod<ApplicationCommand[]>( return await bot.rest.runMethod<ApplicationCommand[]>(
bot.rest, bot.rest,
"put", "put",
guildId ? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId) : bot.constants.endpoints.COMMANDS(bot.applicationId), guildId
? bot.constants.endpoints.COMMANDS_GUILD(bot.applicationId, guildId)
: bot.constants.endpoints.COMMANDS(bot.applicationId),
options options
); );
} }
@@ -4,7 +4,11 @@ import type {SnakeCasedPropertiesDeep} from "../../types/util.ts";
/** Returns the initial Interaction response. Functions the same as Get Webhook Message */ /** Returns the initial Interaction response. Functions the same as Get Webhook Message */
export async function getOriginalInteractionResponse(bot: Bot, token: string) { export async function getOriginalInteractionResponse(bot: Bot, token: string) {
const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Message>>(bot.rest,"get", bot.constants.endpoints.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token)); const result = await bot.rest.runMethod<SnakeCasedPropertiesDeep<Message>>(
bot.rest,
"get",
bot.constants.endpoints.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token)
);
return bot.transformers.message(result); return bot.transformers.message(result);
} }
@@ -42,7 +42,7 @@ export async function sendInteractionResponse(
parse: options.data.allowedMentions.parse, parse: options.data.allowedMentions.parse,
roles: options.data.allowedMentions.roles, roles: options.data.allowedMentions.roles,
users: options.data.allowedMentions.users, users: options.data.allowedMentions.users,
replied_user: options.data.allowedMentions.repliedUser replied_user: options.data.allowedMentions.repliedUser,
}, },
...(options.data.messageReference?.messageId ...(options.data.messageReference?.messageId
? { ? {
@@ -57,7 +57,7 @@ export async function sendInteractionResponse(
file: options.data.file, file: options.data.file,
// TODO: Snakelize components?? // TODO: Snakelize components??
components: options.data.components, components: options.data.components,
flags: options.data.flags flags: options.data.flags,
}); });
} }
@@ -80,7 +80,7 @@ export async function sendInteractionResponse(
parse: options.data.allowedMentions.parse, parse: options.data.allowedMentions.parse,
roles: options.data.allowedMentions.roles, roles: options.data.allowedMentions.roles,
users: options.data.allowedMentions.users, users: options.data.allowedMentions.users,
replied_user: options.data.allowedMentions.repliedUser replied_user: options.data.allowedMentions.repliedUser,
}, },
...(options.data.messageReference?.messageId ...(options.data.messageReference?.messageId
? { ? {
@@ -95,7 +95,7 @@ export async function sendInteractionResponse(
file: options.data.file, file: options.data.file,
// TODO: Snakelize components?? // TODO: Snakelize components??
components: options.data.components, components: options.data.components,
flags: options.data.flags flags: options.data.flags,
} }
); );
} }
+1 -1
View File
@@ -85,7 +85,7 @@ export async function sendMessage(bot: Bot, channelId: bigint, content: string |
parse: content.allowedMentions.parse, parse: content.allowedMentions.parse,
roles: content.allowedMentions.roles, roles: content.allowedMentions.roles,
users: content.allowedMentions.users, users: content.allowedMentions.users,
replied_user: content.allowedMentions.repliedUser replied_user: content.allowedMentions.repliedUser,
}, },
file: content.file, file: content.file,
// TODO: Snakelize components?? // TODO: Snakelize components??
+1 -1
View File
@@ -58,7 +58,7 @@ export async function editWebhookMessage(
parse: content.allowedMentions.parse, parse: content.allowedMentions.parse,
roles: content.allowedMentions.roles, roles: content.allowedMentions.roles,
users: content.allowedMentions.users, users: content.allowedMentions.users,
replied_user: content.allowedMentions.repliedUser replied_user: content.allowedMentions.repliedUser,
}, },
attachments: options.attachments, attachments: options.attachments,
// TODO: Snakelize components?? // TODO: Snakelize components??