3.0.7 (#295)
- Update dependency minimatch to 3.1.1 - Update dependency xml2js Co-authored-by: Ethan Lane <ethan@vylpes.com> Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/vylbot-app/pulls/295 Reviewed-by: VylpesTester <tester@vylpes.com>
This commit is contained in:
parent
f9c706fdd8
commit
39999dfbba
8 changed files with 1001 additions and 904 deletions
|
@ -7,7 +7,7 @@
|
||||||
# any secret values.
|
# any secret values.
|
||||||
|
|
||||||
BOT_TOKEN=
|
BOT_TOKEN=
|
||||||
BOT_VER=3.0.6
|
BOT_VER=3.0.7
|
||||||
BOT_AUTHOR=Vylpes
|
BOT_AUTHOR=Vylpes
|
||||||
BOT_DATE=25 Mar 2023
|
BOT_DATE=08 May 2023
|
||||||
BOT_OWNERID=147392775707426816
|
BOT_OWNERID=147392775707426816
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "vylbot-app",
|
"name": "vylbot-app",
|
||||||
"version": "3.0.6",
|
"version": "3.0.7",
|
||||||
"description": "A discord bot made for Vylpes' Den",
|
"description": "A discord bot made for Vylpes' Den",
|
||||||
"main": "./dist/vylbot",
|
"main": "./dist/vylbot",
|
||||||
"typings": "./dist",
|
"typings": "./dist",
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
"mysql": "^2.18.1",
|
"mysql": "^2.18.1",
|
||||||
"random-bunny": "^2.0.0",
|
"random-bunny": "^2.0.0",
|
||||||
"ts-jest": "^27.1.2",
|
"ts-jest": "^27.1.2",
|
||||||
"typeorm": "^0.2.44",
|
"typeorm": "0.3.14",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -130,7 +130,7 @@ export default class Lobby extends Command {
|
||||||
if (lobby) {
|
if (lobby) {
|
||||||
const errorEmbed = new ErrorEmbed(context, "This channel has already been setup.");
|
const errorEmbed = new ErrorEmbed(context, "This channel has already been setup.");
|
||||||
errorEmbed.SendToCurrentChannel();
|
errorEmbed.SendToCurrentChannel();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ export default class Lobby extends Command {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await BaseEntity.Remove<eLobby>(eLobby, entity);
|
await BaseEntity.Remove<eLobby>(eLobby, entity);
|
||||||
|
|
||||||
const embed = new PublicEmbed(context, "", `Removed <#${context.args[2]}> from the list of lobby channels`);
|
const embed = new PublicEmbed(context, "", `Removed <#${context.args[2]}> from the list of lobby channels`);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Column, DeepPartial, EntityTarget, getConnection, PrimaryColumn } from "typeorm";
|
import { Column, DeepPartial, EntityTarget, getConnection, PrimaryColumn, ObjectLiteral, FindOptionsWhere } from "typeorm";
|
||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
|
|
||||||
export default class BaseEntity {
|
export default class BaseEntity {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.Id = v4();
|
this.Id = v4();
|
||||||
|
|
||||||
this.WhenCreated = new Date();
|
this.WhenCreated = new Date();
|
||||||
this.WhenUpdated = new Date();
|
this.WhenUpdated = new Date();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ export default class BaseEntity {
|
||||||
@Column()
|
@Column()
|
||||||
WhenUpdated: Date;
|
WhenUpdated: Date;
|
||||||
|
|
||||||
public async Save<T>(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 connection = getConnection();
|
const connection = getConnection();
|
||||||
|
@ -28,7 +28,7 @@ export default class BaseEntity {
|
||||||
await repository.save(entity);
|
await repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Remove<T>(target: EntityTarget<T>, entity: T): Promise<void> {
|
public static async Remove<T extends BaseEntity>(target: EntityTarget<T>, entity: T): Promise<void> {
|
||||||
const connection = getConnection();
|
const connection = getConnection();
|
||||||
|
|
||||||
const repository = connection.getRepository<T>(target);
|
const repository = connection.getRepository<T>(target);
|
||||||
|
@ -36,7 +36,7 @@ export default class BaseEntity {
|
||||||
await repository.remove(entity);
|
await repository.remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchAll<T>(target: EntityTarget<T>, relations?: string[]): Promise<T[]> {
|
public static async FetchAll<T extends BaseEntity>(target: EntityTarget<T>, relations?: string[]): Promise<T[]> {
|
||||||
const connection = getConnection();
|
const connection = getConnection();
|
||||||
|
|
||||||
const repository = connection.getRepository<T>(target);
|
const repository = connection.getRepository<T>(target);
|
||||||
|
@ -46,17 +46,17 @@ export default class BaseEntity {
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchOneById<T>(target: EntityTarget<T>, id: string, relations?: string[]): Promise<T | undefined> {
|
public static async FetchOneById<T extends BaseEntity>(target: EntityTarget<T>, id: string, relations?: string[]): Promise<T | null> {
|
||||||
const connection = getConnection();
|
const connection = getConnection();
|
||||||
|
|
||||||
const repository = connection.getRepository<T>(target);
|
const repository = connection.getRepository<T>(target);
|
||||||
|
|
||||||
const single = await repository.findOne(id, { relations: relations || [] });
|
const single = await repository.findOne({ where: ({ Id: id } as FindOptionsWhere<T>), relations: relations || {} });
|
||||||
|
|
||||||
return single;
|
return single;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Any<T>(target: EntityTarget<T>): Promise<boolean> {
|
public static async Any<T extends ObjectLiteral>(target: EntityTarget<T>): Promise<boolean> {
|
||||||
const connection = getConnection();
|
const connection = getConnection();
|
||||||
|
|
||||||
const repository = connection.getRepository<T>(target);
|
const repository = connection.getRepository<T>(target);
|
||||||
|
|
|
@ -33,12 +33,12 @@ export default class Lobby extends BaseEntity {
|
||||||
this.LastUsed = new Date();
|
this.LastUsed = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchOneByChannelId(channelId: string, relations?: string[]): Promise<Lobby | undefined> {
|
public static async FetchOneByChannelId(channelId: string, relations?: string[]): Promise<Lobby | null> {
|
||||||
const connection = getConnection();
|
const connection = getConnection();
|
||||||
|
|
||||||
const repository = connection.getRepository(Lobby);
|
const repository = connection.getRepository(Lobby);
|
||||||
|
|
||||||
const single = await repository.findOne({ ChannelId: channelId }, { relations: relations || [] });
|
const single = await repository.findOne({ where: { ChannelId: channelId }, relations: relations || [] });
|
||||||
|
|
||||||
return single;
|
return single;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,13 @@ export default class Role extends BaseEntity {
|
||||||
|
|
||||||
@ManyToOne(() => Server, x => x.Roles)
|
@ManyToOne(() => Server, x => x.Roles)
|
||||||
Server: Server;
|
Server: Server;
|
||||||
|
|
||||||
public static async FetchOneByRoleId(roleId: string, relations?: string[]): Promise<Role | undefined> {
|
public static async FetchOneByRoleId(roleId: string, relations?: string[]): Promise<Role | null> {
|
||||||
const connection = getConnection();
|
const connection = getConnection();
|
||||||
|
|
||||||
const repository = connection.getRepository(Role);
|
const repository = connection.getRepository(Role);
|
||||||
|
|
||||||
const single = await repository.findOne({ RoleId: roleId}, { relations: relations || [] });
|
const single = await repository.findOne({ where: { RoleId: roleId }, relations: relations || []});
|
||||||
|
|
||||||
return single;
|
return single;
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,9 @@ export default class Role extends BaseEntity {
|
||||||
|
|
||||||
const repository = connection.getRepository(Server);
|
const repository = connection.getRepository(Server);
|
||||||
|
|
||||||
const all = await repository.findOne(serverId, { relations: [
|
const all = await repository.findOne({ where: { Id: serverId }, relations: [
|
||||||
"Roles",
|
"Roles",
|
||||||
]});
|
] });
|
||||||
|
|
||||||
if (!all) {
|
if (!all) {
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -25,12 +25,12 @@ export default class Setting extends BaseEntity {
|
||||||
this.Value = value;
|
this.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async FetchOneByKey(key: string, relations?: string[]): Promise<Setting | undefined> {
|
public static async FetchOneByKey(key: string, relations?: string[]): Promise<Setting | null> {
|
||||||
const connection = getConnection();
|
const connection = getConnection();
|
||||||
|
|
||||||
const repository = connection.getRepository(Setting);
|
const repository = connection.getRepository(Setting);
|
||||||
|
|
||||||
const single = await repository.findOne({ Key: key }, { relations: relations || [] });
|
const single = await repository.findOne({ where: { Key: key }, relations: relations || {} });
|
||||||
|
|
||||||
return single;
|
return single;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue