util function to emit event
This commit is contained in:
parent
d3427b42ea
commit
52ef9f7a3e
26
src/util/Event.ts
Normal file
26
src/util/Event.ts
Normal 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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user