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
5 changes: 4 additions & 1 deletion locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,10 @@
"all-users": "Alle Mitglieder",
"bots": "Bots",
"humans": "Mitglieder (keine Bots)",
"add-subcommand-description": "Füge eine Rolle zu allen Mitgliedern hinzu"
"add-subcommand-description": "Füge eine Rolle zu allen Mitgliedern hinzu",
"not-admin": "⚠️ Um diesen Befehl zu verwenden musst du zur adminRoles option im SCNX-Dashboard hinzugefügt werden. Falls du der Eigentümer dieses Bots bist, denk daran in deinen Servereinstellungen ebenfalls einen entsprechenden Override einzustellen um Missbrauch dieses Commands zu verhindern.",
"add-reason": "Massen-Rollenvergabe durch %u",
"remove-reason": "Massen-Rollenentfernung durch %u"
},
"hunt-the-code": {
"display-name-description": "Name des Codes, der dem Mitglied angezeigt wird, wenn er den Code einlöst",
Expand Down
5 changes: 4 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,10 @@
"target-option-description": "Determines whether bots should be included or not",
"all-users": "All Users",
"bots": "Bots",
"humans": "Humans"
"humans": "Humans",
"not-admin": "⚠️ To use this command, you need to be added to the adminRoles option in the SCNX-Dashboard. If you are the owner of this bot please remember to create an override in the guild settings to prevent abuse of this command.",
"add-reason": "Mass role addition by %u",
"remove-reason": "Mass role removal by %u"
},
"twitch-notifications": {
"channel-not-found": "Channel with ID %c could not be found",
Expand Down
27 changes: 18 additions & 9 deletions modules/massrole/commands/massrole.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ const {embedType} = require('../../../src/functions/helpers');
let target;
let failed;

module.exports.beforeSubcommand = async function(interaction) {
if (interaction.member.roles.cache.filter(m => interaction.client.configurations['massrole']['config'].adminRoles.includes(m.id)).size === 0) {
return interaction.reply({ephemeral: true, content: localize('massrole', 'not-admin')});
}
};

module.exports.subcommands = {
'add': async function (interaction) {
if (interaction.replied) return;
const moduleStrings = interaction.client.configurations['massrole']['strings'];
checkTarget(interaction);
if (target === 'all') {
await interaction.deferReply({ ephemeral: true });
for (const member of interaction.guild.members.cache.values()) {
try {
await member.roles.add(interaction.options.getRole('role'));
await member.roles.add(interaction.options.getRole('role'), localize('massrole', 'add-reason', {u: interaction.user.tag}));
} catch (e) {
failed++;
}
Expand All @@ -27,7 +34,7 @@ module.exports.subcommands = {
for (const member of interaction.guild.members.cache.values()) {
if (member.user.bot) {
try {
await member.roles.add(interaction.options.getRole('role'));
await member.roles.add(interaction.options.getRole('role'), localize('massrole', 'add-reason', {u: interaction.user.tag}));
} catch (e) {
failed++;
}
Expand All @@ -46,7 +53,7 @@ module.exports.subcommands = {
if (!member.user.bot) {
try {

await member.roles.add(interaction.options.getRole('role'));
await member.roles.add(interaction.options.getRole('role'), localize('massrole', 'add-reason', {u: interaction.user.tag}));
} catch (e) {
failed++;
}
Expand All @@ -62,13 +69,14 @@ module.exports.subcommands = {
}
},
'remove': async function (interaction) {
if (interaction.replied) return;
const moduleStrings = interaction.client.configurations['massrole']['strings'];
checkTarget(interaction);
if (target === 'all') {
await interaction.deferReply({ ephemeral: true });
for (const member of interaction.guild.members.cache.values()) {
try {
await member.roles.remove(interaction.options.getRole('role'));
await member.roles.remove(interaction.options.getRole('role'), localize('massrole', 'remove-reason', {u: interaction.user.tag}));
} catch (e) {
failed++;
}
Expand All @@ -86,7 +94,7 @@ module.exports.subcommands = {
for (const member of interaction.guild.members.cache.values()) {
if (member.user.bot) {
try {
await member.roles.remove(interaction.options.getRole('role'));
await member.roles.remove(interaction.options.getRole('role'), localize('massrole', 'remove-reason', {u: interaction.user.tag}));
} catch (e) {
failed++;
}
Expand All @@ -106,7 +114,7 @@ module.exports.subcommands = {
if (member.manageable) {
if (!member.user.bot) {
try {
await member.roles.remove(interaction.options.getRole('role'));
await member.roles.remove(interaction.options.getRole('role'), localize('massrole', 'remove-reason', {u: interaction.user.tag}));
} catch (e) {
failed++;
}
Expand All @@ -123,13 +131,14 @@ module.exports.subcommands = {
}
},
'remove-all': async function (interaction) {
if (interaction.replied) return;
const moduleStrings = interaction.client.configurations['massrole']['strings'];
checkTarget(interaction);
if (target === 'all') {
await interaction.deferReply({ ephemeral: true });
for (const member of interaction.guild.members.cache.values()) {
try {
await member.roles.remove(member.roles.cache.filter(role => !role.managed));
await member.roles.remove(member.roles.cache.filter(role => !role.managed), localize('massrole', 'remove-reason', {u: interaction.user.tag}));
} catch (e) {
failed++;
}
Expand All @@ -146,7 +155,7 @@ module.exports.subcommands = {
if (member.manageable) {
if (member.user.bot) {
try {
await member.roles.remove(member.roles.cache.filter(role => !role.managed));
await member.roles.remove(member.roles.cache.filter(role => !role.managed), localize('massrole', 'remove-reason', {u: interaction.user.tag}));
} catch (e) {
failed++;
}
Expand All @@ -165,7 +174,7 @@ module.exports.subcommands = {
if (member.manageable) {
if (!member.user.bot) {
try {
await member.roles.remove(member.roles.cache.filter(role => !role.managed));
await member.roles.remove(member.roles.cache.filter(role => !role.managed), localize('massrole', 'remove-reason', {u: interaction.user.tag}));
} catch (e) {
failed++;
}
Expand Down
40 changes: 40 additions & 0 deletions modules/massrole/configs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"description": {
"en": "Configure the function of the module here",
"de": "Stelle hier die Funktionen des Modules ein"
},
"humanName": {
"en": "Configuration",
"de": "Konfiguration"
},
"filename": "config.json",
"commandsWarnings": {
"special": [
{
"name": "/massrole",
"info": {
"en": "You need to first set the permissions in your server settings for this command and after that add them under \"adminRoles\" here.",
"de": "Du musst zuerst die Rechte in deinen Server-Einstellungen einstellen und danach diese unter \"AdminRollen\" hinzufügen."
}
}
]
},
"content": [
{
"name": "adminRoles",
"humanName": {
"de": "Adminrollen"
},
"default": {
"en": [],
"de": []
},
"description": {
"en": "Every role that can use the massrole command",
"de": "Jede Rolle, welche den Massrole command verwenden kann"
},
"type": "array",
"content": "roleID"
}
]
}
1 change: 1 addition & 0 deletions modules/massrole/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"openSourceURL": "https://github.com/hfgd123/CustomDCBot/tree/main/modules/massrole",
"commands-dir": "/commands",
"config-example-files": [
"configs/config.json",
"configs/strings.json"
],
"tags": [
Expand Down