Build/project structure #142
@@ -0,0 +1,13 @@
|
||||
import { getDatabase } from '../index.js';
|
||||
|
||||
export function logEvent({ guildId = null, type, actorId = null, payload = null }) {
|
||||
getDatabase()
|
||||
.prepare('INSERT INTO event_logs (guild_id, type, actor_id, payload) VALUES (?, ?, ?, ?)')
|
||||
.run(guildId, type, actorId, payload ? JSON.stringify(payload) : null);
|
||||
}
|
||||
|
||||
export function purgeEventsOlderThan(days) {
|
||||
return getDatabase()
|
||||
.prepare("DELETE FROM event_logs WHERE created_at < datetime('now', ?)")
|
||||
.run(`-${days} days`).changes;
|
||||
}
|
||||
Reference in new issue
Block a user