mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-17 23:25:02 +00:00
Use actions/events for plugin interoperability. Move base case and mute functionality to their own plugins.
This commit is contained in:
parent
993b38db74
commit
1020747398
14 changed files with 674 additions and 332 deletions
|
@ -29,18 +29,20 @@ export class GuildMutes extends BaseRepository {
|
|||
});
|
||||
}
|
||||
|
||||
async addMute(userId, expiryTime) {
|
||||
async addMute(userId, expiryTime): Promise<Mute> {
|
||||
const expiresAt = expiryTime
|
||||
? moment()
|
||||
.add(expiryTime, "ms")
|
||||
.format("YYYY-MM-DD HH:mm:ss")
|
||||
: null;
|
||||
|
||||
return this.mutes.insert({
|
||||
const result = await this.mutes.insert({
|
||||
guild_id: this.guildId,
|
||||
user_id: userId,
|
||||
expires_at: expiresAt
|
||||
});
|
||||
|
||||
return this.mutes.findOne(result.identifiers[0].id);
|
||||
}
|
||||
|
||||
async updateExpiryTime(userId, newExpiryTime) {
|
||||
|
@ -61,11 +63,12 @@ export class GuildMutes extends BaseRepository {
|
|||
);
|
||||
}
|
||||
|
||||
async addOrUpdateMute(userId, expiryTime) {
|
||||
async addOrUpdateMute(userId, expiryTime): Promise<Mute> {
|
||||
const existingMute = await this.findExistingMuteForUserId(userId);
|
||||
|
||||
if (existingMute) {
|
||||
return this.updateExpiryTime(userId, expiryTime);
|
||||
await this.updateExpiryTime(userId, expiryTime);
|
||||
return this.findExistingMuteForUserId(userId);
|
||||
} else {
|
||||
return this.addMute(userId, expiryTime);
|
||||
}
|
||||
|
@ -83,7 +86,7 @@ export class GuildMutes extends BaseRepository {
|
|||
.getMany();
|
||||
}
|
||||
|
||||
async setCaseId(userId, caseId) {
|
||||
async setCaseId(userId: string, caseId: number) {
|
||||
await this.mutes.update(
|
||||
{
|
||||
guild_id: this.guildId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue