mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 03:18:17 +00:00
Prettified Code!
This commit is contained in:
@@ -10,27 +10,30 @@ export async function handleChannelDelete(data: DiscordGatewayPayload) {
|
||||
|
||||
const cachedChannel = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.id),
|
||||
snowflakeToBigint(payload.id)
|
||||
);
|
||||
if (!cachedChannel) return;
|
||||
|
||||
if (
|
||||
cachedChannel.type === DiscordChannelTypes.GuildVoice && payload.guildId
|
||||
cachedChannel.type === DiscordChannelTypes.GuildVoice &&
|
||||
payload.guildId
|
||||
) {
|
||||
const guild = await cacheHandlers.get("guilds", cachedChannel.guildId);
|
||||
|
||||
if (guild) {
|
||||
return Promise.all(guild.voiceStates.map(async (vs, key) => {
|
||||
if (vs.channelId !== cachedChannel.id) return;
|
||||
return Promise.all(
|
||||
guild.voiceStates.map(async (vs, key) => {
|
||||
if (vs.channelId !== cachedChannel.id) return;
|
||||
|
||||
// Since this channel was deleted all voice states for this channel should be deleted
|
||||
guild.voiceStates.delete(key);
|
||||
// Since this channel was deleted all voice states for this channel should be deleted
|
||||
guild.voiceStates.delete(key);
|
||||
|
||||
const member = await cacheHandlers.get("members", vs.userId);
|
||||
if (!member) return;
|
||||
const member = await cacheHandlers.get("members", vs.userId);
|
||||
if (!member) return;
|
||||
|
||||
eventHandlers.voiceChannelLeave?.(member, vs.channelId);
|
||||
}));
|
||||
eventHandlers.voiceChannelLeave?.(member, vs.channelId);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +49,7 @@ export async function handleChannelDelete(data: DiscordGatewayPayload) {
|
||||
cacheHandlers.forEach("messages", (message) => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach messages loop in CHANNEL_DELTE file.`,
|
||||
`Running forEach messages loop in CHANNEL_DELTE file.`
|
||||
);
|
||||
if (message.channelId === snowflakeToBigint(payload.id)) {
|
||||
cacheHandlers.delete("messages", message.id);
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function handleChannelPinsUpdate(data: DiscordGatewayPayload) {
|
||||
|
||||
const channel = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.channelId),
|
||||
snowflakeToBigint(payload.channelId)
|
||||
);
|
||||
if (!channel) return;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function handleChannelUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as Channel;
|
||||
const cachedChannel = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.id),
|
||||
snowflakeToBigint(payload.id)
|
||||
);
|
||||
if (!cachedChannel) return;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function handleThreadDelete(data: DiscordGatewayPayload) {
|
||||
|
||||
const cachedChannel = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.id),
|
||||
snowflakeToBigint(payload.id)
|
||||
);
|
||||
if (!cachedChannel) return;
|
||||
|
||||
@@ -17,7 +17,7 @@ export async function handleThreadDelete(data: DiscordGatewayPayload) {
|
||||
cacheHandlers.forEach("messages", (message) => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach messages loop in CHANNEL_DELTE file.`,
|
||||
`Running forEach messages loop in CHANNEL_DELTE file.`
|
||||
);
|
||||
if (message.channelId === snowflakeToBigint(payload.id)) {
|
||||
cacheHandlers.delete("messages", message.id);
|
||||
|
||||
@@ -14,26 +14,26 @@ export async function handleThreadListSync(data: DiscordGatewayPayload) {
|
||||
payload.threads.map(async (thread) => {
|
||||
const discordenoChannel = await structures.createDiscordenoChannel(
|
||||
thread,
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
|
||||
await cacheHandlers.set(
|
||||
"channels",
|
||||
discordenoChannel.id,
|
||||
discordenoChannel,
|
||||
discordenoChannel
|
||||
);
|
||||
|
||||
return discordenoChannel;
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
const threads = new Collection<bigint, DiscordenoChannel>(
|
||||
discordenoChannels.map((t) => [t.id, t]),
|
||||
discordenoChannels.map((t) => [t.id, t])
|
||||
);
|
||||
|
||||
eventHandlers.threadListSync?.(
|
||||
threads,
|
||||
payload.members,
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export async function handleThreadMembersUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as ThreadMembersUpdate;
|
||||
const thread = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.id),
|
||||
snowflakeToBigint(payload.id)
|
||||
);
|
||||
if (!thread) return;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export async function handleThreadMemberUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as ThreadMember;
|
||||
const thread = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.id),
|
||||
snowflakeToBigint(payload.id)
|
||||
);
|
||||
if (!thread) return;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function handleThreadUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as Channel;
|
||||
const oldChannel = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.id),
|
||||
snowflakeToBigint(payload.id)
|
||||
);
|
||||
if (!oldChannel) return;
|
||||
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import type {
|
||||
ApplicationCommandCreateUpdateDelete,
|
||||
} from "../../types/interactions/commands/application_command_create_update_delete.ts";
|
||||
import type { ApplicationCommandCreateUpdateDelete } from "../../types/interactions/commands/application_command_create_update_delete.ts";
|
||||
|
||||
export function handleApplicationCommandCreate(
|
||||
data: DiscordGatewayPayload,
|
||||
) {
|
||||
export function handleApplicationCommandCreate(data: DiscordGatewayPayload) {
|
||||
eventHandlers.applicationCommandCreate?.(
|
||||
data.d as ApplicationCommandCreateUpdateDelete,
|
||||
data.d as ApplicationCommandCreateUpdateDelete
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import type {
|
||||
ApplicationCommandCreateUpdateDelete,
|
||||
} from "../../types/interactions/commands/application_command_create_update_delete.ts";
|
||||
import type { ApplicationCommandCreateUpdateDelete } from "../../types/interactions/commands/application_command_create_update_delete.ts";
|
||||
|
||||
export function handleApplicationCommandDelete(data: DiscordGatewayPayload) {
|
||||
eventHandlers.applicationCommandDelete?.(
|
||||
data.d as ApplicationCommandCreateUpdateDelete,
|
||||
data.d as ApplicationCommandCreateUpdateDelete
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import type {
|
||||
ApplicationCommandCreateUpdateDelete,
|
||||
} from "../../types/interactions/commands/application_command_create_update_delete.ts";
|
||||
import type { ApplicationCommandCreateUpdateDelete } from "../../types/interactions/commands/application_command_create_update_delete.ts";
|
||||
|
||||
export function handleApplicationCommandUpdate(data: DiscordGatewayPayload) {
|
||||
eventHandlers.applicationCommandUpdate?.(
|
||||
data.d as ApplicationCommandCreateUpdateDelete,
|
||||
data.d as ApplicationCommandCreateUpdateDelete
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,20 +9,16 @@ export async function handleGuildEmojisUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as GuildEmojisUpdate;
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (!guild) return;
|
||||
|
||||
const cachedEmojis = guild.emojis;
|
||||
guild.emojis = new Collection(
|
||||
payload.emojis.map((emoji) => [snowflakeToBigint(emoji.id!), emoji]),
|
||||
payload.emojis.map((emoji) => [snowflakeToBigint(emoji.id!), emoji])
|
||||
);
|
||||
|
||||
await cacheHandlers.set("guilds", guild.id, guild);
|
||||
|
||||
eventHandlers.guildEmojisUpdate?.(
|
||||
guild,
|
||||
guild.emojis,
|
||||
cachedEmojis,
|
||||
);
|
||||
eventHandlers.guildEmojisUpdate?.(guild, guild.emojis, cachedEmojis);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import type {
|
||||
IntegrationCreateUpdate,
|
||||
} from "../../types/integrations/integration_create_update.ts";
|
||||
import type { IntegrationCreateUpdate } from "../../types/integrations/integration_create_update.ts";
|
||||
|
||||
export function handleIntegrationCreate(
|
||||
data: DiscordGatewayPayload,
|
||||
) {
|
||||
eventHandlers.integrationCreate?.(
|
||||
data.d as IntegrationCreateUpdate,
|
||||
);
|
||||
export function handleIntegrationCreate(data: DiscordGatewayPayload) {
|
||||
eventHandlers.integrationCreate?.(data.d as IntegrationCreateUpdate);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,5 @@ import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.
|
||||
import type { IntegrationDelete } from "../../types/integrations/integration_delete.ts";
|
||||
|
||||
export function handleIntegrationDelete(data: DiscordGatewayPayload) {
|
||||
eventHandlers.integrationDelete?.(
|
||||
data.d as IntegrationDelete,
|
||||
);
|
||||
eventHandlers.integrationDelete?.(data.d as IntegrationDelete);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import type {
|
||||
IntegrationCreateUpdate,
|
||||
} from "../../types/integrations/integration_create_update.ts";
|
||||
import type { IntegrationCreateUpdate } from "../../types/integrations/integration_create_update.ts";
|
||||
|
||||
export function handleIntegrationUpdate(data: DiscordGatewayPayload) {
|
||||
eventHandlers.integrationUpdate?.(
|
||||
data.d as IntegrationCreateUpdate,
|
||||
);
|
||||
eventHandlers.integrationUpdate?.(data.d as IntegrationCreateUpdate);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ export async function handleInteractionCreate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as Interaction;
|
||||
const discordenoMember = payload.guildId
|
||||
? await structures.createDiscordenoMember(
|
||||
payload.member as GuildMemberWithUser,
|
||||
snowflakeToBigint(payload.guildId),
|
||||
)
|
||||
payload.member as GuildMemberWithUser,
|
||||
snowflakeToBigint(payload.guildId)
|
||||
)
|
||||
: undefined;
|
||||
if (discordenoMember) {
|
||||
await cacheHandlers.set("members", discordenoMember.id, discordenoMember);
|
||||
|
||||
@@ -3,7 +3,5 @@ import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.
|
||||
import type { InviteCreate } from "../../types/invites/invite_create.ts";
|
||||
|
||||
export function handleInviteCreate(data: DiscordGatewayPayload) {
|
||||
eventHandlers.inviteCreate?.(
|
||||
data.d as InviteCreate,
|
||||
);
|
||||
eventHandlers.inviteCreate?.(data.d as InviteCreate);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,5 @@ import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.
|
||||
import type { InviteDelete } from "../../types/invites/invite_delete.ts";
|
||||
|
||||
export function handleInviteDelete(data: DiscordGatewayPayload) {
|
||||
eventHandlers.inviteDelete?.(
|
||||
data.d as InviteDelete,
|
||||
);
|
||||
eventHandlers.inviteDelete?.(data.d as InviteDelete);
|
||||
}
|
||||
|
||||
@@ -14,18 +14,16 @@ export async function handleGuildMembersChunk(data: DiscordGatewayPayload) {
|
||||
payload.members.map(async (member) => {
|
||||
const discordenoMember = await structures.createDiscordenoMember(
|
||||
member,
|
||||
guildId,
|
||||
guildId
|
||||
);
|
||||
await cacheHandlers.set("members", discordenoMember.id, discordenoMember);
|
||||
|
||||
return discordenoMember;
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
// Check if its necessary to resolve the fetchmembers promise for this chunk or if more chunks will be coming
|
||||
if (
|
||||
payload.nonce
|
||||
) {
|
||||
if (payload.nonce) {
|
||||
const resolve = cache.fetchAllMembersProcessingRequests.get(payload.nonce);
|
||||
if (!resolve) return;
|
||||
|
||||
@@ -37,10 +35,7 @@ export async function handleGuildMembersChunk(data: DiscordGatewayPayload) {
|
||||
}
|
||||
|
||||
return resolve(
|
||||
await cacheHandlers.filter(
|
||||
"members",
|
||||
(m) => m.guilds.has(guildId),
|
||||
),
|
||||
await cacheHandlers.filter("members", (m) => m.guilds.has(guildId))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ export async function handleGuildMemberAdd(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as GuildMemberAdd;
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (!guild) return;
|
||||
|
||||
guild.memberCount++;
|
||||
const discordenoMember = await structures.createDiscordenoMember(
|
||||
payload,
|
||||
guild.id,
|
||||
guild.id
|
||||
);
|
||||
await cacheHandlers.set("members", discordenoMember.id, discordenoMember);
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ export async function handleGuildMemberRemove(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as GuildMemberRemove;
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (!guild) return;
|
||||
|
||||
guild.memberCount--;
|
||||
const member = await cacheHandlers.get(
|
||||
"members",
|
||||
snowflakeToBigint(payload.user.id),
|
||||
snowflakeToBigint(payload.user.id)
|
||||
);
|
||||
eventHandlers.guildMemberRemove?.(guild, payload.user, member);
|
||||
|
||||
|
||||
@@ -9,28 +9,27 @@ export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as GuildMemberUpdate;
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (!guild) return;
|
||||
|
||||
const cachedMember = await cacheHandlers.get(
|
||||
"members",
|
||||
snowflakeToBigint(payload.user.id),
|
||||
snowflakeToBigint(payload.user.id)
|
||||
);
|
||||
const guildMember = cachedMember?.guilds.get(guild.id);
|
||||
|
||||
const newMemberData = {
|
||||
...payload,
|
||||
premiumSince: payload.premiumSince || undefined,
|
||||
joinedAt: new Date(guildMember?.joinedAt || Date.now())
|
||||
.toISOString(),
|
||||
joinedAt: new Date(guildMember?.joinedAt || Date.now()).toISOString(),
|
||||
deaf: guildMember?.deaf || false,
|
||||
mute: guildMember?.mute || false,
|
||||
roles: payload.roles,
|
||||
};
|
||||
const discordenoMember = await structures.createDiscordenoMember(
|
||||
newMemberData,
|
||||
guild.id,
|
||||
guild.id
|
||||
);
|
||||
await cacheHandlers.set("members", discordenoMember.id, discordenoMember);
|
||||
|
||||
@@ -40,7 +39,7 @@ export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) {
|
||||
guild,
|
||||
discordenoMember,
|
||||
payload.nick!,
|
||||
guildMember.nick ?? undefined,
|
||||
guildMember.nick ?? undefined
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,7 +52,7 @@ export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) {
|
||||
roleIds.forEach((id) => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`1. Running forEach loop in GUILD_MEMBER_UPDATE file.`,
|
||||
`1. Running forEach loop in GUILD_MEMBER_UPDATE file.`
|
||||
);
|
||||
if (!payload.roles.includes(bigintToSnowflake(id))) {
|
||||
eventHandlers.roleLost?.(guild, discordenoMember, id);
|
||||
@@ -63,13 +62,13 @@ export async function handleGuildMemberUpdate(data: DiscordGatewayPayload) {
|
||||
payload.roles.forEach((id) => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`2. Running forEach loop in GUILD_MEMBER_UPDATE file.`,
|
||||
`2. Running forEach loop in GUILD_MEMBER_UPDATE file.`
|
||||
);
|
||||
if (!roleIds.includes(snowflakeToBigint(id))) {
|
||||
eventHandlers.roleGained?.(
|
||||
guild,
|
||||
discordenoMember,
|
||||
snowflakeToBigint(id),
|
||||
snowflakeToBigint(id)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ export async function handleMessageCreate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as Message;
|
||||
const channel = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.channelId),
|
||||
snowflakeToBigint(payload.channelId)
|
||||
);
|
||||
if (channel) channel.lastMessageId = snowflakeToBigint(payload.id);
|
||||
|
||||
@@ -22,32 +22,32 @@ export async function handleMessageCreate(data: DiscordGatewayPayload) {
|
||||
// If in a guild cache the author as a member
|
||||
const discordenoMember = await structures.createDiscordenoMember(
|
||||
{ ...payload.member, user: payload.author } as GuildMemberWithUser,
|
||||
guild.id,
|
||||
guild.id
|
||||
);
|
||||
await cacheHandlers.set("members", discordenoMember.id, discordenoMember);
|
||||
}
|
||||
|
||||
if (payload.mentions && guild) {
|
||||
await Promise.all(payload.mentions.map(async (mention) => {
|
||||
// Cache the member if its a valid member
|
||||
if (mention.member) {
|
||||
const discordenoMember = await structures.createDiscordenoMember(
|
||||
{ ...mention.member, user: mention } as GuildMemberWithUser,
|
||||
guild.id,
|
||||
);
|
||||
await Promise.all(
|
||||
payload.mentions.map(async (mention) => {
|
||||
// Cache the member if its a valid member
|
||||
if (mention.member) {
|
||||
const discordenoMember = await structures.createDiscordenoMember(
|
||||
{ ...mention.member, user: mention } as GuildMemberWithUser,
|
||||
guild.id
|
||||
);
|
||||
|
||||
return cacheHandlers.set(
|
||||
"members",
|
||||
snowflakeToBigint(mention.id),
|
||||
discordenoMember,
|
||||
);
|
||||
}
|
||||
}));
|
||||
return cacheHandlers.set(
|
||||
"members",
|
||||
snowflakeToBigint(mention.id),
|
||||
discordenoMember
|
||||
);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
const message = await structures.createDiscordenoMessage(
|
||||
data.d as Message,
|
||||
);
|
||||
const message = await structures.createDiscordenoMessage(data.d as Message);
|
||||
// Cache the message
|
||||
await cacheHandlers.set("messages", snowflakeToBigint(payload.id), message);
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ export async function handleMessageDelete(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as MessageDelete;
|
||||
const channel = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.channelId),
|
||||
snowflakeToBigint(payload.channelId)
|
||||
);
|
||||
if (!channel) return;
|
||||
|
||||
eventHandlers.messageDelete?.(
|
||||
{ id: payload.id, channel },
|
||||
await cacheHandlers.get("messages", snowflakeToBigint(payload.id)),
|
||||
await cacheHandlers.get("messages", snowflakeToBigint(payload.id))
|
||||
);
|
||||
|
||||
await cacheHandlers.delete("messages", snowflakeToBigint(payload.id));
|
||||
|
||||
@@ -8,15 +8,17 @@ export async function handleMessageDeleteBulk(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as MessageDeleteBulk;
|
||||
const channel = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.channelId),
|
||||
snowflakeToBigint(payload.channelId)
|
||||
);
|
||||
if (!channel) return;
|
||||
|
||||
return Promise.all(payload.ids.map(async (id) => {
|
||||
eventHandlers.messageDelete?.(
|
||||
{ id, channel },
|
||||
await cacheHandlers.get("messages", snowflakeToBigint(id)),
|
||||
);
|
||||
await cacheHandlers.delete("messages", snowflakeToBigint(id));
|
||||
}));
|
||||
return Promise.all(
|
||||
payload.ids.map(async (id) => {
|
||||
eventHandlers.messageDelete?.(
|
||||
{ id, channel },
|
||||
await cacheHandlers.get("messages", snowflakeToBigint(id))
|
||||
);
|
||||
await cacheHandlers.delete("messages", snowflakeToBigint(id));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,23 +2,21 @@ import { botId, eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import { structures } from "../../structures/mod.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import type {
|
||||
MessageReactionAdd,
|
||||
} from "../../types/messages/message_reaction_add.ts";
|
||||
import type { MessageReactionAdd } from "../../types/messages/message_reaction_add.ts";
|
||||
import { snowflakeToBigint } from "../../util/bigint.ts";
|
||||
|
||||
export async function handleMessageReactionAdd(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as MessageReactionAdd;
|
||||
const message = await cacheHandlers.get(
|
||||
"messages",
|
||||
snowflakeToBigint(payload.messageId),
|
||||
snowflakeToBigint(payload.messageId)
|
||||
);
|
||||
|
||||
if (message) {
|
||||
const reactionExisted = message.reactions?.find(
|
||||
(reaction) =>
|
||||
reaction.emoji.id === payload.emoji.id &&
|
||||
reaction.emoji.name === payload.emoji.name,
|
||||
reaction.emoji.name === payload.emoji.name
|
||||
);
|
||||
|
||||
if (reactionExisted) reactionExisted.count++;
|
||||
@@ -36,26 +34,23 @@ export async function handleMessageReactionAdd(data: DiscordGatewayPayload) {
|
||||
await cacheHandlers.set(
|
||||
"messages",
|
||||
snowflakeToBigint(payload.messageId),
|
||||
message,
|
||||
message
|
||||
);
|
||||
}
|
||||
|
||||
if (payload.member && payload.guildId) {
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (guild) {
|
||||
const discordenoMember = await structures.createDiscordenoMember(
|
||||
payload.member,
|
||||
guild.id,
|
||||
guild.id
|
||||
);
|
||||
await cacheHandlers.set("members", discordenoMember.id, discordenoMember);
|
||||
}
|
||||
}
|
||||
|
||||
eventHandlers.reactionAdd?.(
|
||||
payload,
|
||||
message,
|
||||
);
|
||||
eventHandlers.reactionAdd?.(payload, message);
|
||||
}
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import type {
|
||||
MessageReactionRemove,
|
||||
} from "../../types/messages/message_reaction_remove.ts";
|
||||
import type { MessageReactionRemove } from "../../types/messages/message_reaction_remove.ts";
|
||||
import { snowflakeToBigint } from "../../util/bigint.ts";
|
||||
|
||||
export async function handleMessageReactionRemove(
|
||||
data: DiscordGatewayPayload,
|
||||
) {
|
||||
export async function handleMessageReactionRemove(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as MessageReactionRemove;
|
||||
const message = await cacheHandlers.get(
|
||||
"messages",
|
||||
snowflakeToBigint(payload.messageId),
|
||||
snowflakeToBigint(payload.messageId)
|
||||
);
|
||||
|
||||
if (message) {
|
||||
const reaction = message.reactions?.find((reaction) =>
|
||||
// MUST USE == because discord sends null and we use undefined
|
||||
reaction.emoji.id == payload.emoji.id &&
|
||||
reaction.emoji.name === payload.emoji.name
|
||||
const reaction = message.reactions?.find(
|
||||
(reaction) =>
|
||||
// MUST USE == because discord sends null and we use undefined
|
||||
reaction.emoji.id == payload.emoji.id &&
|
||||
reaction.emoji.name === payload.emoji.name
|
||||
);
|
||||
|
||||
if (reaction) {
|
||||
@@ -33,8 +30,5 @@ export async function handleMessageReactionRemove(
|
||||
}
|
||||
}
|
||||
|
||||
eventHandlers.reactionRemove?.(
|
||||
payload,
|
||||
message,
|
||||
);
|
||||
eventHandlers.reactionRemove?.(payload, message);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import { eventHandlers } from "../../bot.ts";
|
||||
import { cacheHandlers } from "../../cache.ts";
|
||||
import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.ts";
|
||||
import type {
|
||||
MessageReactionRemoveAll,
|
||||
} from "../../types/messages/message_reaction_remove_all.ts";
|
||||
import type { MessageReactionRemoveAll } from "../../types/messages/message_reaction_remove_all.ts";
|
||||
import { snowflakeToBigint } from "../../util/bigint.ts";
|
||||
|
||||
export async function handleMessageReactionRemoveAll(
|
||||
data: DiscordGatewayPayload,
|
||||
data: DiscordGatewayPayload
|
||||
) {
|
||||
const payload = data.d as MessageReactionRemoveAll;
|
||||
const message = await cacheHandlers.get(
|
||||
"messages",
|
||||
snowflakeToBigint(payload.messageId),
|
||||
snowflakeToBigint(payload.messageId)
|
||||
);
|
||||
|
||||
if (message?.reactions) {
|
||||
@@ -21,12 +19,9 @@ export async function handleMessageReactionRemoveAll(
|
||||
await cacheHandlers.set(
|
||||
"messages",
|
||||
snowflakeToBigint(payload.messageId),
|
||||
message,
|
||||
message
|
||||
);
|
||||
}
|
||||
|
||||
eventHandlers.reactionRemoveAll?.(
|
||||
payload,
|
||||
message,
|
||||
);
|
||||
eventHandlers.reactionRemoveAll?.(payload, message);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import type { MessageReactionRemoveEmoji } from "../../types/messages/message_re
|
||||
import { snowflakeToBigint } from "../../util/bigint.ts";
|
||||
|
||||
export async function handleMessageReactionRemoveEmoji(
|
||||
data: DiscordGatewayPayload,
|
||||
data: DiscordGatewayPayload
|
||||
) {
|
||||
const payload = data.d as MessageReactionRemoveEmoji;
|
||||
const message = await cacheHandlers.get(
|
||||
"messages",
|
||||
snowflakeToBigint(payload.messageId),
|
||||
snowflakeToBigint(payload.messageId)
|
||||
);
|
||||
|
||||
if (message?.reactions) {
|
||||
@@ -18,9 +18,11 @@ export async function handleMessageReactionRemoveEmoji(
|
||||
(reaction) =>
|
||||
!(
|
||||
// MUST USE == because discord sends null and we use undefined
|
||||
reaction.emoji.id == payload.emoji.id &&
|
||||
reaction.emoji.name === payload.emoji.name
|
||||
),
|
||||
(
|
||||
reaction.emoji.id == payload.emoji.id &&
|
||||
reaction.emoji.name === payload.emoji.name
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (!message.reactions.length) message.reactions = undefined;
|
||||
@@ -32,6 +34,6 @@ export async function handleMessageReactionRemoveEmoji(
|
||||
payload.emoji,
|
||||
snowflakeToBigint(payload.messageId),
|
||||
snowflakeToBigint(payload.channelId),
|
||||
payload.guildId ? snowflakeToBigint(payload.guildId) : undefined,
|
||||
payload.guildId ? snowflakeToBigint(payload.guildId) : undefined
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,21 +9,18 @@ export async function handleMessageUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as Message;
|
||||
const channel = await cacheHandlers.get(
|
||||
"channels",
|
||||
snowflakeToBigint(payload.channelId),
|
||||
snowflakeToBigint(payload.channelId)
|
||||
);
|
||||
if (!channel) return;
|
||||
|
||||
const oldMessage = await cacheHandlers.get(
|
||||
"messages",
|
||||
snowflakeToBigint(payload.id),
|
||||
snowflakeToBigint(payload.id)
|
||||
);
|
||||
if (!oldMessage) return;
|
||||
|
||||
// Messages with embeds can trigger update but they wont have edited_timestamp
|
||||
if (
|
||||
!payload.editedTimestamp ||
|
||||
(oldMessage.content === payload.content)
|
||||
) {
|
||||
if (!payload.editedTimestamp || oldMessage.content === payload.content) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ export async function handlePresenceUpdate(data: DiscordGatewayPayload) {
|
||||
|
||||
const oldPresence = await cacheHandlers.get(
|
||||
"presences",
|
||||
snowflakeToBigint(payload.user.id),
|
||||
snowflakeToBigint(payload.user.id)
|
||||
);
|
||||
await cacheHandlers.set(
|
||||
"presences",
|
||||
snowflakeToBigint(payload.user.id),
|
||||
payload,
|
||||
payload
|
||||
);
|
||||
|
||||
eventHandlers.presenceUpdate?.(payload, oldPresence);
|
||||
|
||||
@@ -5,10 +5,7 @@ import type { Ready } from "../../types/gateway/ready.ts";
|
||||
import { snowflakeToBigint } from "../../util/bigint.ts";
|
||||
import { DiscordenoShard, ws } from "../../ws/ws.ts";
|
||||
|
||||
export function handleReady(
|
||||
data: DiscordGatewayPayload,
|
||||
shardId: number,
|
||||
) {
|
||||
export function handleReady(data: DiscordGatewayPayload, shardId: number) {
|
||||
// Triggered on each shard
|
||||
eventHandlers.shardReady?.(shardId);
|
||||
|
||||
@@ -26,17 +23,14 @@ export function handleReady(
|
||||
shard.ready = false;
|
||||
// All guilds are unavailable at first
|
||||
shard.unavailableGuildIds = new Set(
|
||||
payload.guilds.map((g) => snowflakeToBigint(g.id)),
|
||||
payload.guilds.map((g) => snowflakeToBigint(g.id))
|
||||
);
|
||||
// Set the last available to now
|
||||
shard.lastAvailable = Date.now();
|
||||
|
||||
// Start ready check in 2 seconds
|
||||
setTimeout(() => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`1. Running setTimeout in READY file.`,
|
||||
);
|
||||
eventHandlers.debug?.("loop", `1. Running setTimeout in READY file.`);
|
||||
checkReady(payload, shard);
|
||||
}, 2000);
|
||||
}
|
||||
@@ -55,10 +49,7 @@ function checkReady(payload: Ready, shard: DiscordenoShard) {
|
||||
|
||||
// Not all guilds were loaded but 5 seconds haven't passed so check again
|
||||
setTimeout(() => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`2. Running setTimeout in READY file.`,
|
||||
);
|
||||
eventHandlers.debug?.("loop", `2. Running setTimeout in READY file.`);
|
||||
checkReady(payload, shard);
|
||||
}, 2000);
|
||||
}
|
||||
@@ -72,10 +63,7 @@ function loaded(shard: DiscordenoShard) {
|
||||
// Still some shards are loading so wait another 2 seconds for them
|
||||
if (ws.shards.some((shard) => !shard.ready)) {
|
||||
setTimeout(() => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`3. Running setTimeout in READY file.`,
|
||||
);
|
||||
eventHandlers.debug?.("loop", `3. Running setTimeout in READY file.`);
|
||||
loaded(shard);
|
||||
}, 2000);
|
||||
|
||||
|
||||
@@ -3,7 +3,5 @@ import type { DiscordGatewayPayload } from "../../types/gateway/gateway_payload.
|
||||
import type { TypingStart } from "../../types/misc/typing_start.ts";
|
||||
|
||||
export function handleTypingStart(data: DiscordGatewayPayload) {
|
||||
eventHandlers.typingStart?.(
|
||||
data.d as TypingStart,
|
||||
);
|
||||
eventHandlers.typingStart?.(data.d as TypingStart);
|
||||
}
|
||||
|
||||
@@ -9,17 +9,14 @@ export async function handleUserUpdate(data: DiscordGatewayPayload) {
|
||||
|
||||
const member = await cacheHandlers.get(
|
||||
"members",
|
||||
snowflakeToBigint(userData.id),
|
||||
snowflakeToBigint(userData.id)
|
||||
);
|
||||
if (!member) return;
|
||||
|
||||
Object.entries(userData).forEach(([key, value]) => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`Running forEach loop in USER_UPDATE file.`,
|
||||
);
|
||||
eventHandlers.debug?.("loop", `Running forEach loop in USER_UPDATE file.`);
|
||||
// @ts-ignore index signatures
|
||||
if (member[key] !== value) return member[key] = value;
|
||||
if (member[key] !== value) return (member[key] = value);
|
||||
});
|
||||
|
||||
await cacheHandlers.set("members", snowflakeToBigint(userData.id), member);
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function handleGuildRoleCreate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as GuildRoleCreate;
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (!guild) return;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export async function handleGuildRoleDelete(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as GuildRoleDelete;
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (!guild) return;
|
||||
|
||||
@@ -23,7 +23,7 @@ export async function handleGuildRoleDelete(data: DiscordGatewayPayload) {
|
||||
cacheHandlers.forEach("members", (member) => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`1. Running forEach members loop in GUILD_ROLE_DELETE file.`,
|
||||
`1. Running forEach members loop in GUILD_ROLE_DELETE file.`
|
||||
);
|
||||
// Not in the relevant guild so just skip.
|
||||
if (!member.guilds.has(guild.id)) return;
|
||||
@@ -31,7 +31,7 @@ export async function handleGuildRoleDelete(data: DiscordGatewayPayload) {
|
||||
member.guilds.forEach((g) => {
|
||||
eventHandlers.debug?.(
|
||||
"loop",
|
||||
`2. Running forEach loop in CHANNEL_DELTE file.`,
|
||||
`2. Running forEach loop in CHANNEL_DELTE file.`
|
||||
);
|
||||
// Member does not have this role
|
||||
if (!g.roles.includes(roleId)) return;
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function handleGuildRoleUpdate(data: DiscordGatewayPayload) {
|
||||
const payload = data.d as GuildRoleUpdate;
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (!guild) return;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export async function handleVoiceServerUpdate(data: DiscordGatewayPayload) {
|
||||
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (!guild) return;
|
||||
|
||||
|
||||
@@ -11,15 +11,12 @@ export async function handleVoiceStateUpdate(data: DiscordGatewayPayload) {
|
||||
|
||||
const guild = await cacheHandlers.get(
|
||||
"guilds",
|
||||
snowflakeToBigint(payload.guildId),
|
||||
snowflakeToBigint(payload.guildId)
|
||||
);
|
||||
if (!guild) return;
|
||||
|
||||
const member = payload.member
|
||||
? await structures.createDiscordenoMember(
|
||||
payload.member,
|
||||
guild.id,
|
||||
)
|
||||
? await structures.createDiscordenoMember(payload.member, guild.id)
|
||||
: await cacheHandlers.get("members", snowflakeToBigint(payload.userId));
|
||||
if (!member) return;
|
||||
|
||||
@@ -28,27 +25,29 @@ export async function handleVoiceStateUpdate(data: DiscordGatewayPayload) {
|
||||
|
||||
guild.voiceStates.set(
|
||||
snowflakeToBigint(payload.userId),
|
||||
await structures.createDiscordenoVoiceState(guild.id, payload),
|
||||
await structures.createDiscordenoVoiceState(guild.id, payload)
|
||||
);
|
||||
|
||||
await cacheHandlers.set("guilds", guild.id, guild);
|
||||
|
||||
if (
|
||||
cachedState?.channelId !==
|
||||
(payload.channelId ? snowflakeToBigint(payload.channelId) : null)
|
||||
(payload.channelId ? snowflakeToBigint(payload.channelId) : null)
|
||||
) {
|
||||
// Either joined or moved channels
|
||||
if (payload.channelId) {
|
||||
if (cachedState?.channelId) { // Was in a channel before
|
||||
if (cachedState?.channelId) {
|
||||
// Was in a channel before
|
||||
eventHandlers.voiceChannelSwitch?.(
|
||||
member,
|
||||
snowflakeToBigint(payload.channelId),
|
||||
cachedState.channelId,
|
||||
cachedState.channelId
|
||||
);
|
||||
} else { // Was not in a channel before so user just joined
|
||||
} else {
|
||||
// Was not in a channel before so user just joined
|
||||
eventHandlers.voiceChannelJoin?.(
|
||||
member,
|
||||
snowflakeToBigint(payload.channelId),
|
||||
snowflakeToBigint(payload.channelId)
|
||||
);
|
||||
}
|
||||
} // Left the channel
|
||||
|
||||
@@ -7,6 +7,6 @@ export function handleWebhooksUpdate(data: DiscordGatewayPayload) {
|
||||
const options = data.d as WebhookUpdate;
|
||||
eventHandlers.webhooksUpdate?.(
|
||||
snowflakeToBigint(options.channelId),
|
||||
snowflakeToBigint(options.guildId),
|
||||
snowflakeToBigint(options.guildId)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user