summary refs log tree commit diff
path: root/src/util/Event.ts
blob: 53c08e2b97f3c52b19cae0af7c8c4a1ff0ffd5dd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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);
}