change: prettier code

This commit is contained in:
Skillz4Killz
2021-11-10 20:35:03 +00:00
committed by GitHub Action
parent 0f91120769
commit 370d62be04
15 changed files with 43 additions and 65 deletions
+1 -5
View File
@@ -5,9 +5,5 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
export async function handleGuildBanAdd(bot: Bot, data: DiscordGatewayPayload) { export async function handleGuildBanAdd(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<GuildBanAddRemove>; const payload = data.d as SnakeCasedPropertiesDeep<GuildBanAddRemove>;
bot.events.guildBanAdd( bot.events.guildBanAdd(bot, bot.transformers.user(bot, payload.user), bot.transformers.snowflake(payload.guild_id));
bot,
bot.transformers.user(bot, payload.user),
bot.transformers.snowflake(payload.guild_id)
);
} }
+1 -5
View File
@@ -3,11 +3,7 @@ import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.
import type { Guild } from "../../types/guilds/guild.ts"; import type { Guild } from "../../types/guilds/guild.ts";
import { SnakeCasedPropertiesDeep } from "../../types/util.ts"; import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
export function handleGuildLoaded( export function handleGuildLoaded(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
bot: Bot,
data: DiscordGatewayPayload,
shardId: number
) {
const payload = data.d as SnakeCasedPropertiesDeep<Guild>; const payload = data.d as SnakeCasedPropertiesDeep<Guild>;
const guild = bot.transformers.guild(bot, { guild: payload, shardId }); const guild = bot.transformers.guild(bot, { guild: payload, shardId });
+5 -7
View File
@@ -6,11 +6,9 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
export async function handleMessageDelete(bot: Bot, data: DiscordGatewayPayload) { export async function handleMessageDelete(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<MessageDelete>; const payload = data.d as SnakeCasedPropertiesDeep<MessageDelete>;
bot.events.messageDelete(bot, bot.events.messageDelete(bot, {
{ id: bot.transformers.snowflake(payload.id),
id: bot.transformers.snowflake(payload.id), channelId: bot.transformers.snowflake(payload.channel_id),
channelId: bot.transformers.snowflake(payload.channel_id), guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined, });
},
);
} }
+4 -1
View File
@@ -5,5 +5,8 @@ import { SnakeCasedPropertiesDeep } from "../../types/util.ts";
export async function handleGuildRoleDelete(bot: Bot, data: DiscordGatewayPayload) { export async function handleGuildRoleDelete(bot: Bot, data: DiscordGatewayPayload) {
const payload = data.d as SnakeCasedPropertiesDeep<GuildRoleDelete>; const payload = data.d as SnakeCasedPropertiesDeep<GuildRoleDelete>;
bot.events.roleDelete(bot, { roleId: bot.transformers.snowflake(payload.role_id), guildId: bot.transformers.snowflake(payload.guild_id) }); bot.events.roleDelete(bot, {
roleId: bot.transformers.snowflake(payload.role_id),
guildId: bot.transformers.snowflake(payload.guild_id),
});
} }
@@ -1,11 +1,7 @@
import type { Bot } from "../../bot.ts"; import type { Bot } from "../../bot.ts";
/** Delete the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */ /** Delete the channel permission overwrites for a user or role in this channel. Requires `MANAGE_ROLES` permission. */
export async function deleteChannelOverwrite( export async function deleteChannelOverwrite(bot: Bot, channelId: bigint, overwriteId: bigint): Promise<undefined> {
bot: Bot,
channelId: bigint,
overwriteId: bigint
): Promise<undefined> {
return await bot.rest.runMethod<undefined>( return await bot.rest.runMethod<undefined>(
bot.rest, bot.rest,
"delete", "delete",
@@ -28,12 +28,14 @@ export async function sendInteractionResponse(
options.data = { ...options.data, allowedMentions: { parse: [] } }; options.data = { ...options.data, allowedMentions: { parse: [] } };
} }
const allowedMentions: AllowedMentions = options.data?.allowedMentions ? { const allowedMentions: AllowedMentions = options.data?.allowedMentions
parse: options.data?.allowedMentions.parse, ? {
repliedUser: options.data?.allowedMentions.repliedUser, parse: options.data?.allowedMentions.parse,
users: options.data?.allowedMentions.users?.map(id => id.toString()), repliedUser: options.data?.allowedMentions.repliedUser,
roles: options.data?.allowedMentions.roles?.map(id => id.toString()), users: options.data?.allowedMentions.users?.map((id) => id.toString()),
} : { parse: [] }; roles: options.data?.allowedMentions.roles?.map((id) => id.toString()),
}
: { parse: [] };
// If its already been executed, we need to send a followup response // If its already been executed, we need to send a followup response
if (bot.cache.executedSlashCommands.has(token)) { if (bot.cache.executedSlashCommands.has(token)) {
+1 -5
View File
@@ -1,11 +1,7 @@
import type { Bot } from "../../bot.ts"; import type { Bot } from "../../bot.ts";
/** Edit the nickname of the bot in this guild */ /** Edit the nickname of the bot in this guild */
export async function editBotNickname( export async function editBotNickname(bot: Bot, guildId: bigint, options: { nick: string | null; reason?: string }) {
bot: Bot,
guildId: bigint,
options: { nick: string | null; reason?: string }
) {
const response = await bot.rest.runMethod<{ nick: string }>( const response = await bot.rest.runMethod<{ nick: string }>(
bot.rest, bot.rest,
"patch", "patch",
+7 -12
View File
@@ -4,18 +4,13 @@ import type { Bot } from "../../bot.ts";
/** Edit a guild role. Requires the MANAGE_ROLES permission. */ /** Edit a guild role. Requires the MANAGE_ROLES permission. */
export async function editRole(bot: Bot, guildId: bigint, id: bigint, options: CreateGuildRole) { export async function editRole(bot: Bot, guildId: bigint, id: bigint, options: CreateGuildRole) {
const result = await bot.rest.runMethod<Role>( const result = await bot.rest.runMethod<Role>(bot.rest, "patch", bot.constants.endpoints.GUILD_ROLE(guildId, id), {
bot.rest, name: options.name,
"patch", color: options.color,
bot.constants.endpoints.GUILD_ROLE(guildId, id), hoist: options.hoist,
{ mentionable: options.mentionable,
name: options.name, permissions: options.permissions ? bot.utils.calculateBits(options.permissions) : undefined,
color: options.color, });
hoist: options.hoist,
mentionable: options.mentionable,
permissions: options.permissions ? bot.utils.calculateBits(options.permissions) : undefined,
}
);
return bot.transformers.role(bot, { role: result, guildId }); return bot.transformers.role(bot, { role: result, guildId });
} }
+5 -1
View File
@@ -7,7 +7,11 @@ import type { Bot } from "../../bot.ts";
* Requires the `MANAGE_GUILD` permission. * Requires the `MANAGE_GUILD` permission.
*/ */
export async function getGuildTemplates(bot: Bot, guildId: bigint) { export async function getGuildTemplates(bot: Bot, guildId: bigint) {
const templates = await bot.rest.runMethod<Template[]>(bot.rest, "get", bot.constants.endpoints.GUILD_TEMPLATES(guildId)); const templates = await bot.rest.runMethod<Template[]>(
bot.rest,
"get",
bot.constants.endpoints.GUILD_TEMPLATES(guildId)
);
return new Collection(templates.map((template) => [template.code, template])); return new Collection(templates.map((template) => [template.code, template]));
} }
+4 -9
View File
@@ -16,13 +16,8 @@ export async function createWebhook(bot: Bot, channelId: bigint, options: Create
throw new Error(bot.constants.Errors.INVALID_WEBHOOK_NAME); throw new Error(bot.constants.Errors.INVALID_WEBHOOK_NAME);
} }
return await bot.rest.runMethod<Webhook>( return await bot.rest.runMethod<Webhook>(bot.rest, "post", bot.constants.endpoints.CHANNEL_WEBHOOKS(channelId), {
bot.rest, ...options,
"post", avatar: options.avatar ? await bot.utils.urlToBase64(options.avatar) : undefined,
bot.constants.endpoints.CHANNEL_WEBHOOKS(channelId), });
{
...options,
avatar: options.avatar ? await bot.utils.urlToBase64(options.avatar) : undefined,
}
);
} }
+1 -5
View File
@@ -5,11 +5,7 @@ import type { SnakeCasedPropertiesDeep } from "../../types/util.ts";
/** Returns a list of guild webhooks objects. Requires the MANAGE_WEBHOOKs permission. */ /** Returns a list of guild webhooks objects. Requires the MANAGE_WEBHOOKs permission. */
export async function getWebhooks(bot: Bot, guildId: bigint) { export async function getWebhooks(bot: Bot, guildId: bigint) {
const result = await bot.rest.runMethod<Webhook[]>( const result = await bot.rest.runMethod<Webhook[]>(bot.rest, "get", bot.constants.endpoints.GUILD_WEBHOOKS(guildId));
bot.rest,
"get",
bot.constants.endpoints.GUILD_WEBHOOKS(guildId)
);
return new Collection(result.map((webhook) => [webhook.id, webhook])); return new Collection(result.map((webhook) => [webhook.id, webhook]));
} }
+2 -1
View File
@@ -32,7 +32,8 @@ export function transformRole(
}; };
} }
export interface DiscordenoRole extends Omit<Role, "tags" | "id" | "permissions" | "hoist" | "mentionable" | "managed" | "icon"> { export interface DiscordenoRole
extends Omit<Role, "tags" | "id" | "permissions" | "hoist" | "mentionable" | "managed" | "icon"> {
/** The role id */ /** The role id */
id: bigint; id: bigint;
/** The bot id that is associated with this role. */ /** The bot id that is associated with this role. */
+1 -1
View File
@@ -54,7 +54,7 @@ export function identify(gateway: GatewayManager, shardId: number, maxShards: nu
}, },
intents: gateway.intents, intents: gateway.intents,
shard: [shardId, maxShards], shard: [shardId, maxShards],
presence: gateway.presence presence: gateway.presence,
}, },
}, },
true true
+1 -1
View File
@@ -20,6 +20,6 @@ export async function editGuildTests(bot: Bot, guildId: bigint, t: Deno.TestCont
// await delayUntil(10000, async () => bot.cache.guilds.get(guild.id)?.name === "Discordeno Test 1.0"); // await delayUntil(10000, async () => bot.cache.guilds.get(guild.id)?.name === "Discordeno Test 1.0");
// if (!bot.cache.guilds.has(guild.id)) { // if (!bot.cache.guilds.has(guild.id)) {
// throw new Error(`The guild seemed to be edited but the cache didn't got updated.`); // throw new Error(`The guild seemed to be edited but the cache didn't got updated.`);
// } // }
} }
+1 -1
View File
@@ -21,6 +21,6 @@ export async function editMessageTest(bot: Bot, channelId: bigint, t: Deno.TestC
// await delayUntil(10000, async () => bot.cache.messages.get(message.id)?.content === "Goodbye World!"); // await delayUntil(10000, async () => bot.cache.messages.get(message.id)?.content === "Goodbye World!");
// Make sure it was edited // Make sure it was edited
// if (bot.cache.messages.get(message.id)?.content !== "Goodbye World!") { // if (bot.cache.messages.get(message.id)?.content !== "Goodbye World!") {
// throw new Error("The message should have been edited but it was not."); // throw new Error("The message should have been edited but it was not.");
// } // }
} }