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
+2 -2
View File
@@ -8,13 +8,13 @@ export async function handleGuildBanAdd(data: DiscordGatewayPayload) {
const payload = data.d as GuildBanAddRemove;
const guild = await cacheHandlers.get(
"guilds",
snowflakeToBigint(payload.guildId),
snowflakeToBigint(payload.guildId)
);
if (!guild) return;
const member = await cacheHandlers.get(
"members",
snowflakeToBigint(payload.user.id),
snowflakeToBigint(payload.user.id)
);
eventHandlers.guildBanAdd?.(guild, payload.user, member);
}
+2 -2
View File
@@ -8,13 +8,13 @@ export async function handleGuildBanRemove(data: DiscordGatewayPayload) {
const payload = data.d as GuildBanAddRemove;
const guild = await cacheHandlers.get(
"guilds",
snowflakeToBigint(payload.guildId),
snowflakeToBigint(payload.guildId)
);
if (!guild) return;
const member = await cacheHandlers.get(
"members",
snowflakeToBigint(payload.user.id),
snowflakeToBigint(payload.user.id)
);
eventHandlers.guildBanRemove?.(guild, payload.user, member);
}
+2 -5
View File
@@ -8,16 +8,13 @@ import { ws } from "../../ws/ws.ts";
export async function handleGuildCreate(
data: DiscordGatewayPayload,
shardId: number,
shardId: number
) {
const payload = data.d as Guild;
// When shards resume they emit GUILD_CREATE again.
if (await cacheHandlers.has("guilds", snowflakeToBigint(payload.id))) return;
const guild = await structures.createDiscordenoGuild(
payload,
shardId,
);
const guild = await structures.createDiscordenoGuild(payload, shardId);
await cacheHandlers.set("guilds", guild.id, guild);
const shard = ws.shards.get(shardId);
+5 -5
View File
@@ -7,13 +7,13 @@ import { ws } from "../../ws/ws.ts";
export async function handleGuildDelete(
data: DiscordGatewayPayload,
shardId: number,
shardId: number
) {
const payload = data.d as UnavailableGuild;
const guild = await cacheHandlers.get(
"guilds",
snowflakeToBigint(payload.id),
snowflakeToBigint(payload.id)
);
if (!guild) return;
@@ -32,7 +32,7 @@ export async function handleGuildDelete(
cacheHandlers.forEach("messages", (message) => {
eventHandlers.debug?.(
"loop",
`1. Running forEach messages loop in CHANNEL_DELTE file.`,
`1. Running forEach messages loop in CHANNEL_DELTE file.`
);
if (message.guildId === guild.id) {
cacheHandlers.delete("messages", message.id);
@@ -42,7 +42,7 @@ export async function handleGuildDelete(
cacheHandlers.forEach("channels", (channel) => {
eventHandlers.debug?.(
"loop",
`2. Running forEach channels loop in CHANNEL_DELTE file.`,
`2. Running forEach channels loop in CHANNEL_DELTE file.`
);
if (channel.guildId === guild.id) {
cacheHandlers.delete("channels", channel.id);
@@ -52,7 +52,7 @@ export async function handleGuildDelete(
cacheHandlers.forEach("members", (member) => {
eventHandlers.debug?.(
"loop",
`3. Running forEach members loop in CHANNEL_DELTE file.`,
`3. Running forEach members loop in CHANNEL_DELTE file.`
);
if (!member.guilds.has(guild.id)) return;
@@ -5,13 +5,13 @@ import type { GuildIntegrationsUpdate } from "../../types/integrations/guild_int
import { snowflakeToBigint } from "../../util/bigint.ts";
export async function handleGuildIntegrationsUpdate(
data: DiscordGatewayPayload,
data: DiscordGatewayPayload
) {
const payload = data.d as GuildIntegrationsUpdate;
const guild = await cacheHandlers.get(
"guilds",
snowflakeToBigint(payload.guildId),
snowflakeToBigint(payload.guildId)
);
if (!guild) return;
+4 -3
View File
@@ -8,12 +8,12 @@ import { snowflakeToBigint } from "../../util/bigint.ts";
export async function handleGuildUpdate(
data: DiscordGatewayPayload,
shardId: number,
shardId: number
) {
const payload = data.d as Guild;
const oldGuild = await cacheHandlers.get(
"guilds",
snowflakeToBigint(payload.id),
snowflakeToBigint(payload.id)
);
if (!oldGuild) return;
@@ -40,7 +40,8 @@ export async function handleGuildUpdate(
if (!cachedValue && !value) return;
if (Array.isArray(cachedValue) && Array.isArray(value)) {
const different = cachedValue.length !== value.length ||
const different =
cachedValue.length !== value.length ||
cachedValue.find((val) => !value.includes(val)) ||
value.find((val) => !cachedValue.includes(val));
if (!different) return;