Some of breadthread is working, added basic role tracking
This commit is contained in:
23
src/utilties/events/roles.ts
Normal file
23
src/utilties/events/roles.ts
Normal 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)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user