Feature/182 setup actions (#186)

* Create scripts

* Create github workflows

* Create initial DB migration script

* Make default bot prefix configurable

* Add bot token fetcher
This commit is contained in:
Vylpes 2022-09-06 19:24:40 +01:00 committed by GitHub
parent cd666d24fd
commit 7decd28dc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 525 additions and 83 deletions

View file

@ -25,12 +25,10 @@ export class CoreClient extends Client {
return this._eventItems;
}
constructor(intents: number[], devmode: boolean = false) {
constructor(intents: number[]) {
super({ intents: intents });
dotenv.config();
DefaultValues.useDevPrefix = devmode;
CoreClient._commandItems = [];
CoreClient._eventItems = [];

View file

@ -17,11 +17,7 @@ export default class DefaultValues {
private static SetValues() {
if (this.values.length == 0) {
// Bot
if (this.useDevPrefix) {
this.values.push({ Key: "bot.prefix", Value: "d!" });
} else {
this.values.push({ Key: "bot.prefix", Value: "v!" });
}
this.values.push({ Key: "bot.prefix", Value: process.env.BOT_PREFIX || "v!" })
// Commands
this.values.push({ Key: "commands.disabled", Value: "" });

View file

@ -0,0 +1,20 @@
import { readFileSync } from "fs";
import { QueryRunner } from "typeorm";
export default class MigrationHelper {
public static Up(migrationName: string, version: string, queryFiles: string[], queryRunner: QueryRunner) {
for (let path of queryFiles) {
const query = readFileSync(`${process.cwd()}/database/${version}/${migrationName}/Up/${path}.sql`).toString();
queryRunner.query(query);
}
}
public static Down(migrationName: string, version: string, queryFiles: string[], queryRunner: QueryRunner) {
for (let path of queryFiles) {
const query = readFileSync(`${process.cwd()}/database/${version}/${migrationName}/Down/${path}.sql`).toString();
queryRunner.query(query);
}
}
}

View file

@ -1,13 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm"
export class migration1652375907691 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`CREATE TABLE role (Id varchar(255), WhenCreated datetime, WhenUpdated datetime, RoleId varchar(255), serverId varchar(255), PRIMARY KEY (Id), FOREIGN KEY (serverId) REFERENCES server(Id))`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`DROP TABLE role`);
}
}

View file

@ -1,13 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm"
export class migration1657647026816 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`CREATE TABLE ignored_channel (Id varchar(255), PRIMARY KEY (Id))`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`DROP TABLE ignored_channel`)
}
}

View file

@ -1,13 +0,0 @@
import { MigrationInterface, QueryRunner } from "typeorm"
export class CreateAudit1660754832945 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`CREATE TABLE audit (Id varchar(255), WhenCreated datetime, WhenUpdated datetime, auditId varchar(255), userId varchar(255), auditType int, reason varchar(255), moderatorId varchar(255), serverId varchar(255), PRIMARY KEY (Id))`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`DROP TABLE audit`);
}
}

View file

@ -0,0 +1,30 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import MigrationHelper from "../../helpers/MigrationHelper"
export class vylbot1662399171315 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
MigrationHelper.Up('1662399171315-CreateBase', '3.1', [
"01-table/Audit",
"01-table/IgnoredChannel",
"01-table/Lobby",
"01-table/Role",
"01-table/Server",
"01-table/Setting",
"02-key/Audit",
"02-key/IgnoredChannel",
"02-key/Lobby",
"02-key/Role",
"02-key/Server",
"02-key/Setting",
"03-constraint/Role",
"03-constraint/Setting",
], queryRunner);
}
public async down(queryRunner: QueryRunner): Promise<void> {
}
}

View file

@ -19,13 +19,11 @@ requiredConfigs.forEach(config => {
}
});
const devmode = process.argv.find(x => x.toLowerCase() == "--dev") != null;
const client = new CoreClient([
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
], devmode);
]);
registry.RegisterCommands();
registry.RegisterEvents();