3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 20:35:02 +00:00

Add warn and mute commands. General code clean-up.

This commit is contained in:
Dragory 2018-07-08 13:57:27 +03:00
parent 28bb8165bc
commit 15b7da82e8
5 changed files with 264 additions and 67 deletions

View file

@ -1,5 +1,5 @@
import knex from "../knex";
import moment from "moment-timezone";
import * as moment from "moment-timezone";
import Mute from "../models/Mute";
export class GuildMutes {
@ -12,20 +12,20 @@ export class GuildMutes {
async getExpiredMutes(): Promise<Mute[]> {
const result = await knex("mutes")
.where("guild_id", this.guildId)
.where("expires_at", "<=", "CURDATE()")
.whereNotNull("expires_at")
.whereRaw("expires_at <= NOW()")
.select();
return result.map(r => new Mute(r));
}
async findExistingMuteForUserId(userId: string): Promise<Mute[]> {
async findExistingMuteForUserId(userId: string): Promise<Mute> {
const result = await knex("mutes")
.where("guild_id", this.guildId)
.where("user_id", userId)
.first();
return result.map(r => new Mute(r));
return result ? new Mute(result) : null;
}
async addMute(userId, expiryTime) {
@ -69,8 +69,8 @@ export class GuildMutes {
}
}
async unmute(userId) {
return knex
async clear(userId) {
return knex("mutes")
.where("guild_id", this.guildId)
.where("user_id", userId)
.delete();

View file

@ -0,0 +1,8 @@
export enum ModActionType {
Ban = 1,
Unban,
Note,
Warn,
Kick,
Mute
}