Compare commits
No commits in common. "93c4b1553af2add7deb9f882823a52e2307e3a58" and "592a2b0e38a6bfd062b2950fa6a7fd58a9d0c71d" have entirely different histories.
93c4b1553a
...
592a2b0e38
38 changed files with 169 additions and 133 deletions
8
.dev.env
8
.dev.env
|
@ -15,11 +15,3 @@ BOT_CLIENTID=682942374040961060
|
||||||
|
|
||||||
ABOUT_FUNDING=https://ko-fi.com/vylpes
|
ABOUT_FUNDING=https://ko-fi.com/vylpes
|
||||||
ABOUT_REPO=https://gitea.vylpes.xyz/RabbitLabs/vylbot-app
|
ABOUT_REPO=https://gitea.vylpes.xyz/RabbitLabs/vylbot-app
|
||||||
|
|
||||||
DB_HOST=127.0.0.1
|
|
||||||
DB_PORT=3101
|
|
||||||
DB_NAME=vylbot
|
|
||||||
DB_AUTH_USER=dev
|
|
||||||
DB_AUTH_PASS=dev
|
|
||||||
DB_SYNC=true
|
|
||||||
DB_LOGGING=true
|
|
|
@ -14,11 +14,3 @@ BOT_CLIENTID=680083120896081954
|
||||||
|
|
||||||
ABOUT_FUNDING=https://ko-fi.com/vylpes
|
ABOUT_FUNDING=https://ko-fi.com/vylpes
|
||||||
ABOUT_REPO=https://gitea.vylpes.xyz/RabbitLabs/vylbot-app
|
ABOUT_REPO=https://gitea.vylpes.xyz/RabbitLabs/vylbot-app
|
||||||
|
|
||||||
DB_HOST=127.0.0.1
|
|
||||||
DB_PORT=3121
|
|
||||||
DB_NAME=vylbot
|
|
||||||
DB_AUTH_USER=prod
|
|
||||||
DB_AUTH_PASS=prod
|
|
||||||
DB_SYNC=false
|
|
||||||
DB_LOGGING=false
|
|
|
@ -14,11 +14,3 @@ BOT_CLIENTID=1016767908740857949
|
||||||
|
|
||||||
ABOUT_FUNDING=https://ko-fi.com/vylpes
|
ABOUT_FUNDING=https://ko-fi.com/vylpes
|
||||||
ABOUT_REPO=https://gitea.vylpes.xyz/RabbitLabs/vylbot-app
|
ABOUT_REPO=https://gitea.vylpes.xyz/RabbitLabs/vylbot-app
|
||||||
|
|
||||||
DB_HOST=127.0.0.1
|
|
||||||
DB_PORT=3111
|
|
||||||
DB_NAME=vylbot
|
|
||||||
DB_AUTH_USER=stage
|
|
||||||
DB_AUTH_PASS=stage
|
|
||||||
DB_SYNC=false
|
|
||||||
DB_LOGGING=false
|
|
24
ormconfig.dev.json
Normal file
24
ormconfig.dev.json
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"type": "mysql",
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 3101,
|
||||||
|
"username": "dev",
|
||||||
|
"password": "dev",
|
||||||
|
"database": "vylbot",
|
||||||
|
"synchronize": false,
|
||||||
|
"logging": false,
|
||||||
|
"entities": [
|
||||||
|
"dist/entity/**/*.js"
|
||||||
|
],
|
||||||
|
"migrations": [
|
||||||
|
"dist/migration/**/*.js"
|
||||||
|
],
|
||||||
|
"subscribers": [
|
||||||
|
"dist/subscriber/**/*.js"
|
||||||
|
],
|
||||||
|
"cli": {
|
||||||
|
"entitiesDir": "dist/entity",
|
||||||
|
"migrationsDir": "dist/migration",
|
||||||
|
"subscribersDir": "dist/subscriber"
|
||||||
|
}
|
||||||
|
}
|
24
ormconfig.prod.json
Normal file
24
ormconfig.prod.json
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"type": "mysql",
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 3121,
|
||||||
|
"username": "prod",
|
||||||
|
"password": "prod",
|
||||||
|
"database": "vylbot",
|
||||||
|
"synchronize": false,
|
||||||
|
"logging": false,
|
||||||
|
"entities": [
|
||||||
|
"dist/entity/**/*.js"
|
||||||
|
],
|
||||||
|
"migrations": [
|
||||||
|
"dist/migration/**/*.js"
|
||||||
|
],
|
||||||
|
"subscribers": [
|
||||||
|
"dist/subscriber/**/*.js"
|
||||||
|
],
|
||||||
|
"cli": {
|
||||||
|
"entitiesDir": "dist/entity",
|
||||||
|
"migrationsDir": "dist/migration",
|
||||||
|
"subscribersDir": "dist/subscriber"
|
||||||
|
}
|
||||||
|
}
|
24
ormconfig.stage.json
Normal file
24
ormconfig.stage.json
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"type": "mysql",
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 3111,
|
||||||
|
"username": "stage",
|
||||||
|
"password": "stage",
|
||||||
|
"database": "vylbot",
|
||||||
|
"synchronize": false,
|
||||||
|
"logging": false,
|
||||||
|
"entities": [
|
||||||
|
"dist/entity/**/*.js"
|
||||||
|
],
|
||||||
|
"migrations": [
|
||||||
|
"dist/migration/**/*.js"
|
||||||
|
],
|
||||||
|
"subscribers": [
|
||||||
|
"dist/subscriber/**/*.js"
|
||||||
|
],
|
||||||
|
"cli": {
|
||||||
|
"entitiesDir": "dist/entity",
|
||||||
|
"migrationsDir": "dist/migration",
|
||||||
|
"subscribersDir": "dist/subscriber"
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,8 +9,8 @@
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"start": "node ./dist/vylbot",
|
"start": "node ./dist/vylbot",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"db:up": "typeorm migration:run -d dist/database/dataSources/appDataSource.js",
|
"db:up": "typeorm migration:run",
|
||||||
"db:down": "typeorm migration:revert -d dist/database/dataSources/appDataSource.js"
|
"db:down": "typeorm migration:revert"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
"emoji-regex": "^10.0.0",
|
"emoji-regex": "^10.0.0",
|
||||||
"jest": "^29.0.0",
|
"jest": "^29.0.0",
|
||||||
"jest-mock-extended": "^3.0.0",
|
"jest-mock-extended": "^3.0.0",
|
||||||
"minimatch": "9.0.1",
|
"minimatch": "7.4.6",
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"random-bunny": "^2.0.5",
|
"random-bunny": "^2.0.5",
|
||||||
"ts-jest": "^29.0.0",
|
"ts-jest": "^29.0.0",
|
||||||
|
|
|
@ -13,6 +13,7 @@ cd ~/apps/vylbot/vylbot_prod \
|
||||||
&& (pm2 stop vylbot_prod || true) \
|
&& (pm2 stop vylbot_prod || true) \
|
||||||
&& (pm2 delete vylbot_prod || true) \
|
&& (pm2 delete vylbot_prod || true) \
|
||||||
&& cp .prod.env .env \
|
&& cp .prod.env .env \
|
||||||
|
&& cp ormconfig.prod.json ormconfig.json \
|
||||||
&& yarn clean \
|
&& yarn clean \
|
||||||
&& yarn install --frozen-lockfile \
|
&& yarn install --frozen-lockfile \
|
||||||
&& yarn build \
|
&& yarn build \
|
||||||
|
|
|
@ -13,6 +13,7 @@ cd ~/apps/vylbot/vylbot_stage \
|
||||||
&& (pm2 stop vylbot_stage || true) \
|
&& (pm2 stop vylbot_stage || true) \
|
||||||
&& (pm2 delete vylbot_stage || true) \
|
&& (pm2 delete vylbot_stage || true) \
|
||||||
&& cp .stage.env .env \
|
&& cp .stage.env .env \
|
||||||
|
&& cp ormconfig.stage.json ormconfig.json \
|
||||||
&& yarn clean \
|
&& yarn clean \
|
||||||
&& yarn install --frozen-lockfile \
|
&& yarn install --frozen-lockfile \
|
||||||
&& yarn build \
|
&& yarn build \
|
||||||
|
|
|
@ -8,12 +8,11 @@ import { Command } from "../type/command";
|
||||||
|
|
||||||
import { Events } from "./events";
|
import { Events } from "./events";
|
||||||
import { Util } from "./util";
|
import { Util } from "./util";
|
||||||
import AppDataSource from "../database/dataSources/appDataSource";
|
|
||||||
|
|
||||||
export class CoreClient extends Client {
|
export class CoreClient extends Client {
|
||||||
private static _commandItems: ICommandItem[];
|
private static _commandItems: ICommandItem[];
|
||||||
private static _eventItems: IEventItem[];
|
private static _eventItems: IEventItem[];
|
||||||
|
|
||||||
private _events: Events;
|
private _events: Events;
|
||||||
private _util: Util;
|
private _util: Util;
|
||||||
|
|
||||||
|
@ -42,9 +41,10 @@ export class CoreClient extends Client {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await AppDataSource.initialize()
|
await createConnection().catch(e => {
|
||||||
.then(() => console.log("Data Source Initialized"))
|
console.error(e);
|
||||||
.catch((err) => console.error("Error Initialising Data Source", err));
|
return;
|
||||||
|
});
|
||||||
|
|
||||||
super.on("interactionCreate", this._events.onInteractionCreate);
|
super.on("interactionCreate", this._events.onInteractionCreate);
|
||||||
super.on("ready", this._events.onReady);
|
super.on("ready", this._events.onReady);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||||
import { Command } from "../../../type/command";
|
import { Command } from "../../../type/command";
|
||||||
import { default as eLobby } from "../../../database/entities/501231711271780357/Lobby";
|
import { default as eLobby } from "../../../entity/501231711271780357/Lobby";
|
||||||
|
|
||||||
export default class AddRole extends Command {
|
export default class AddRole extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CacheType, CommandInteraction, EmbedBuilder, GuildBasedChannel, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
import { CacheType, CommandInteraction, EmbedBuilder, GuildBasedChannel, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||||
import { Command } from "../../../type/command";
|
import { Command } from "../../../type/command";
|
||||||
import { default as eLobby } from "../../../database/entities/501231711271780357/Lobby";
|
import { default as eLobby } from "../../../entity/501231711271780357/Lobby";
|
||||||
import EmbedColours from "../../../constants/EmbedColours";
|
import EmbedColours from "../../../constants/EmbedColours";
|
||||||
|
|
||||||
export default class ListLobby extends Command {
|
export default class ListLobby extends Command {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
import { CommandInteraction, SlashCommandBuilder } from "discord.js";
|
||||||
import { Command } from "../../../type/command";
|
import { Command } from "../../../type/command";
|
||||||
import { default as eLobby } from "../../../database/entities/501231711271780357/Lobby";
|
import { default as eLobby } from "../../../entity/501231711271780357/Lobby";
|
||||||
|
|
||||||
export default class Lobby extends Command {
|
export default class Lobby extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -13,7 +13,7 @@ export default class Lobby extends Command {
|
||||||
|
|
||||||
public override async execute(interaction: CommandInteraction) {
|
public override async execute(interaction: CommandInteraction) {
|
||||||
if (!interaction.channelId) return;
|
if (!interaction.channelId) return;
|
||||||
|
|
||||||
const lobby = await eLobby.FetchOneByChannelId(interaction.channelId);
|
const lobby = await eLobby.FetchOneByChannelId(interaction.channelId);
|
||||||
|
|
||||||
if (!lobby) {
|
if (!lobby) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||||
import { Command } from "../../../type/command";
|
import { Command } from "../../../type/command";
|
||||||
import { default as eLobby } from "../../../database/entities/501231711271780357/Lobby";
|
import { default as eLobby } from "../../../entity/501231711271780357/Lobby";
|
||||||
import BaseEntity from "../../../contracts/BaseEntity";
|
import BaseEntity from "../../../contracts/BaseEntity";
|
||||||
|
|
||||||
export default class RemoveLobby extends Command {
|
export default class RemoveLobby extends Command {
|
||||||
|
@ -32,7 +32,7 @@ export default class RemoveLobby extends Command {
|
||||||
await interaction.reply('Channel not found.');
|
await interaction.reply('Channel not found.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await BaseEntity.Remove<eLobby>(eLobby, entity);
|
await BaseEntity.Remove<eLobby>(eLobby, entity);
|
||||||
|
|
||||||
await interaction.reply(`Removed <#${channel.channel.id}> from the list of lobby channels`);
|
await interaction.reply(`Removed <#${channel.channel.id}> from the list of lobby channels`);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||||
import { Command } from "../../type/command";
|
import { Command } from "../../type/command";
|
||||||
import { default as eRole } from "../../database/entities/Role";
|
import { default as eRole } from "../../entity/Role";
|
||||||
import Server from "../../database/entities/Server";
|
import Server from "../../entity/Server";
|
||||||
|
|
||||||
export default class ConfigRole extends Command {
|
export default class ConfigRole extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -33,7 +33,7 @@ export default class ConfigRole extends Command {
|
||||||
|
|
||||||
if (existingRole) {
|
if (existingRole) {
|
||||||
await eRole.Remove(eRole, existingRole);
|
await eRole.Remove(eRole, existingRole);
|
||||||
|
|
||||||
await interaction.reply('Removed role from configuration.');
|
await interaction.reply('Removed role from configuration.');
|
||||||
} else {
|
} else {
|
||||||
const server = await Server.FetchOneById(Server, interaction.guildId);
|
const server = await Server.FetchOneById(Server, interaction.guildId);
|
||||||
|
@ -45,7 +45,7 @@ export default class ConfigRole extends Command {
|
||||||
|
|
||||||
const newRole = new eRole(role.role.id);
|
const newRole = new eRole(role.role.id);
|
||||||
newRole.SetServer(server);
|
newRole.SetServer(server);
|
||||||
|
|
||||||
await newRole.Save(eRole, newRole);
|
await newRole.Save(eRole, newRole);
|
||||||
|
|
||||||
await interaction.reply('Added role to configuration.');
|
await interaction.reply('Added role to configuration.');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { CommandInteraction, EmbedBuilder, GuildMemberRoleManager, SlashCommandBuilder } from "discord.js";
|
import { CommandInteraction, EmbedBuilder, GuildMemberRoleManager, SlashCommandBuilder } from "discord.js";
|
||||||
import { Command } from "../../type/command";
|
import { Command } from "../../type/command";
|
||||||
import { default as eRole } from "../../database/entities/Role";
|
import { default as eRole } from "../../entity/Role";
|
||||||
import EmbedColours from "../../constants/EmbedColours";
|
import EmbedColours from "../../constants/EmbedColours";
|
||||||
|
|
||||||
export default class Role extends Command {
|
export default class Role extends Command {
|
||||||
|
@ -47,7 +47,7 @@ export default class Role extends Command {
|
||||||
.setColor(EmbedColours.Ok)
|
.setColor(EmbedColours.Ok)
|
||||||
.setTitle("Roles")
|
.setTitle("Roles")
|
||||||
.setDescription(`Roles: ${roles.length}\n\n${roles.join("\n")}`);
|
.setDescription(`Roles: ${roles.length}\n\n${roles.join("\n")}`);
|
||||||
|
|
||||||
await interaction.reply({ embeds: [ embed ]});
|
await interaction.reply({ embeds: [ embed ]});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import Audit from "../database/entities/Audit";
|
import Audit from "../entity/Audit";
|
||||||
import AuditTools from "../helpers/AuditTools";
|
import AuditTools from "../helpers/AuditTools";
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||||
|
@ -13,7 +13,7 @@ export default class Audits extends Command {
|
||||||
.setName("audits")
|
.setName("audits")
|
||||||
.setDescription("View audits of a particular user in the server")
|
.setDescription("View audits of a particular user in the server")
|
||||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
|
||||||
.addSubcommand(subcommand =>
|
.addSubcommand(subcommand =>
|
||||||
subcommand
|
subcommand
|
||||||
.setName('user')
|
.setName('user')
|
||||||
.setDescription('View all audits done against a user')
|
.setDescription('View all audits done against a user')
|
||||||
|
@ -66,7 +66,7 @@ export default class Audits extends Command {
|
||||||
option
|
option
|
||||||
.setName('reason')
|
.setName('reason')
|
||||||
.setDescription('The reason')));
|
.setDescription('The reason')));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async execute(interaction: CommandInteraction) {
|
public override async execute(interaction: CommandInteraction) {
|
||||||
|
@ -188,13 +188,13 @@ export default class Audits extends Command {
|
||||||
await interaction.reply("Audit cleared.");
|
await interaction.reply("Audit cleared.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async AddAudit(interaction: CommandInteraction) {
|
private async AddAudit(interaction: CommandInteraction) {
|
||||||
if (!interaction.guildId) return;
|
if (!interaction.guildId) return;
|
||||||
|
|
||||||
const user = interaction.options.getUser('target');
|
const user = interaction.options.getUser('target');
|
||||||
const auditType = interaction.options.get('type');
|
const auditType = interaction.options.get('type');
|
||||||
const reasonInput = interaction.options.get('reason');
|
const reasonInput = interaction.options.get('reason');
|
||||||
|
|
||||||
if (!user || !auditType || !auditType.value) {
|
if (!user || !auditType || !auditType.value) {
|
||||||
await interaction.reply("Invalid input.");
|
await interaction.reply("Invalid input.");
|
||||||
return;
|
return;
|
||||||
|
@ -206,7 +206,7 @@ export default class Audits extends Command {
|
||||||
const audit = new Audit(user.id, type, reason, interaction.user.id, interaction.guildId);
|
const audit = new Audit(user.id, type, reason, interaction.user.id, interaction.guildId);
|
||||||
|
|
||||||
await audit.Save(Audit, audit);
|
await audit.Save(Audit, audit);
|
||||||
|
|
||||||
await interaction.reply(`Created new audit with ID \`${audit.AuditId}\``);
|
await interaction.reply(`Created new audit with ID \`${audit.AuditId}\``);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
import Audit from "../database/entities/Audit";
|
import Audit from "../entity/Audit";
|
||||||
import { AuditType } from "../constants/AuditType";
|
import { AuditType } from "../constants/AuditType";
|
||||||
import { CommandInteraction, EmbedBuilder, GuildMember, PermissionsBitField, SlashCommandBuilder, TextChannel } from "discord.js";
|
import { CommandInteraction, EmbedBuilder, GuildMember, PermissionsBitField, SlashCommandBuilder, TextChannel } from "discord.js";
|
||||||
import EmbedColours from "../constants/EmbedColours";
|
import EmbedColours from "../constants/EmbedColours";
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuil
|
||||||
import { readFileSync } from "fs";
|
import { readFileSync } from "fs";
|
||||||
import DefaultValues from "../constants/DefaultValues";
|
import DefaultValues from "../constants/DefaultValues";
|
||||||
import EmbedColours from "../constants/EmbedColours";
|
import EmbedColours from "../constants/EmbedColours";
|
||||||
import Server from "../database/entities/Server";
|
import Server from "../entity/Server";
|
||||||
import Setting from "../database/entities/Setting";
|
import Setting from "../entity/Setting";
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
|
|
||||||
export default class Config extends Command {
|
export default class Config extends Command {
|
||||||
|
@ -124,7 +124,7 @@ export default class Config extends Command {
|
||||||
|
|
||||||
private async ResetValue(interaction: CommandInteraction) {
|
private async ResetValue(interaction: CommandInteraction) {
|
||||||
if (!interaction.guildId) return;
|
if (!interaction.guildId) return;
|
||||||
|
|
||||||
const key = interaction.options.get('key');
|
const key = interaction.options.get('key');
|
||||||
|
|
||||||
if (!key || !key.value) {
|
if (!key || !key.value) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||||
import IgnoredChannel from "../database/entities/IgnoredChannel";
|
import IgnoredChannel from "../entity/IgnoredChannel";
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
|
|
||||||
export default class Ignore extends Command {
|
export default class Ignore extends Command {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
import Audit from "../database/entities/Audit";
|
import Audit from "../entity/Audit";
|
||||||
import { AuditType } from "../constants/AuditType";
|
import { AuditType } from "../constants/AuditType";
|
||||||
import { CommandInteraction, EmbedBuilder, GuildMember, PermissionsBitField, SlashCommandBuilder, TextChannel } from "discord.js";
|
import { CommandInteraction, EmbedBuilder, GuildMember, PermissionsBitField, SlashCommandBuilder, TextChannel } from "discord.js";
|
||||||
import EmbedColours from "../constants/EmbedColours";
|
import EmbedColours from "../constants/EmbedColours";
|
||||||
|
@ -54,7 +54,7 @@ export default class Kick extends Command {
|
||||||
value: reason,
|
value: reason,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (!member.kickable) {
|
if (!member.kickable) {
|
||||||
await interaction.reply('Insufficient permissions. Please contact a moderator.');
|
await interaction.reply('Insufficient permissions. Please contact a moderator.');
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { CommandInteraction, EmbedBuilder, GuildMember, PermissionsBitField, SlashCommandBuilder, TextChannel } from "discord.js";
|
import { CommandInteraction, EmbedBuilder, GuildMember, PermissionsBitField, SlashCommandBuilder, TextChannel } from "discord.js";
|
||||||
import { AuditType } from "../constants/AuditType";
|
import { AuditType } from "../constants/AuditType";
|
||||||
import EmbedColours from "../constants/EmbedColours";
|
import EmbedColours from "../constants/EmbedColours";
|
||||||
import Audit from "../database/entities/Audit";
|
import Audit from "../entity/Audit";
|
||||||
import SettingsHelper from "../helpers/SettingsHelper";
|
import SettingsHelper from "../helpers/SettingsHelper";
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
import { CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
|
||||||
import Server from "../database/entities/Server";
|
import Server from "../entity/Server";
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
|
|
||||||
export default class Setup extends Command {
|
export default class Setup extends Command {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { CommandInteraction, EmbedBuilder, GuildMember, PermissionsBitField, SlashCommandBuilder, TextChannel } from "discord.js";
|
import { CommandInteraction, EmbedBuilder, GuildMember, PermissionsBitField, SlashCommandBuilder, TextChannel } from "discord.js";
|
||||||
import { AuditType } from "../constants/AuditType";
|
import { AuditType } from "../constants/AuditType";
|
||||||
import EmbedColours from "../constants/EmbedColours";
|
import EmbedColours from "../constants/EmbedColours";
|
||||||
import Audit from "../database/entities/Audit";
|
import Audit from "../entity/Audit";
|
||||||
import SettingsHelper from "../helpers/SettingsHelper";
|
import SettingsHelper from "../helpers/SettingsHelper";
|
||||||
import { Command } from "../type/command";
|
import { Command } from "../type/command";
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { Column, DeepPartial, EntityTarget, PrimaryColumn, ObjectLiteral, FindOptionsWhere } from "typeorm";
|
import { Column, DeepPartial, EntityTarget, getConnection, PrimaryColumn, ObjectLiteral, FindOptionsWhere } from "typeorm";
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import AppDataSource from "../database/dataSources/appDataSource";
|
|
||||||
|
|
||||||
export default class BaseEntity {
|
export default class BaseEntity {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -22,19 +21,25 @@ export default class BaseEntity {
|
||||||
public async Save<T extends BaseEntity>(target: EntityTarget<T>, entity: DeepPartial<T>): Promise<void> {
|
public async Save<T extends BaseEntity>(target: EntityTarget<T>, entity: DeepPartial<T>): Promise<void> {
|
||||||
this.WhenUpdated = new Date();
|
this.WhenUpdated = new Date();
|
||||||
|
|
||||||
const repository = AppDataSource.getRepository<T>(target);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository<T>(target);
|
||||||
|
|
||||||
await repository.save(entity);
|
await repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Remove<T extends BaseEntity>(target: EntityTarget<T>, entity: T): Promise<void> {
|
public static async Remove<T extends BaseEntity>(target: EntityTarget<T>, entity: T): Promise<void> {
|
||||||
const repository = AppDataSource.getRepository<T>(target);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository<T>(target);
|
||||||
|
|
||||||
await repository.remove(entity);
|
await repository.remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchAll<T extends BaseEntity>(target: EntityTarget<T>, relations?: string[]): Promise<T[]> {
|
public static async FetchAll<T extends BaseEntity>(target: EntityTarget<T>, relations?: string[]): Promise<T[]> {
|
||||||
const repository = AppDataSource.getRepository<T>(target);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository<T>(target);
|
||||||
|
|
||||||
const all = await repository.find({ relations: relations || [] });
|
const all = await repository.find({ relations: relations || [] });
|
||||||
|
|
||||||
|
@ -42,7 +47,9 @@ export default class BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchOneById<T extends BaseEntity>(target: EntityTarget<T>, id: string, relations?: string[]): Promise<T | null> {
|
public static async FetchOneById<T extends BaseEntity>(target: EntityTarget<T>, id: string, relations?: string[]): Promise<T | null> {
|
||||||
const repository = AppDataSource.getRepository<T>(target);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository<T>(target);
|
||||||
|
|
||||||
const single = await repository.findOne({ where: ({ Id: id } as FindOptionsWhere<T>), relations: relations || {} });
|
const single = await repository.findOne({ where: ({ Id: id } as FindOptionsWhere<T>), relations: relations || {} });
|
||||||
|
|
||||||
|
@ -50,7 +57,9 @@ export default class BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Any<T extends ObjectLiteral>(target: EntityTarget<T>): Promise<boolean> {
|
public static async Any<T extends ObjectLiteral>(target: EntityTarget<T>): Promise<boolean> {
|
||||||
const repository = AppDataSource.getRepository<T>(target);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository<T>(target);
|
||||||
|
|
||||||
const any = await repository.find();
|
const any = await repository.find();
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { DataSource } from "typeorm";
|
|
||||||
import * as dotenv from "dotenv";
|
|
||||||
|
|
||||||
dotenv.config();
|
|
||||||
|
|
||||||
const AppDataSource = new DataSource({
|
|
||||||
type: "mysql",
|
|
||||||
host: process.env.DB_HOST,
|
|
||||||
port: Number(process.env.DB_PORT),
|
|
||||||
username: process.env.DB_AUTH_USER,
|
|
||||||
password: process.env.DB_AUTH_PASS,
|
|
||||||
database: process.env.DB_NAME,
|
|
||||||
synchronize: process.env.DB_SYNC == "true",
|
|
||||||
logging: process.env.DB_LOGGING == "true",
|
|
||||||
entities: [
|
|
||||||
"dist/database/entities/**/*.js",
|
|
||||||
],
|
|
||||||
migrations: [
|
|
||||||
"dist/database/migrations/**/*.js",
|
|
||||||
],
|
|
||||||
subscribers: [
|
|
||||||
"dist/database/subscribers/**/*.js",
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
export default AppDataSource;
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { Column, Entity } from "typeorm";
|
import { Column, Entity, getConnection } from "typeorm";
|
||||||
import BaseEntity from "../../../contracts/BaseEntity";
|
import BaseEntity from "../../contracts/BaseEntity";
|
||||||
import AppDataSource from "../../dataSources/appDataSource";
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export default class Lobby extends BaseEntity {
|
export default class Lobby extends BaseEntity {
|
||||||
|
@ -35,7 +34,9 @@ export default class Lobby extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchOneByChannelId(channelId: string, relations?: string[]): Promise<Lobby | null> {
|
public static async FetchOneByChannelId(channelId: string, relations?: string[]): Promise<Lobby | null> {
|
||||||
const repository = AppDataSource.getRepository(Lobby);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository(Lobby);
|
||||||
|
|
||||||
const single = await repository.findOne({ where: { ChannelId: channelId }, relations: relations || [] });
|
const single = await repository.findOne({ where: { ChannelId: channelId }, relations: relations || [] });
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import { Column, Entity } from "typeorm";
|
import { Column, Entity, getConnection } from "typeorm";
|
||||||
import { AuditType } from "../../constants/AuditType";
|
import { AuditType } from "../constants/AuditType";
|
||||||
import BaseEntity from "../../contracts/BaseEntity";
|
import BaseEntity from "../contracts/BaseEntity";
|
||||||
import StringTools from "../../helpers/StringTools";
|
import StringTools from "../helpers/StringTools";
|
||||||
import AppDataSource from "../dataSources/appDataSource";
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export default class Audit extends BaseEntity {
|
export default class Audit extends BaseEntity {
|
||||||
|
@ -36,7 +35,9 @@ export default class Audit extends BaseEntity {
|
||||||
ServerId: string;
|
ServerId: string;
|
||||||
|
|
||||||
public static async FetchAuditsByUserId(userId: string, serverId: string): Promise<Audit[] | null> {
|
public static async FetchAuditsByUserId(userId: string, serverId: string): Promise<Audit[] | null> {
|
||||||
const repository = AppDataSource.getRepository(Audit);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository(Audit);
|
||||||
|
|
||||||
const all = await repository.find({ where: { UserId: userId, ServerId: serverId } });
|
const all = await repository.find({ where: { UserId: userId, ServerId: serverId } });
|
||||||
|
|
||||||
|
@ -44,7 +45,9 @@ export default class Audit extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchAuditByAuditId(auditId: string, serverId: string): Promise<Audit | null> {
|
public static async FetchAuditByAuditId(auditId: string, serverId: string): Promise<Audit | null> {
|
||||||
const repository = AppDataSource.getRepository(Audit);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository(Audit);
|
||||||
|
|
||||||
const single = await repository.findOne({ where: { AuditId: auditId, ServerId: serverId } });
|
const single = await repository.findOne({ where: { AuditId: auditId, ServerId: serverId } });
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { Entity } from "typeorm";
|
import { Entity, getConnection } from "typeorm";
|
||||||
import BaseEntity from "../../contracts/BaseEntity";
|
import BaseEntity from "../contracts/BaseEntity";
|
||||||
import AppDataSource from "../dataSources/appDataSource";
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export default class IgnoredChannel extends BaseEntity {
|
export default class IgnoredChannel extends BaseEntity {
|
||||||
|
@ -11,7 +10,9 @@ export default class IgnoredChannel extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async IsChannelIgnored(channelId: string): Promise<boolean> {
|
public static async IsChannelIgnored(channelId: string): Promise<boolean> {
|
||||||
const repository = AppDataSource.getRepository(IgnoredChannel);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository(IgnoredChannel);
|
||||||
|
|
||||||
const single = await repository.findOne({ where: { Id: channelId } });
|
const single = await repository.findOne({ where: { Id: channelId } });
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { Column, Entity, ManyToOne } from "typeorm";
|
import { Column, Entity, getConnection, ManyToOne } from "typeorm";
|
||||||
import BaseEntity from "../../contracts/BaseEntity"
|
import BaseEntity from "../contracts/BaseEntity"
|
||||||
import Server from "./Server";
|
import Server from "./Server";
|
||||||
import AppDataSource from "../dataSources/appDataSource";
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export default class Role extends BaseEntity {
|
export default class Role extends BaseEntity {
|
||||||
|
@ -22,7 +21,9 @@ export default class Role extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchOneByRoleId(roleId: string, relations?: string[]): Promise<Role | null> {
|
public static async FetchOneByRoleId(roleId: string, relations?: string[]): Promise<Role | null> {
|
||||||
const repository = AppDataSource.getRepository(Role);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository(Role);
|
||||||
|
|
||||||
const single = await repository.findOne({ where: { RoleId: roleId }, relations: relations || []});
|
const single = await repository.findOne({ where: { RoleId: roleId }, relations: relations || []});
|
||||||
|
|
||||||
|
@ -30,7 +31,9 @@ export default class Role extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchAllByServerId(serverId: string): Promise<Role[]> {
|
public static async FetchAllByServerId(serverId: string): Promise<Role[]> {
|
||||||
const repository = AppDataSource.getRepository(Server);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository(Server);
|
||||||
|
|
||||||
const all = await repository.findOne({ where: { Id: serverId }, relations: [
|
const all = await repository.findOne({ where: { Id: serverId }, relations: [
|
||||||
"Roles",
|
"Roles",
|
|
@ -1,5 +1,5 @@
|
||||||
import { Entity, OneToMany } from "typeorm";
|
import { Entity, OneToMany } from "typeorm";
|
||||||
import BaseEntity from "../../contracts/BaseEntity";
|
import BaseEntity from "../contracts/BaseEntity";
|
||||||
import Role from "./Role";
|
import Role from "./Role";
|
||||||
import Setting from "./Setting";
|
import Setting from "./Setting";
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { Column, Entity, ManyToOne } from "typeorm";
|
import { Column, Entity, getConnection, ManyToOne } from "typeorm";
|
||||||
import BaseEntity from "../../contracts/BaseEntity";
|
import BaseEntity from "../contracts/BaseEntity";
|
||||||
import Server from "./Server";
|
import Server from "./Server";
|
||||||
import AppDataSource from "../dataSources/appDataSource";
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export default class Setting extends BaseEntity {
|
export default class Setting extends BaseEntity {
|
||||||
|
@ -27,7 +26,9 @@ export default class Setting extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchOneByKey(key: string, relations?: string[]): Promise<Setting | null> {
|
public static async FetchOneByKey(key: string, relations?: string[]): Promise<Setting | null> {
|
||||||
const repository = AppDataSource.getRepository(Setting);
|
const connection = getConnection();
|
||||||
|
|
||||||
|
const repository = connection.getRepository(Setting);
|
||||||
|
|
||||||
const single = await repository.findOne({ where: { Key: key }, relations: relations || {} });
|
const single = await repository.findOne({ where: { Key: key }, relations: relations || {} });
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { EmbedBuilder, Message, TextChannel } from "discord.js";
|
import { EmbedBuilder, Message, TextChannel } from "discord.js";
|
||||||
import EmbedColours from "../../constants/EmbedColours";
|
import EmbedColours from "../../constants/EmbedColours";
|
||||||
import IgnoredChannel from "../../database/entities/IgnoredChannel";
|
import IgnoredChannel from "../../entity/IgnoredChannel";
|
||||||
import SettingsHelper from "../../helpers/SettingsHelper";
|
import SettingsHelper from "../../helpers/SettingsHelper";
|
||||||
|
|
||||||
export default async function MessageDelete(message: Message) {
|
export default async function MessageDelete(message: Message) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { EmbedBuilder, Message, TextChannel } from "discord.js";
|
import { EmbedBuilder, Message, TextChannel } from "discord.js";
|
||||||
import EmbedColours from "../../constants/EmbedColours";
|
import EmbedColours from "../../constants/EmbedColours";
|
||||||
import IgnoredChannel from "../../database/entities/IgnoredChannel";
|
import IgnoredChannel from "../../entity/IgnoredChannel";
|
||||||
import SettingsHelper from "../../helpers/SettingsHelper";
|
import SettingsHelper from "../../helpers/SettingsHelper";
|
||||||
|
|
||||||
export default async function MessageUpdate(oldMessage: Message, newMessage: Message) {
|
export default async function MessageUpdate(oldMessage: Message, newMessage: Message) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import DefaultValues from "../constants/DefaultValues";
|
import DefaultValues from "../constants/DefaultValues";
|
||||||
import Server from "../database/entities/Server";
|
import Server from "../entity/Server";
|
||||||
import Setting from "../database/entities/Setting";
|
import Setting from "../entity/Setting";
|
||||||
|
|
||||||
export default class SettingsHelper {
|
export default class SettingsHelper {
|
||||||
public static async GetSetting(key: string, serverId: string): Promise<string | undefined> {
|
public static async GetSetting(key: string, serverId: string): Promise<string | undefined> {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||||
import MigrationHelper from "../../../helpers/MigrationHelper"
|
import MigrationHelper from "../../helpers/MigrationHelper"
|
||||||
|
|
||||||
export class vylbot1662399171315 implements MigrationInterface {
|
export class vylbot1662399171315 implements MigrationInterface {
|
||||||
|
|
|
@ -11,12 +11,6 @@ const requiredConfigs: string[] = [
|
||||||
"BOT_AUTHOR",
|
"BOT_AUTHOR",
|
||||||
"BOT_OWNERID",
|
"BOT_OWNERID",
|
||||||
"BOT_CLIENTID",
|
"BOT_CLIENTID",
|
||||||
"DB_HOST",
|
|
||||||
"DB_PORT",
|
|
||||||
"DB_AUTH_USER",
|
|
||||||
"DB_AUTH_PASS",
|
|
||||||
"DB_SYNC",
|
|
||||||
"DB_LOGGING",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
requiredConfigs.forEach(config => {
|
requiredConfigs.forEach(config => {
|
||||||
|
|
|
@ -2154,10 +2154,10 @@ mimic-response@^3.1.0:
|
||||||
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9"
|
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9"
|
||||||
integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==
|
integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==
|
||||||
|
|
||||||
minimatch@9.0.1:
|
minimatch@7.4.6:
|
||||||
version "9.0.1"
|
version "7.4.6"
|
||||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.1.tgz#8a555f541cf976c622daf078bb28f29fb927c253"
|
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-7.4.6.tgz#845d6f254d8f4a5e4fd6baf44d5f10c8448365fb"
|
||||||
integrity sha512-0jWhJpD/MdhPXwPuiRkCbfYfSKp2qnn2eOc279qI7f+osl/l+prKSrvhg157zSYvx/1nmgn2NqdT6k2Z7zSH9w==
|
integrity sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==
|
||||||
dependencies:
|
dependencies:
|
||||||
brace-expansion "^2.0.1"
|
brace-expansion "^2.0.1"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue