Some of breadthread is working, added basic role tracking

This commit is contained in:
2025-07-07 21:46:12 -04:00
parent b474d55612
commit 5999aeeb0c
15 changed files with 255 additions and 22 deletions

View File

@@ -0,0 +1,23 @@
import { Client, Events } from "discord.js";
import { SQLCommon } from "../storage/interfaces";
import { SQLResult } from "../storage/enumerations";
import { insertRole, markRoleDeleted, updateRole } from "../discord/roles";
import { insertGuild } from "../discord/guilds";
export function setupRoleCapture(client: Client, db: SQLCommon) {
client.on(Events.GuildRoleCreate, async (role) => {
const serverOk: SQLResult = await insertGuild(db, role.guild)
if (serverOk == SQLResult.ALREADYEXISTS || serverOk == SQLResult.CREATED) {
await insertRole(db, role)
}
})
client.on(Events.GuildRoleUpdate, async (role) => {
await updateRole(db, role)
})
client.on(Events.GuildRoleDelete, async (role) => {
await markRoleDeleted(db, role)
})
}