Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Check style

on:
push:
pull_request:
workflow_dispatch:

Expand Down
4 changes: 4 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@
"moderate-mute-command-description": "Mute a user on your server",
"moderate-unmute-command-description": "Unmutes a user on your server",
"moderate-warn-command-description": "Warn a user",
"moderate-channel-mute-description": "Mutes a user from the current channel",
"moderate-unchannel-mute-description": "Removes a channel-mute from this channel",
"moderate-lock-command-description": "Lock the current channel",
"moderate-unlock-command-description": "Unlock the current channel",
"moderate-user-description": "User on who the action should get performed",
Expand All @@ -552,6 +554,8 @@
"quarantine-audit-log-reason": "Got quarantined by %u because of \"%r\"",
"kicked-audit-log-reason": "Got kicked by %u because of \"%r\"",
"banned-audit-log-reason": "Got banned by %u because of \"%r\"",
"channelmute-audit-log-reason": "Got channel-mutet by %u of \"%r\"",
"unchannelmute-audit-log-reason": "The Channel-Mute got removed by %u of \"%r\"",
"unbanned-audit-log-reason": "Got unbanned by %u because of \"%r\"",
"unquarantine-audit-log-reason": "Got unquarantined by %u because of \"%r\"",
"action-expired": "Action expired",
Expand Down
66 changes: 66 additions & 0 deletions modules/moderation/commands/moderate.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,32 @@ module.exports.subcommands = {
interaction.reply({ephemeral: true, content: '⚠ ' + r});
});
},
'channel-mute': async function (interaction) {
if (interaction.replied) return;
if (!checkRoles(interaction, 2)) return;
moderationAction(interaction.client, 'channel-mute', interaction.member, interaction.memberToExecuteUpon, interaction.options.getString('reason'), {channel: interaction.channel}).then(r => {
if (r) interaction.reply({
ephemeral: true,
content: localize('moderation', 'action-done', {i: r.actionID})
});
else interaction.reply({ephemeral: true, content: '⚠ ' + r});
}).catch((r) => {
interaction.reply({ephemeral: true, content: '⚠ ' + r});
});
},
'remove-channel-mute': async function (interaction) {
if (interaction.replied) return;
if (!checkRoles(interaction, 2)) return;
moderationAction(interaction.client, 'unchannel-mute', interaction.member, interaction.memberToExecuteUpon, interaction.options.getString('reason'), {channel: interaction.channel}).then(r => {
if (r) interaction.reply({
ephemeral: true,
content: localize('moderation', 'action-done', {i: r.actionID})
});
else interaction.reply({ephemeral: true, content: '⚠ ' + r});
}).catch((r) => {
interaction.reply({ephemeral: true, content: '⚠ ' + r});
});
},
'lock': async function (interaction) {
if (interaction.replied) return;
if (!checkRoles(interaction, 2)) return;
Expand Down Expand Up @@ -792,6 +818,46 @@ module.exports.config = {
];
}
},
{
type: 'SUB_COMMAND',
name: 'channel-mute',
description: localize('moderation', 'moderate-channel-mute-description'),
options: function (client) {
return [{
type: 'USER',
name: 'user',
required: true,
description: localize('moderation', 'moderate-user-description')
},
{
type: 'STRING',
name: 'reason',
required: client.configurations['moderation']['config']['require_reason'],
description: localize('moderation', 'moderate-reason-description')
}
];
}
},
{
type: 'SUB_COMMAND',
name: 'remove-channel-mute',
description: localize('moderation', 'moderate-unchannel-mute-description'),
options: function (client) {
return [{
type: 'USER',
name: 'user',
required: true,
description: localize('moderation', 'moderate-user-description')
},
{
type: 'STRING',
name: 'reason',
required: client.configurations['moderation']['config']['require_reason'],
description: localize('moderation', 'moderate-reason-description')
}
];
}
},
{
type: 'SUB_COMMAND',
name: 'actions',
Expand Down
8 changes: 4 additions & 4 deletions modules/moderation/configs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"content": "roleID",
"description": "ID of moderator roles that can perform the following actions: Warn",
"humanname-de": "Moderator-Level 1",
"description-de": "ID der Rollen, die folgende Aktionen ausfhren können: Warn",
"description-de": "ID der Rollen, die folgende Aktionen ausführen können: Warn",
"params-de": {},
"default-de": []
},
Expand All @@ -67,7 +67,7 @@
"content": "roleID",
"description": "ID of moderator roles that can perform the following actions: Warn, Mute, Unmute",
"humanname-de": "Moderator-Level 2",
"description-de": "ID der Rollen, die folgende Aktionen ausfhren können: Warn, Mute, Unmute",
"description-de": "ID der Rollen, die folgende Aktionen ausführen können: Warn, Mute, Unmute",
"params-de": {},
"default-de": []
},
Expand All @@ -78,7 +78,7 @@
"content": "roleID",
"description": "ID of moderator roles that can perform the following actions: Warn, Mute, Unmute, Kick, Clear",
"humanname-de": "Moderator-Level 3",
"description-de": "ID der Rollen, die folgende Aktionen ausfhren können: Warn, Mute, Unmute, Kick, Clear",
"description-de": "ID der Rollen, die folgende Aktionen ausführen können: Warn, Mute, Unmute, Kick, Clear",
"params-de": {},
"default-de": []
},
Expand All @@ -89,7 +89,7 @@
"content": "roleID",
"description": "ID of moderator roles that can perform the following actions: Warn, Mute, Unmute, Kick, Clear, Ban, Unban",
"humanname-de": "Moderator-Level 4",
"description-de": "ID der Rollen, die folgende Aktionen ausfhren können: Warn, Mute, Unmute, Kick, Clear, Ban, Unban",
"description-de": "ID der Rollen, die folgende Aktionen ausführen können: Warn, Mute, Unmute, Kick, Clear, Ban, Unban",
"params-de": {},
"default-de": []
},
Expand Down
44 changes: 43 additions & 1 deletion modules/moderation/configs/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,48 @@
"params-de": {},
"default-de": "You got muted for **%reason%** by %user%!"
},
{
"field_name": "channel_mute",
"default": "You got channel-muted from %channel% for **%reason%** by %user%!",
"type": "string",
"allowEmbed": true,
"description": "Message that gets send to a user when they got muted",
"params": [
{
"name": "%user%",
"description": "Tag of the moderator"
},
{
"name": "%reason%",
"description": "Reason of the mute"
},
{
"name": "%channel%",
"description": "Channel from which the user got muted"
}
]
},
{
"field_name": "remove-channel_mute",
"default": "Your channel-mute from %channel% got removed because of **%reason%** by %user%!",
"type": "string",
"allowEmbed": true,
"description": "Message that gets send to a user when they got muted",
"params": [
{
"name": "%user%",
"description": "Tag of the moderator"
},
{
"name": "%reason%",
"description": "Reason of the mute"
},
{
"name": "%channel%",
"description": "Channel from which the user got unmuted"
}
]
},
{
"field_name": "tmpmute_message",
"default": "You got temporarily muted for **%reason%** by %user%! This action is going to expire on %date%.",
Expand Down Expand Up @@ -333,4 +375,4 @@
"default-de": "This channel got unlocked by %user%"
}
]
}
}
36 changes: 34 additions & 2 deletions modules/moderation/moderationActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ async function moderationAction(client, type, user, victim, reason, additionalDa
'%reason%': reason,
'%user%': user.user.tag,
'%date%': expiringAt ? formatDate(expiringAt) : null
})).catch(() => {});
})).catch(() => {
});
if (victim.bannable) await victim.ban({
days: additionalData.days || 0,
reason: '[moderation] ' + localize('moderation', 'banned-audit-log-reason', {
Expand All @@ -154,7 +155,10 @@ async function moderationAction(client, type, user, victim, reason, additionalDa
victim.user.id = victim.id;
await guild.members.ban(victim.id, {
days: additionalData.days || 0,
reason: `[moderation] Got banned by ${user.user.tag} because of "${reason}"`
reason: '[moderation] ' + localize('moderation', 'banned-audit-log-reason', {
u: user.user.tag,
r: reason
})
});
}
break;
Expand All @@ -176,6 +180,34 @@ async function moderationAction(client, type, user, victim, reason, additionalDa
await moderationAction(client, moduleConfig['automod'][warns.length + 1].split(':')[0], {user: client.user}, victim, `[${localize('moderation', 'auto-mod')}]: ${localize('moderation', 'reached-warns', {w: warns.length + 1})}`, {roles: roles}, moduleConfig['automod'][warns.length + 1].includes(':') ? new Date(new Date().getTime() + durationParser(moduleConfig['automod'][warns.length + 1].split(':')[1])) : null);
}
break;
case 'channel-mute':
await additionalData.channel.permissionOverwrites.edit(victim, {SEND_MESSAGES: false}, {
reason: '[moderation] ' + localize('moderation', 'channelmute-audit-log-reason', {
u: user.user.tag,
r: reason
})
});
await victim.send(embedType(moduleStrings['channel_mute'], {
'%reason%': reason,
'%user%': user.user.tag,
'%channel%': additionalData.channel.toString()
})).catch(() => {
});
break;
case 'unchannel-mute':
await additionalData.channel.permissionOverwrites.delete(victim, {
reason: '[moderation] ' + localize('moderation', 'unchannelmute-audit-log-reason', {
u: user.user.tag,
r: reason
})
});
await victim.send(embedType(moduleStrings['remove-channel_mute'], {
'%reason%': reason,
'%user%': user.user.tag,
'%channel%': additionalData.channel.toString()
})).catch(() => {
});
break;
case 'unwarn':
break;
case 'unban':
Expand Down