mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
Merge pull request #1021 from discordeno/lurker
add: lurkerVoiceStateUpdate event
This commit is contained in:
@@ -17,6 +17,8 @@ export async function handleVoiceStateUpdate(data: DiscordGatewayPayload) {
|
||||
: await cacheHandlers.get("members", snowflakeToBigint(payload.userId));
|
||||
if (!member) return;
|
||||
|
||||
if (!payload.member?.joinedAt) return eventHandlers.lurkerVoiceStateUpdate?.(member, payload);
|
||||
|
||||
// No cached state before so lets make one for em
|
||||
const cachedState = guild.voiceStates.get(snowflakeToBigint(payload.userId));
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@ export type EventHandlersDefinitions = {
|
||||
interactionGuildCreate: [data: Omit<Interaction, "member">, member: DiscordenoMember];
|
||||
/** Sent when a user uses a Slash Command in a dm (type 2) or clicks a button (type 3). */
|
||||
interactionDMCreate: [data: Omit<Interaction, "member">];
|
||||
/** Sent when a lurker joins/leaves/moves stage channels. */
|
||||
lurkerVoiceStateUpdate: [member: DiscordenoMember, voiceState: VoiceState];
|
||||
/** Sent when a message is created. */
|
||||
messageCreate: [message: DiscordenoMessage];
|
||||
/** Sent when a message is deleted. */
|
||||
|
||||
@@ -4,6 +4,7 @@ import { deleteGuild } from "../../src/helpers/guilds/delete_guild.ts";
|
||||
import { delay } from "../../src/util/utils.ts";
|
||||
import { ws } from "../../src/ws/ws.ts";
|
||||
import { assertEquals, assertExists } from "../deps.ts";
|
||||
import { delayUntil } from "../util/delay_until.ts";
|
||||
|
||||
// Set necessary settings
|
||||
// Disables the logger which logs everything
|
||||
@@ -33,19 +34,17 @@ Deno.test({
|
||||
const token = Deno.env.get("DISCORD_TOKEN");
|
||||
if (!token) throw new Error("Token is not provided");
|
||||
|
||||
let didReady = false;
|
||||
|
||||
await startBot({
|
||||
token,
|
||||
eventHandlers: {
|
||||
ready: () => (didReady = true),
|
||||
},
|
||||
eventHandlers: {},
|
||||
intents: ["GuildMessages", "Guilds", "GuildEmojis", "GuildMessageReactions"],
|
||||
});
|
||||
|
||||
// Delay the execution by 5 seconds
|
||||
await delay(3000);
|
||||
|
||||
await delayUntil(10000, () => cache.isReady);
|
||||
|
||||
// DELETE GUILDS IF LESS THAN 10 SERVERS AS SAFETY MEASURE
|
||||
if (cache.guilds.size <= 10) {
|
||||
for (const guild of cache.guilds.values()) await deleteGuild(guild.id);
|
||||
@@ -53,7 +52,7 @@ Deno.test({
|
||||
|
||||
// Assertions
|
||||
assertExists(botId);
|
||||
assertEquals(true, didReady);
|
||||
assertEquals(true, cache.isReady);
|
||||
},
|
||||
...defaultTestOptions,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user