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

plugins.Logs: log multiple role changes in one properly

This commit is contained in:
Dragory 2019-02-23 21:20:35 +02:00
parent 76b9cb6b0c
commit 56a1f51f56
3 changed files with 36 additions and 7 deletions

View file

@ -253,22 +253,48 @@ export class LogsPlugin extends Plugin {
);
const mod = relevantAuditLogEntry ? relevantAuditLogEntry.user : unknownUser;
if (addedRoles.length) {
if (addedRoles.length && removedRoles.length) {
// Roles added *and* removed
this.guildLogs.log(
LogType.MEMBER_ROLE_ADD,
LogType.MEMBER_ROLE_CHANGES,
{
member,
role: this.guild.roles.get(addedRoles[0]),
addedRoles: addedRoles
.map(roleId => this.guild.roles.get(roleId))
.map(r => r.name)
.join(", "),
removedRoles: removedRoles
.map(roleId => this.guild.roles.get(roleId))
.map(r => r.name)
.join(", "),
mod: stripObjectToScalars(mod),
},
member.id,
);
} else if (removedRoles.length) {
} else if (addedRoles.length) {
// Roles added
this.guildLogs.log(
LogType.MEMBER_ROLE_ADD,
{
member,
roles: addedRoles
.map(roleId => this.guild.roles.get(roleId))
.map(r => r.name)
.join(", "),
mod: stripObjectToScalars(mod),
},
member.id,
);
} else if (removedRoles.length && !addedRoles.length) {
// Roles removed
this.guildLogs.log(
LogType.MEMBER_ROLE_REMOVE,
{
member,
role: this.guild.roles.get(removedRoles[0]),
roles: removedRoles
.map(roleId => this.guild.roles.get(roleId))
.map(r => r.name)
.join(", "),
mod: stripObjectToScalars(mod),
},
member.id,