fix: revert name change

This commit is contained in:
QuantumlyTangled
2021-05-17 14:44:44 +02:00
parent 9382e2e921
commit a505ed48cb
3 changed files with 10 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
import { getGatewayBot } from "./helpers/misc/get_gateway_bot.ts";
import { rest } from "./rest/rest.ts";
import type { EventHandlerFunctions } from "./types/discordeno/eventHandlers.ts";
import type { EventHandlers } from "./types/discordeno/eventHandlers.ts";
import { DiscordGatewayIntents } from "./types/gateway/gateway_intents.ts";
import { snowflakeToBigint } from "./util/bigint.ts";
import { GATEWAY_VERSION } from "./util/constants.ts";
@@ -11,7 +11,7 @@ export let secretKey = "";
export let botId = 0n;
export let applicationId = 0n;
export let eventHandlers: EventHandlerFunctions = {};
export let eventHandlers: EventHandlers = {};
export let proxyWSURL = `wss://gateway.discord.gg`;
@@ -44,12 +44,12 @@ export async function startBot(config: BotConfig) {
ws.spawnShards();
}
export function replaceEventHandlers(newEventHandlers: EventHandlerFunctions) {
export function replaceEventHandlers(newEventHandlers: EventHandlers) {
eventHandlers = newEventHandlers;
}
/** Allows you to dynamically update the event handlers by passing in new eventHandlers */
export function updateEventHandlers(newEventHandlers: EventHandlerFunctions) {
export function updateEventHandlers(newEventHandlers: EventHandlers) {
Object.assign(eventHandlers, newEventHandlers);
}
@@ -67,5 +67,5 @@ export interface BotConfig {
token: string;
compress?: boolean;
intents: (DiscordGatewayIntents | keyof typeof DiscordGatewayIntents)[];
eventHandlers?: EventHandlerFunctions;
eventHandlers?: EventHandlers;
}

View File

@@ -1,10 +1,10 @@
import { eventHandlers, replaceEventHandlers } from "../bot.ts";
import type { EventHandlerFunctions } from "../types/discordeno/eventHandlers.ts";
import type { EventHandlers } from "../types/discordeno/eventHandlers.ts";
import type { EventEmitter } from "https://deno.land/std@0.96.0/node/events.ts";
export function proxyEvent(emitter: EventEmitter) {
replaceEventHandlers(new Proxy(eventHandlers, {
get(target, prop: keyof EventHandlerFunctions) {
get(target, prop: keyof EventHandlers) {
return target[prop] !== undefined ? target[prop] : ((...args: unknown[]) => emitter.emit(prop, ...args));
},
}));

View File

@@ -28,7 +28,7 @@ import { VoiceServerUpdate } from "../voice/voice_server_update.ts";
import { DebugArg } from "./debug_arg.ts";
import { GuildUpdateChange } from "./guild_update_change.ts";
export type EventHandlers = {
export type EventHandlersDefinitions = {
/** Sent when a new Slash Command is created, relevant to the current user. */
applicationCommandCreate: [data: ApplicationCommandCreateUpdateDelete];
/** Sent when a Slash Command relevant to the current user is updated. */
@@ -160,6 +160,6 @@ export type EventHandlers = {
inviteDelete: [data: InviteDelete];
}
export type EventHandlerFunctions = {
[E in keyof EventHandlers]?: (...args: EventHandlers[E]) => unknown;
export type EventHandlers = {
[E in keyof EventHandlersDefinitions]?: (...args: EventHandlersDefinitions[E]) => unknown;
};