mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
plugins.Logs: log multiple role changes in one properly
This commit is contained in:
parent
76b9cb6b0c
commit
56a1f51f56
3 changed files with 36 additions and 7 deletions
|
@ -12,8 +12,9 @@
|
|||
"MEMBER_SOFTBAN": "🔨 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was softbanned by {mod.username}#{mod.discriminator}",
|
||||
"MEMBER_JOIN": "📥 **{member.user.username}#{member.user.discriminator}** (`{member.id}`, <@!{member.id}>) joined{new} (created {account_age} ago)",
|
||||
"MEMBER_LEAVE": "📤 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) left the server",
|
||||
"MEMBER_ROLE_ADD": "🔑 **{member.user.username}#{member.user.discriminator}** (`{member.id}`): role **{role.name}** added by {mod.username}#{mod.discriminator}",
|
||||
"MEMBER_ROLE_REMOVE": "🔑 **{member.user.username}#{member.user.discriminator}** (`{member.id}`): role **{role.name}** removed by {mod.username}#{mod.discriminator}",
|
||||
"MEMBER_ROLE_ADD": "🔑 **{member.user.username}#{member.user.discriminator}** (`{member.id}`): role(s) **{roles}** added by {mod.username}#{mod.discriminator}",
|
||||
"MEMBER_ROLE_REMOVE": "🔑 **{member.user.username}#{member.user.discriminator}** (`{member.id}`): role(s) **{roles}** removed by {mod.username}#{mod.discriminator}",
|
||||
"MEMBER_ROLE_CHANGES": "🔑 **{member.user.username}#{member.user.discriminator}** (`{member.id}`): roles changed: added **{addedRoles}**, removed **{removedRoles}** by {mod.username}#{mod.discriminator}",
|
||||
"MEMBER_NICK_CHANGE": "✏ **{member.user.username}#{member.user.discriminator}** (`{member.id}`): nickname changed from **{oldNick}** to **{newNick}**",
|
||||
"MEMBER_USERNAME_CHANGE": "✏ **{member.user.username}#{member.user.discriminator}** (`{member.id}`): username changed from **{oldName}** to **{newName}**",
|
||||
"MEMBER_RESTORE": "💿 **{member.user.username}#{member.user.discriminator}** (`{member.id}`) was restored",
|
||||
|
|
|
@ -46,4 +46,6 @@ export enum LogType {
|
|||
|
||||
MEMBER_JOIN_WITH_PRIOR_RECORDS,
|
||||
OTHER_SPAM_DETECTED,
|
||||
|
||||
MEMBER_ROLE_CHANGES,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue