Working on Voice stuff
This commit is contained in:
parent
69f2206a4b
commit
68d8415a77
@ -1,5 +1,5 @@
|
||||
import "reflect-metadata"
|
||||
import { Client, Events, GatewayIntentBits, Guild, GuildBasedChannel, Role } from "discord.js"
|
||||
import { ChatInputCommandInteraction, Client, Events, GatewayIntentBits, Guild, GuildBasedChannel, Interaction, Role } from "discord.js"
|
||||
import { config } from "./config"
|
||||
import { DataSource } from "typeorm"
|
||||
import { DBServer } from "./utilties/storage/entities/DBServer"
|
||||
@ -15,6 +15,11 @@ import { DBMessage } from "./utilties/storage/entities/DBMessage"
|
||||
import { DBMessageContentChanges } from "./utilties/storage/entities/DBMessageContentChanges"
|
||||
import { DBMessageAttachments } from "./utilties/storage/entities/DBMessageAttachment"
|
||||
import { setupMessageCapture } from "./utilties/events/messages"
|
||||
import { utilities } from "./utilties"
|
||||
import { commands } from "./commands"
|
||||
import { DBCall } from "./utilties/storage/entities/DBCall"
|
||||
import { DBCallTranscriptions } from "./utilties/storage/entities/DBCallTranscriptions"
|
||||
import { DBCallUsers } from "./utilties/storage/entities/DBCallUsers"
|
||||
|
||||
console.log(__dirname + path.sep + "utilities" + path.sep + "storage" + path.sep + "entities" + path.sep + "*.ts")
|
||||
|
||||
@ -28,7 +33,10 @@ export const dataSource = new DataSource({
|
||||
DBUser,
|
||||
DBMessage,
|
||||
DBMessageContentChanges,
|
||||
DBMessageAttachments
|
||||
DBMessageAttachments,
|
||||
DBCall,
|
||||
DBCallTranscriptions,
|
||||
DBCallUsers
|
||||
],
|
||||
synchronize: true,
|
||||
logging: true
|
||||
@ -69,70 +77,28 @@ client.once(Events.ClientReady, async () => {
|
||||
}
|
||||
})
|
||||
|
||||
setupRoleCapture(client, serverRepo, roleRepo)
|
||||
setupMessageCapture(client, channelRepo, userRepo, messageRepo, mccRepo, maRepo)
|
||||
|
||||
console.log("Breadbot is Ready")
|
||||
})
|
||||
|
||||
client.login(config.DISCORD_TOKEN)
|
||||
|
||||
/*
|
||||
export let db: SQLCommon
|
||||
|
||||
if (config.DB_MODE == "sqlite") {
|
||||
db = new utilities.sqlite.SqliteDB("breadbot_test.db")
|
||||
|
||||
db.run("PRAGMA foreign_keys = ON")
|
||||
|
||||
utilities.tables.makeTables(db)
|
||||
|
||||
//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, () => {
|
||||
// TODO Winston should handle this
|
||||
console.log("Breadbot is ready")
|
||||
|
||||
client.guilds.cache.forEach(async (guild: Guild) => {
|
||||
client.on(Events.GuildCreate, async (guild : Guild) => {
|
||||
await utilities.commands.deployCommands(guild.id)
|
||||
|
||||
// TODO handle failures?
|
||||
await utilities.guilds.insertGuild(db, guild)
|
||||
await utilities.guilds.insertGuild(serverRepo, guild)
|
||||
|
||||
guild.channels.cache.forEach(async (channel: GuildBasedChannel) => {
|
||||
await utilities.channels.insertChannel(db, channel)
|
||||
await utilities.channels.insertChannel(channelRepo, channel)
|
||||
})
|
||||
|
||||
guild.roles.cache.forEach(async (role: Role) => {
|
||||
await utilities.roles.insertRole(db, role)
|
||||
await insertRole(roleRepo, role)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
client.on(Events.GuildCreate, async (guild : Guild) => {
|
||||
await utilities.commands.deployCommands(guild.id)
|
||||
await utilities.guilds.insertGuild(db, guild)
|
||||
|
||||
guild.channels.cache.forEach(async (channel: GuildBasedChannel) => {
|
||||
await utilities.channels.insertChannel(db, channel)
|
||||
client.on(Events.ChannelCreate, async (channel) => {
|
||||
await utilities.channels.insertChannel(channelRepo, channel)
|
||||
})
|
||||
})
|
||||
|
||||
client.on(Events.ChannelCreate, async (channel) => {
|
||||
console.log("CHANNEL CREATE CALLED")
|
||||
await utilities.channels.insertChannel(db, channel)
|
||||
})
|
||||
client.on(Events.ThreadCreate, async (channel) => {
|
||||
await utilities.channels.insertChannel(channelRepo, 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) => {
|
||||
client.on(Events.InteractionCreate, async (interaction: Interaction) => {
|
||||
if (!interaction.isCommand()) {
|
||||
return
|
||||
}
|
||||
@ -140,10 +106,12 @@ client.on(Events.InteractionCreate, async (interaction: Interaction) => {
|
||||
if (commands[interaction.commandName as keyof typeof commands]) {
|
||||
commands[interaction.commandName as keyof typeof commands].execute(interaction as ChatInputCommandInteraction)
|
||||
}
|
||||
})
|
||||
|
||||
setupRoleCapture(client, serverRepo, roleRepo)
|
||||
setupMessageCapture(client, channelRepo, userRepo, messageRepo, mccRepo, maRepo)
|
||||
|
||||
console.log("Breadbot is Ready")
|
||||
})
|
||||
|
||||
setInterval(async () => {
|
||||
await utilities.breadthread.breadthreadProcessLocks(db, client)
|
||||
}, 5000)
|
||||
|
||||
client.login(config.DISCORD_TOKEN)*/
|
||||
client.login(config.DISCORD_TOKEN)
|
||||
34
src/utilties/storage/entities/DBCall.ts
Normal file
34
src/utilties/storage/entities/DBCall.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { DBChannel } from "./DBChannel";
|
||||
import { DBCallTranscriptions } from "./DBCallTranscriptions";
|
||||
import { DBCallUsers } from "./DBCallUsers";
|
||||
|
||||
@Entity()
|
||||
export class DBCall {
|
||||
@PrimaryGeneratedColumn()
|
||||
call_id: number
|
||||
|
||||
@ManyToOne(() => DBChannel, (channel: DBChannel) => channel.calls)
|
||||
channel: DBChannel
|
||||
|
||||
@Column({type: "datetime"})
|
||||
call_start_time: Date
|
||||
|
||||
@Column({type: "datetime", nullable: true, default: null})
|
||||
call_end_time: Date | null
|
||||
|
||||
@Column({default: false})
|
||||
call_consolidated: boolean
|
||||
|
||||
@Column({default: false})
|
||||
call_transcribed: boolean
|
||||
|
||||
@Column({default: false})
|
||||
call_data_cleaned_up: boolean
|
||||
|
||||
@OneToMany(() => DBCallTranscriptions, (transcription: DBCallTranscriptions) => transcription.call, {nullable: true})
|
||||
transcriptions: DBCallTranscriptions[] | null
|
||||
|
||||
@OneToMany(() => DBCallUsers, (callUser: DBCallUsers) => callUser.call, {nullable: true})
|
||||
participants: DBCallUsers | null
|
||||
}
|
||||
21
src/utilties/storage/entities/DBCallTranscriptions.ts
Normal file
21
src/utilties/storage/entities/DBCallTranscriptions.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { DBCall } from "./DBCall";
|
||||
import { DBUser } from "./DBUser";
|
||||
|
||||
@Entity()
|
||||
export class DBCallTranscriptions {
|
||||
@PrimaryGeneratedColumn()
|
||||
transcription_id: number
|
||||
|
||||
@ManyToOne(() => DBCall, (call: DBCall) => call.transcriptions)
|
||||
call: DBCall
|
||||
|
||||
@ManyToOne(() => DBUser, (user: DBUser) => user.transcriptions)
|
||||
user: DBUser
|
||||
|
||||
@Column({type: "datetime"})
|
||||
speaking_start_time: Date
|
||||
|
||||
@Column()
|
||||
text: string
|
||||
}
|
||||
21
src/utilties/storage/entities/DBCallUsers.ts
Normal file
21
src/utilties/storage/entities/DBCallUsers.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { DBCall } from "./DBCall";
|
||||
import { DBUser } from "./DBUser";
|
||||
|
||||
@Entity()
|
||||
export class DBCallUsers {
|
||||
@PrimaryGeneratedColumn()
|
||||
call_users_id: number
|
||||
|
||||
@ManyToOne(() => DBCall, (call: DBCall) => call.participants)
|
||||
call: DBCall
|
||||
|
||||
@ManyToOne(() => DBUser, (user: DBUser) => user.call_history)
|
||||
user: DBUser
|
||||
|
||||
@Column({type: "datetime"})
|
||||
call_join_time: Date
|
||||
|
||||
@Column({type: "datetime", nullable: true, default: null})
|
||||
call_leave_time: Date | null
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
import { Column, Entity, ManyToOne, OneToMany, PrimaryColumn } from "typeorm";
|
||||
import { DBServer } from "./DBServer";
|
||||
import { DBMessage } from "./DBMessage";
|
||||
import { DBCall } from "./DBCall";
|
||||
|
||||
@Entity()
|
||||
export class DBChannel {
|
||||
@ -23,5 +24,8 @@ export class DBChannel {
|
||||
is_voice: boolean
|
||||
|
||||
@OneToMany(() => DBMessage, (message: DBMessage) => message.channel)
|
||||
messages: DBMessage[]
|
||||
messages: DBMessage[] | null
|
||||
|
||||
@OneToMany(() => DBCall, (call: DBCall) => call.channel)
|
||||
calls: DBCall[] | null
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm";
|
||||
import { DBMessage } from "./DBMessage";
|
||||
import { DBCallTranscriptions } from "./DBCallTranscriptions";
|
||||
import { DBCallUsers } from "./DBCallUsers";
|
||||
|
||||
@Entity()
|
||||
export class DBUser {
|
||||
@ -14,4 +16,10 @@ export class DBUser {
|
||||
|
||||
@OneToMany(() => DBMessage, (message: DBMessage) => message.user)
|
||||
messages: DBMessage[]
|
||||
|
||||
@OneToMany(() => DBCallTranscriptions, (transcription: DBCallTranscriptions) => transcription.user, {nullable: true})
|
||||
transcriptions: DBCallTranscriptions[] | null
|
||||
|
||||
@OneToMany(() => DBCallUsers, (call_user: DBCallUsers) => call_user.user)
|
||||
call_history: DBCallUsers[] | null
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user