3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 22:21:51 +00:00

Add special mention if a mod action was performed on behalf of another mod with the --mmod option

This commit is contained in:
Dragory 2019-02-08 20:25:35 +02:00
parent 4ce59fb99b
commit e841f20ab0
4 changed files with 58 additions and 12 deletions

View file

@ -25,6 +25,10 @@ export class Case {
@Column() is_hidden: boolean; @Column() is_hidden: boolean;
@Column() pp_id: string;
@Column() pp_name: string;
@OneToMany(type => CaseNote, note => note.case) @OneToMany(type => CaseNote, note => note.case)
notes: CaseNote[]; notes: CaseNote[];
} }

View file

@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddPPFieldsToCases1549649586803 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`
ALTER TABLE \`cases\`
ADD COLUMN \`pp_id\` BIGINT NULL,
ADD COLUMN \`pp_name\` VARCHAR(128) NULL
`);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.query(`
ALTER TABLE \`cases\`
DROP COLUMN \`pp_id\`,
DROP COLUMN \`pp_name\`
`);
}
}

View file

@ -37,7 +37,8 @@ export class CasesPlugin extends ZeppelinPlugin {
args.auditLogId, args.auditLogId,
args.reason, args.reason,
args.automatic, args.automatic,
args.postInCaseLog args.postInCaseLog,
args.ppId
); );
}); });
@ -72,7 +73,8 @@ export class CasesPlugin extends ZeppelinPlugin {
auditLogId: string = null, auditLogId: string = null,
reason: string = null, reason: string = null,
automatic = false, automatic = false,
postInCaseLogOverride = null postInCaseLogOverride = null,
ppId = null
): Promise<Case> { ): Promise<Case> {
const user = this.bot.users.get(userId); const user = this.bot.users.get(userId);
const userName = user ? `${user.username}#${user.discriminator}` : "Unknown#0000"; const userName = user ? `${user.username}#${user.discriminator}` : "Unknown#0000";
@ -80,13 +82,21 @@ export class CasesPlugin extends ZeppelinPlugin {
const mod = this.bot.users.get(modId); const mod = this.bot.users.get(modId);
const modName = mod ? `${mod.username}#${mod.discriminator}` : "Unknown#0000"; const modName = mod ? `${mod.username}#${mod.discriminator}` : "Unknown#0000";
let ppName = null;
if (ppId) {
const pp = this.bot.users.get(ppId);
ppName = pp ? `${pp.username}#${pp.discriminator}` : "Unknown#0000";
}
const createdCase = await this.cases.create({ const createdCase = await this.cases.create({
type, type,
user_id: userId, user_id: userId,
user_name: userName, user_name: userName,
mod_id: modId, mod_id: modId,
mod_name: modName, mod_name: modName,
audit_log_id: auditLogId audit_log_id: auditLogId,
pp_id: ppId,
pp_name: ppName
}); });
if (reason) { if (reason) {
@ -180,6 +190,10 @@ export class CasesPlugin extends ZeppelinPlugin {
] ]
}; };
if (theCase.pp_id) {
embed.fields[1].value += `\np.p. ${theCase.pp_name}\n<@!${theCase.pp_id}>`;
}
if (theCase.is_hidden) { if (theCase.is_hidden) {
embed.title += " (hidden)"; embed.title += " (hidden)";
} }

View file

@ -339,7 +339,8 @@ export class ModActionsPlugin extends ZeppelinPlugin {
userId: args.member.id, userId: args.member.id,
modId: mod.id, modId: mod.id,
type: CaseTypes.Warn, type: CaseTypes.Warn,
reason: args.reason reason: args.reason,
ppId: mod.id !== msg.author.id ? msg.author.id : null
}); });
msg.channel.createMessage( msg.channel.createMessage(
@ -419,7 +420,8 @@ export class ModActionsPlugin extends ZeppelinPlugin {
userId: args.member.id, userId: args.member.id,
modId: mod.id, modId: mod.id,
type: CaseTypes.Mute, type: CaseTypes.Mute,
reason: args.reason reason: args.reason,
ppId: mod.id !== msg.author.id ? msg.author.id : null
}); });
await this.mutes.setCaseId(args.member.id, theCase.id); await this.mutes.setCaseId(args.member.id, theCase.id);
} }
@ -515,7 +517,8 @@ export class ModActionsPlugin extends ZeppelinPlugin {
userId: args.member.id, userId: args.member.id,
modId: mod.id, modId: mod.id,
type: CaseTypes.Unmute, type: CaseTypes.Unmute,
reason: args.reason reason: args.reason,
ppId: mod.id !== msg.author.id ? msg.author.id : null
}); });
if (unmuteTime) { if (unmuteTime) {
@ -615,7 +618,8 @@ export class ModActionsPlugin extends ZeppelinPlugin {
userId: args.member.id, userId: args.member.id,
modId: mod.id, modId: mod.id,
type: CaseTypes.Kick, type: CaseTypes.Kick,
reason: args.reason reason: args.reason,
ppId: mod.id !== msg.author.id ? msg.author.id : null
}); });
// Confirm the action to the moderator // Confirm the action to the moderator
@ -680,7 +684,8 @@ export class ModActionsPlugin extends ZeppelinPlugin {
userId: args.member.id, userId: args.member.id,
modId: mod.id, modId: mod.id,
type: CaseTypes.Ban, type: CaseTypes.Ban,
reason: args.reason reason: args.reason,
ppId: mod.id !== msg.author.id ? msg.author.id : null
}); });
// Confirm the action to the moderator // Confirm the action to the moderator
@ -733,7 +738,8 @@ export class ModActionsPlugin extends ZeppelinPlugin {
userId: args.member.id, userId: args.member.id,
modId: mod.id, modId: mod.id,
type: CaseTypes.Softban, type: CaseTypes.Softban,
reason: args.reason reason: args.reason,
ppId: mod.id !== msg.author.id ? msg.author.id : null
}); });
// Confirm the action to the moderator // Confirm the action to the moderator
@ -783,7 +789,8 @@ export class ModActionsPlugin extends ZeppelinPlugin {
userId: args.userId, userId: args.userId,
modId: mod.id, modId: mod.id,
type: CaseTypes.Unban, type: CaseTypes.Unban,
reason: args.reason reason: args.reason,
ppId: mod.id !== msg.author.id ? msg.author.id : null
}); });
// Confirm the action // Confirm the action
@ -834,7 +841,8 @@ export class ModActionsPlugin extends ZeppelinPlugin {
userId: args.userId, userId: args.userId,
modId: mod.id, modId: mod.id,
type: CaseTypes.Ban, type: CaseTypes.Ban,
reason: args.reason reason: args.reason,
ppId: mod.id !== msg.author.id ? msg.author.id : null
}); });
// Confirm the action // Confirm the action
@ -970,7 +978,8 @@ export class ModActionsPlugin extends ZeppelinPlugin {
userId: args.target, userId: args.target,
modId: mod.id, modId: mod.id,
type: CaseTypes[type], type: CaseTypes[type],
reason: args.reason reason: args.reason,
ppId: mod.id !== msg.author.id ? msg.author.id : null
}); });
msg.channel.createMessage(successMessage(`Case #${theCase.case_number} created`)); msg.channel.createMessage(successMessage(`Case #${theCase.case_number} created`));