mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-17 11:25:03 +00:00
Merge branch '240811_application_commands_merge_2' into next
This commit is contained in:
commit
43b8017985
279 changed files with 6192 additions and 3044 deletions
|
@ -1,4 +1,5 @@
|
|||
import { In, InsertResult, Repository } from "typeorm";
|
||||
import { FindOptionsWhere } from "typeorm/find-options/FindOptionsWhere";
|
||||
import { Queue } from "../Queue.js";
|
||||
import { chunkArray } from "../utils.js";
|
||||
import { BaseGuildRepository } from "./BaseGuildRepository.js";
|
||||
|
@ -73,34 +74,69 @@ export class GuildCases extends BaseGuildRepository {
|
|||
});
|
||||
}
|
||||
|
||||
async getByUserId(userId: string): Promise<Case[]> {
|
||||
async getByUserId(
|
||||
userId: string,
|
||||
filters: Omit<FindOptionsWhere<Case>, "guild_id" | "user_id"> = {},
|
||||
): Promise<Case[]> {
|
||||
return this.cases.find({
|
||||
relations: this.getRelations(),
|
||||
where: {
|
||||
guild_id: this.guildId,
|
||||
user_id: userId,
|
||||
...filters,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getRecentByUserId(userId: string, count: number, skip = 0): Promise<Case[]> {
|
||||
return this.cases.find({
|
||||
relations: this.getRelations(),
|
||||
where: {
|
||||
guild_id: this.guildId,
|
||||
user_id: userId,
|
||||
},
|
||||
skip,
|
||||
take: count,
|
||||
order: {
|
||||
case_number: "DESC",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getTotalCasesByModId(modId: string): Promise<number> {
|
||||
async getTotalCasesByModId(
|
||||
modId: string,
|
||||
filters: Omit<FindOptionsWhere<Case>, "guild_id" | "mod_id" | "is_hidden"> = {},
|
||||
): Promise<number> {
|
||||
return this.cases.count({
|
||||
where: {
|
||||
guild_id: this.guildId,
|
||||
mod_id: modId,
|
||||
is_hidden: false,
|
||||
...filters,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getRecentByModId(modId: string, count: number, skip = 0): Promise<Case[]> {
|
||||
async getRecentByModId(
|
||||
modId: string,
|
||||
count: number,
|
||||
skip = 0,
|
||||
filters: Omit<FindOptionsWhere<Case>, "guild_id" | "mod_id"> = {},
|
||||
): Promise<Case[]> {
|
||||
const where: FindOptionsWhere<Case> = {
|
||||
guild_id: this.guildId,
|
||||
mod_id: modId,
|
||||
is_hidden: false,
|
||||
...filters,
|
||||
};
|
||||
|
||||
if (where.is_hidden === true) {
|
||||
delete where.is_hidden;
|
||||
}
|
||||
|
||||
return this.cases.find({
|
||||
relations: this.getRelations(),
|
||||
where: {
|
||||
guild_id: this.guildId,
|
||||
mod_id: modId,
|
||||
is_hidden: false,
|
||||
},
|
||||
where,
|
||||
skip,
|
||||
take: count,
|
||||
order: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue