DB Storage Re-engineering #1
@@ -23,6 +23,7 @@ import { DBCallUsers } from "./utilties/storage/entities/DBCallUsers"
|
|||||||
import { DBMessageRegex } from "./utilties/storage/entities/DBMessageRegex"
|
import { DBMessageRegex } from "./utilties/storage/entities/DBMessageRegex"
|
||||||
import { DBMessageRegexMatches } from "./utilties/storage/entities/DBMessageRegexMatches"
|
import { DBMessageRegexMatches } from "./utilties/storage/entities/DBMessageRegexMatches"
|
||||||
import { setupVoice } from "./utilties/events/voice"
|
import { setupVoice } from "./utilties/events/voice"
|
||||||
|
import { DBBreadAsleep } from "./utilties/storage/entities/DBBreadAsleep"
|
||||||
|
|
||||||
console.log(__dirname + path.sep + "utilities" + path.sep + "storage" + path.sep + "entities" + path.sep + "*.ts")
|
console.log(__dirname + path.sep + "utilities" + path.sep + "storage" + path.sep + "entities" + path.sep + "*.ts")
|
||||||
|
|
||||||
@@ -41,7 +42,8 @@ export const dataSource = new DataSource({
|
|||||||
DBCallTranscriptions,
|
DBCallTranscriptions,
|
||||||
DBCallUsers,
|
DBCallUsers,
|
||||||
DBMessageRegex,
|
DBMessageRegex,
|
||||||
DBMessageRegexMatches
|
DBMessageRegexMatches,
|
||||||
|
DBBreadAsleep
|
||||||
],
|
],
|
||||||
synchronize: true,
|
synchronize: true,
|
||||||
logging: false
|
logging: false
|
||||||
@@ -71,8 +73,10 @@ client.once(Events.ClientReady, async () => {
|
|||||||
const matchesRepo = dataSource.getRepository(DBMessageRegexMatches)
|
const matchesRepo = dataSource.getRepository(DBMessageRegexMatches)
|
||||||
const callRepo = dataSource.getRepository(DBCall)
|
const callRepo = dataSource.getRepository(DBCall)
|
||||||
const callUserRepo = dataSource.getRepository(DBCallUsers)
|
const callUserRepo = dataSource.getRepository(DBCallUsers)
|
||||||
|
const breadAsleepRepo = dataSource.getRepository(DBBreadAsleep)
|
||||||
|
|
||||||
client.guilds.cache.forEach(async (guild: Guild) => {
|
client.guilds.cache.forEach(async (guild: Guild) => {
|
||||||
|
await utilities.commands.deployCommands(guild.id)
|
||||||
const server: DBServer | null = await insertGuild(serverRepo, guild)
|
const server: DBServer | null = await insertGuild(serverRepo, guild)
|
||||||
|
|
||||||
if (server != null) {
|
if (server != null) {
|
||||||
@@ -120,7 +124,7 @@ client.once(Events.ClientReady, async () => {
|
|||||||
setupRoleCapture(client, serverRepo, roleRepo)
|
setupRoleCapture(client, serverRepo, roleRepo)
|
||||||
setupMessageCapture(client, serverRepo, channelRepo, userRepo, messageRepo, mccRepo, maRepo, regexesRepo, matchesRepo)
|
setupMessageCapture(client, serverRepo, channelRepo, userRepo, messageRepo, mccRepo, maRepo, regexesRepo, matchesRepo)
|
||||||
setupVoice(client, callRepo, channelRepo, userRepo, callUserRepo)
|
setupVoice(client, callRepo, channelRepo, userRepo, callUserRepo)
|
||||||
|
|
||||||
console.log("Breadbot is Ready")
|
console.log("Breadbot is Ready")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
55
src/commands/breadasleep.ts
Normal file
55
src/commands/breadasleep.ts
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
import { CommandInteraction, SlashCommandBuilder, SlashCommandSubcommandBuilder } from "discord.js";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
enabled: true,
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('breadasleep')
|
||||||
|
.setDescription("Set, list, or remove Bread Asleep notification configurations")
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName("list")
|
||||||
|
.setDescription("Lists any existing Bread Asleep configurations")
|
||||||
|
)
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName("set")
|
||||||
|
.setDescription("Sets the Bread Asleep configuration for a given role")
|
||||||
|
.addRoleOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("role")
|
||||||
|
.setDescription("The role to apply the configuration to")
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("starttime")
|
||||||
|
.setDescription("The time when Bread Asleep warnings will start in 24 hour HH:MM:SS format")
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.addStringOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("endtime")
|
||||||
|
.setDescription("The time when Bread Asleep warnings will end in 24 hour HH:MM:SS format")
|
||||||
|
.setRequired(true)
|
||||||
|
)
|
||||||
|
.addIntegerOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("timeoutduration")
|
||||||
|
.setDescription("The amount of time Bread Asleep will wait between sending warnings in minutes, default 5 minutes")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.addSubcommand((subcommand) =>
|
||||||
|
subcommand
|
||||||
|
.setName("remove")
|
||||||
|
.setDescription("Removes the Bread Asleep configuration for a given role")
|
||||||
|
.addRoleOption((option) =>
|
||||||
|
option
|
||||||
|
.setName("role")
|
||||||
|
.setDescription("The role to remove the Bread Asleep configuration from")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
async execute(interaction: CommandInteraction) {
|
||||||
|
await interaction.reply("NOT IMPLEMENTED")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
23
src/utilties/storage/entities/DBBreadAsleep.ts
Normal file
23
src/utilties/storage/entities/DBBreadAsleep.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { Column, Entity, OneToOne, PrimaryGeneratedColumn } from "typeorm";
|
||||||
|
import { DBRole } from "./DBRole";
|
||||||
|
|
||||||
|
@Entity()
|
||||||
|
export class DBBreadAsleep {
|
||||||
|
@PrimaryGeneratedColumn()
|
||||||
|
bread_asleep_id: number
|
||||||
|
|
||||||
|
@OneToOne(() => DBRole, (role: DBRole) => role.bread_asleep_config)
|
||||||
|
role: DBRole
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
start_time: string
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
end_time: string
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
lockout_duration: number
|
||||||
|
|
||||||
|
@Column({nullable: true})
|
||||||
|
warning_lockout_until: Date | null
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm";
|
import { Column, Entity, ManyToOne, OneToOne, PrimaryColumn } from "typeorm";
|
||||||
import { DBServer } from "./DBServer";
|
import { DBServer } from "./DBServer";
|
||||||
|
import { DBBreadAsleep } from "./DBBreadAsleep";
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class DBRole {
|
export class DBRole {
|
||||||
@@ -14,4 +15,7 @@ export class DBRole {
|
|||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
is_deleted: boolean
|
is_deleted: boolean
|
||||||
|
|
||||||
|
@OneToOne(() => DBBreadAsleep, (ba: DBBreadAsleep) => ba.role, {nullable: true})
|
||||||
|
bread_asleep_config: DBBreadAsleep
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user