mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-17 23:25:02 +00:00
Notify user for spam detection mutes. Add notification status ('user notified in DMs' etc.) to the case. Log case updates. Add 'unmuted immediately' to the case for unmutes without a time.
This commit is contained in:
parent
d5f3a74bdb
commit
2dd6fb22fe
10 changed files with 455 additions and 332 deletions
|
@ -24,11 +24,16 @@ export class GuildMutes extends BaseRepository {
|
|||
return this.mutes.findOne({
|
||||
where: {
|
||||
guild_id: this.guildId,
|
||||
user_id: userId
|
||||
}
|
||||
user_id: userId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async isMuted(userId: string): Promise<boolean> {
|
||||
const mute = await this.findExistingMuteForUserId(userId);
|
||||
return mute != null;
|
||||
}
|
||||
|
||||
async addMute(userId, expiryTime): Promise<Mute> {
|
||||
const expiresAt = expiryTime
|
||||
? moment()
|
||||
|
@ -39,7 +44,7 @@ export class GuildMutes extends BaseRepository {
|
|||
const result = await this.mutes.insert({
|
||||
guild_id: this.guildId,
|
||||
user_id: userId,
|
||||
expires_at: expiresAt
|
||||
expires_at: expiresAt,
|
||||
});
|
||||
|
||||
return this.mutes.findOne({ where: result.identifiers[0] });
|
||||
|
@ -55,25 +60,14 @@ export class GuildMutes extends BaseRepository {
|
|||
return this.mutes.update(
|
||||
{
|
||||
guild_id: this.guildId,
|
||||
user_id: userId
|
||||
user_id: userId,
|
||||
},
|
||||
{
|
||||
expires_at: expiresAt
|
||||
}
|
||||
expires_at: expiresAt,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async addOrUpdateMute(userId, expiryTime): Promise<Mute> {
|
||||
const existingMute = await this.findExistingMuteForUserId(userId);
|
||||
|
||||
if (existingMute) {
|
||||
await this.updateExpiryTime(userId, expiryTime);
|
||||
return this.findExistingMuteForUserId(userId);
|
||||
} else {
|
||||
return this.addMute(userId, expiryTime);
|
||||
}
|
||||
}
|
||||
|
||||
async getActiveMutes(): Promise<Mute[]> {
|
||||
return this.mutes
|
||||
.createQueryBuilder("mutes")
|
||||
|
@ -81,7 +75,7 @@ export class GuildMutes extends BaseRepository {
|
|||
.andWhere(
|
||||
new Brackets(qb => {
|
||||
qb.where("expires_at > NOW()").orWhere("expires_at IS NULL");
|
||||
})
|
||||
}),
|
||||
)
|
||||
.getMany();
|
||||
}
|
||||
|
@ -90,18 +84,18 @@ export class GuildMutes extends BaseRepository {
|
|||
await this.mutes.update(
|
||||
{
|
||||
guild_id: this.guildId,
|
||||
user_id: userId
|
||||
user_id: userId,
|
||||
},
|
||||
{
|
||||
case_id: caseId
|
||||
}
|
||||
case_id: caseId,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async clear(userId) {
|
||||
await this.mutes.delete({
|
||||
guild_id: this.guildId,
|
||||
user_id: userId
|
||||
user_id: userId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue