summary refs log tree commit diff
path: root/src/util/Event.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-10 22:04:13 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-10 22:04:13 +0100
commit52ef9f7a3e35493f4bad780e1a8b9ac8bdfd4c6e (patch)
tree5b21881bd02fa2def97a06d72dfe4dbcd2936f40 /src/util/Event.ts
parentmove Schema from util to api (diff)
downloadserver-52ef9f7a3e35493f4bad780e1a8b9ac8bdfd4c6e.tar.xz
util function to emit event
Diffstat (limited to 'src/util/Event.ts')
-rw-r--r--src/util/Event.ts26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/util/Event.ts b/src/util/Event.ts
new file mode 100644

index 00000000..53c08e2b --- /dev/null +++ b/src/util/Event.ts
@@ -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); +}