Compare commits
1 commit
6a6c997a5b
...
9619b8f73e
Author | SHA1 | Date | |
---|---|---|---|
9619b8f73e |
10 changed files with 1243 additions and 956 deletions
1
.dev.env
1
.dev.env
|
@ -9,7 +9,6 @@
|
|||
BOT_TOKEN=
|
||||
BOT_VER=3.1
|
||||
BOT_AUTHOR=Vylpes
|
||||
BOT_DATE=08 May 2023
|
||||
BOT_OWNERID=147392775707426816
|
||||
BOT_CLIENTID=682942374040961060
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
"mysql": "^2.18.1",
|
||||
"random-bunny": "^2.0.5",
|
||||
"ts-jest": "^27.1.2",
|
||||
"typeorm": "0.3.14"
|
||||
"typeorm": "^0.2.44",
|
||||
"uuid": "^9.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.0.0",
|
||||
|
|
|
@ -14,17 +14,12 @@ export default class Ignore extends Command {
|
|||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
if (!interaction.guildId) return;
|
||||
|
||||
|
||||
const isChannelIgnored = await IgnoredChannel.IsChannelIgnored(interaction.guildId);
|
||||
|
||||
|
||||
if (isChannelIgnored) {
|
||||
const entity = await IgnoredChannel.FetchOneById(IgnoredChannel, interaction.guildId);
|
||||
|
||||
if (!entity) {
|
||||
await interaction.reply('Unable to find channel.');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
await IgnoredChannel.Remove(IgnoredChannel, entity);
|
||||
|
||||
await interaction.reply('This channel will start being logged again.');
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { Column, DeepPartial, EntityTarget, getConnection, PrimaryColumn, ObjectLiteral, FindOptionsWhere } from "typeorm";
|
||||
import { Column, DeepPartial, EntityTarget, getConnection, PrimaryColumn } from "typeorm";
|
||||
import { v4 } from "uuid";
|
||||
|
||||
export default class BaseEntity {
|
||||
constructor() {
|
||||
this.Id = v4();
|
||||
|
||||
|
||||
this.WhenCreated = new Date();
|
||||
this.WhenUpdated = new Date();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export default class BaseEntity {
|
|||
@Column()
|
||||
WhenUpdated: Date;
|
||||
|
||||
public async Save<T extends BaseEntity>(target: EntityTarget<T>, entity: DeepPartial<T>): Promise<void> {
|
||||
public async Save<T>(target: EntityTarget<T>, entity: DeepPartial<T>): Promise<void> {
|
||||
this.WhenUpdated = new Date();
|
||||
|
||||
const connection = getConnection();
|
||||
|
@ -28,7 +28,7 @@ export default class BaseEntity {
|
|||
await repository.save(entity);
|
||||
}
|
||||
|
||||
public static async Remove<T extends BaseEntity>(target: EntityTarget<T>, entity: T): Promise<void> {
|
||||
public static async Remove<T>(target: EntityTarget<T>, entity: T): Promise<void> {
|
||||
const connection = getConnection();
|
||||
|
||||
const repository = connection.getRepository<T>(target);
|
||||
|
@ -36,7 +36,7 @@ export default class BaseEntity {
|
|||
await repository.remove(entity);
|
||||
}
|
||||
|
||||
public static async FetchAll<T extends BaseEntity>(target: EntityTarget<T>, relations?: string[]): Promise<T[]> {
|
||||
public static async FetchAll<T>(target: EntityTarget<T>, relations?: string[]): Promise<T[]> {
|
||||
const connection = getConnection();
|
||||
|
||||
const repository = connection.getRepository<T>(target);
|
||||
|
@ -46,17 +46,17 @@ export default class BaseEntity {
|
|||
return all;
|
||||
}
|
||||
|
||||
public static async FetchOneById<T extends BaseEntity>(target: EntityTarget<T>, id: string, relations?: string[]): Promise<T | null> {
|
||||
public static async FetchOneById<T>(target: EntityTarget<T>, id: string, relations?: string[]): Promise<T | undefined> {
|
||||
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(id, { relations: relations || [] });
|
||||
|
||||
return single;
|
||||
}
|
||||
|
||||
public static async Any<T extends ObjectLiteral>(target: EntityTarget<T>): Promise<boolean> {
|
||||
public static async Any<T>(target: EntityTarget<T>): Promise<boolean> {
|
||||
const connection = getConnection();
|
||||
|
||||
const repository = connection.getRepository<T>(target);
|
||||
|
|
|
@ -33,12 +33,12 @@ export default class Lobby extends BaseEntity {
|
|||
this.LastUsed = new Date();
|
||||
}
|
||||
|
||||
public static async FetchOneByChannelId(channelId: string, relations?: string[]): Promise<Lobby | null> {
|
||||
public static async FetchOneByChannelId(channelId: string, relations?: string[]): Promise<Lobby | undefined> {
|
||||
const connection = getConnection();
|
||||
|
||||
const repository = connection.getRepository(Lobby);
|
||||
|
||||
const single = await repository.findOne({ where: { ChannelId: channelId }, relations: relations || [] });
|
||||
const single = await repository.findOne({ ChannelId: channelId }, { relations: relations || [] });
|
||||
|
||||
return single;
|
||||
}
|
||||
|
|
|
@ -34,22 +34,22 @@ export default class Audit extends BaseEntity {
|
|||
@Column()
|
||||
ServerId: string;
|
||||
|
||||
public static async FetchAuditsByUserId(userId: string, serverId: string): Promise<Audit[] | null> {
|
||||
public static async FetchAuditsByUserId(userId: string, serverId: string): Promise<Audit[] | undefined> {
|
||||
const connection = getConnection();
|
||||
|
||||
const repository = connection.getRepository(Audit);
|
||||
|
||||
const all = await repository.find({ where: { UserId: userId, ServerId: serverId } });
|
||||
const all = await repository.find({ UserId: userId, ServerId: serverId });
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
public static async FetchAuditByAuditId(auditId: string, serverId: string): Promise<Audit | null> {
|
||||
public static async FetchAuditByAuditId(auditId: string, serverId: string): Promise<Audit | undefined> {
|
||||
const connection = getConnection();
|
||||
|
||||
const repository = connection.getRepository(Audit);
|
||||
|
||||
const single = await repository.findOne({ where: { AuditId: auditId, ServerId: serverId } });
|
||||
const single = await repository.findOne({ AuditId: auditId, ServerId: serverId });
|
||||
|
||||
return single;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ export default class IgnoredChannel extends BaseEntity {
|
|||
|
||||
const repository = connection.getRepository(IgnoredChannel);
|
||||
|
||||
const single = await repository.findOne({ where: { Id: channelId } });
|
||||
const single = await repository.findOne(channelId);
|
||||
|
||||
return single != undefined;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@ export default class Role extends BaseEntity {
|
|||
public SetServer(server: Server) {
|
||||
this.Server = server;
|
||||
}
|
||||
|
||||
public static async FetchOneByRoleId(roleId: string, relations?: string[]): Promise<Role | null> {
|
||||
|
||||
public static async FetchOneByRoleId(roleId: string, relations?: string[]): Promise<Role | undefined> {
|
||||
const connection = getConnection();
|
||||
|
||||
const repository = connection.getRepository(Role);
|
||||
|
||||
const single = await repository.findOne({ where: { RoleId: roleId }, relations: relations || []});
|
||||
const single = await repository.findOne({ RoleId: roleId}, { relations: relations || [] });
|
||||
|
||||
return single;
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ export default class Role extends BaseEntity {
|
|||
|
||||
const repository = connection.getRepository(Server);
|
||||
|
||||
const all = await repository.findOne({ where: { Id: serverId }, relations: [
|
||||
const all = await repository.findOne(serverId, { relations: [
|
||||
"Roles",
|
||||
] });
|
||||
]});
|
||||
|
||||
if (!all) {
|
||||
return [];
|
||||
|
|
|
@ -25,12 +25,12 @@ export default class Setting extends BaseEntity {
|
|||
this.Value = value;
|
||||
}
|
||||
|
||||
public static async FetchOneByKey(key: string, relations?: string[]): Promise<Setting | null> {
|
||||
public static async FetchOneByKey(key: string, relations?: string[]): Promise<Setting | undefined> {
|
||||
const connection = getConnection();
|
||||
|
||||
const repository = connection.getRepository(Setting);
|
||||
|
||||
const single = await repository.findOne({ where: { Key: key }, relations: relations || {} });
|
||||
const single = await repository.findOne({ Key: key }, { relations: relations || [] });
|
||||
|
||||
return single;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue