util function to emit event

This commit is contained in:
Flam3rboy 2021-02-10 22:04:13 +01:00
parent d3427b42ea
commit 52ef9f7a3e

26
src/util/Event.ts Normal file
View File

@ -0,0 +1,26 @@
import { db } from "fosscord-server-util";
export async function emitEvent({
guild,
user,
channel,
event,
data,
}: {
guild?: bigint;
channel?: bigint;
user?: bigint;
event: string;
data: any;
}) {
const emitEvent = {
created_at: Math.floor(Date.now() / 1000), // in seconds
guild_id: guild,
user_id: user,
channel_id: channel,
data,
event,
};
return await db.data.events.push(emitEvent);
}