3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-21 08:45:03 +00:00

Update rofls roleRemovalMute to newest commits

This commit is contained in:
Dark 2020-12-22 05:51:21 +01:00
parent 460fb2f29b
commit c3f54954ca
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8
12 changed files with 133 additions and 27 deletions

View file

@ -34,7 +34,7 @@ export class GuildMutes extends BaseGuildRepository {
return mute != null;
}
async addMute(userId, expiryTime): Promise<Mute> {
async addMute(userId, expiryTime, rolesToRestore?: string[]): Promise<Mute> {
const expiresAt = expiryTime
? moment
.utc()
@ -46,12 +46,13 @@ export class GuildMutes extends BaseGuildRepository {
guild_id: this.guildId,
user_id: userId,
expires_at: expiresAt,
roles_to_restore: rolesToRestore ?? [],
});
return (await this.mutes.findOne({ where: result.identifiers[0] }))!;
}
async updateExpiryTime(userId, newExpiryTime) {
async updateExpiryTime(userId, newExpiryTime, rolesToRestore?: string[]) {
const expiresAt = newExpiryTime
? moment
.utc()
@ -59,15 +60,28 @@ export class GuildMutes extends BaseGuildRepository {
.format("YYYY-MM-DD HH:mm:ss")
: null;
return this.mutes.update(
{
guild_id: this.guildId,
user_id: userId,
},
{
expires_at: expiresAt,
},
);
if (rolesToRestore && rolesToRestore.length) {
return this.mutes.update(
{
guild_id: this.guildId,
user_id: userId,
},
{
expires_at: expiresAt,
roles_to_restore: rolesToRestore,
},
);
} else {
return this.mutes.update(
{
guild_id: this.guildId,
user_id: userId,
},
{
expires_at: expiresAt,
},
);
}
}
async getActiveMutes(): Promise<Mute[]> {

View file

@ -15,4 +15,6 @@ export class Mute {
@Column({ type: String, nullable: true }) expires_at: string | null;
@Column() case_id: number;
@Column("simple-array") roles_to_restore: string[];
}