Some of breadthread is working, added basic role tracking
This commit is contained in:
1 parent
b474d55612
commit
5999aeeb0c
15 files changed
+255
-22
No files matched your search
+22
-4
@@ -1,4 +1,4 @@
|
||||
import { Client, Events, GatewayIntentBits, Guild, GuildBasedChannel, Interaction } from "discord.js"
|
||||
import { CacheType, ChatInputCommandInteraction, Client, Events, GatewayIntentBits, Guild, GuildBasedChannel, Interaction, Role } from "discord.js"
|
||||
import { utilities } from "./utilties"
|
||||
import { commands } from "./commands"
|
||||
import { config } from "./config"
|
||||
@@ -13,7 +13,7 @@ export const client : Client = new Client({
|
||||
]
|
||||
})
|
||||
|
||||
let db: SQLCommon
|
||||
export let db: SQLCommon
|
||||
|
||||
if (config.DB_MODE == "sqlite") {
|
||||
db = new utilities.sqlite.SqliteDB("breadbot_test.db")
|
||||
@@ -24,6 +24,7 @@ if (config.DB_MODE == "sqlite") {
|
||||
|
||||
//TODO I really don't want this to be here.
|
||||
utilities.events.messages.setupMessageCapture(client, db)
|
||||
utilities.events.roles.setupRoleCapture(client, db)
|
||||
}
|
||||
|
||||
client.once(Events.ClientReady, () => {
|
||||
@@ -39,6 +40,10 @@ client.once(Events.ClientReady, () => {
|
||||
guild.channels.cache.forEach(async (channel: GuildBasedChannel) => {
|
||||
await utilities.channels.insertChannel(db, channel)
|
||||
})
|
||||
|
||||
guild.roles.cache.forEach(async (role: Role) => {
|
||||
await utilities.roles.insertRole(db, role)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -51,16 +56,29 @@ client.on(Events.GuildCreate, async (guild : Guild) => {
|
||||
})
|
||||
})
|
||||
|
||||
client.on(Events.ChannelCreate, async (channel) => {
|
||||
console.log("CHANNEL CREATE CALLED")
|
||||
await utilities.channels.insertChannel(db, channel)
|
||||
})
|
||||
|
||||
client.on(Events.ThreadCreate, async (channel) => {
|
||||
console.log("THREAD CREATE CALLED")
|
||||
console.log(channel.toString())
|
||||
await utilities.channels.insertChannel(db, channel)
|
||||
})
|
||||
|
||||
client.on(Events.InteractionCreate, async (interaction: Interaction) => {
|
||||
if (!interaction.isCommand()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (commands[interaction.commandName as keyof typeof commands]) {
|
||||
commands[interaction.commandName as keyof typeof commands].execute(interaction)
|
||||
commands[interaction.commandName as keyof typeof commands].execute(interaction as ChatInputCommandInteraction)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
setInterval(async () => {
|
||||
await utilities.breadthread.breadthreadProcessLocks(db, client)
|
||||
}, 5000)
|
||||
|
||||
client.login(config.DISCORD_TOKEN)
|
||||
Reference in new issue
Block a user