mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Add case_id to mutes. Add !mutes command to list mutes.
This commit is contained in:
parent
60c434999e
commit
7a372533ec
9 changed files with 131 additions and 3 deletions
|
@ -9,6 +9,14 @@ export class GuildCases {
|
|||
this.guildId = guildId;
|
||||
}
|
||||
|
||||
async get(ids: number[]): Promise<Case[]> {
|
||||
const result = await knex("cases")
|
||||
.whereIn("id", ids)
|
||||
.select();
|
||||
|
||||
return result.map(r => new Case(r));
|
||||
}
|
||||
|
||||
async find(id: number): Promise<Case> {
|
||||
const result = await knex("cases")
|
||||
.where("guild_id", this.guildId)
|
||||
|
|
|
@ -69,6 +69,22 @@ export class GuildMutes {
|
|||
}
|
||||
}
|
||||
|
||||
async getActiveMutes(): Promise<Mute[]> {
|
||||
const result = await knex("mutes")
|
||||
.where("guild_id", this.guildId)
|
||||
.where(q => q.whereRaw("expires_at > NOW()").orWhereNull("expires_at"))
|
||||
.select();
|
||||
|
||||
return result.map(r => new Mute(r));
|
||||
}
|
||||
|
||||
async setCaseId(userId, caseId) {
|
||||
await knex("mutes")
|
||||
.where("guild_id", this.guildId)
|
||||
.where("user_id", userId)
|
||||
.update({ case_id: caseId });
|
||||
}
|
||||
|
||||
async clear(userId) {
|
||||
return knex("mutes")
|
||||
.where("guild_id", this.guildId)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue