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
4 changes: 4 additions & 0 deletions default-locales.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@
"all-users": "All Users",
"bots": "Bots",
"humans": "Humans"
},
"status-role": {
"fulfilled": "Status-role condition is fulfilled",
"not-fulfilled": "Status-role condition is no longer fulfilled"
}
}
}
33 changes: 33 additions & 0 deletions modules/status-roles/configs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"filename": "config.json",
"humanname-de": "Konfiguration",
"humanname-en": "Configuration",
"description-en": "Configure the function of the module here",
"description-de": "Stelle hier die Funktionen des Modules ein",
"content": [
{
"field_name": "words",
"humanname-en": "Words",
"humanname-de": "Statusinhalt",
"default": [],
"type": "array",
"content": "string",
"description-en": "Words users should have in their status.",
"description-de": "Wörter, die Nutzer in ihrem Status haben sollen.",
"params-de": {},
"default-de": []
},
{
"field_name": "roles",
"humanname-en": "Roles",
"humanname-de": "Rollen",
"default": [],
"type": "array",
"content": "roleID",
"description-en": "Roles to give to users with one of the words in their status",
"description-de": "Rollen, die an Nutzer mit einem der Wörter im Status vergeben werden sollen",
"params-de": {},
"default-de": []
}
]
}
36 changes: 36 additions & 0 deletions modules/status-roles/events/presenceUpdate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const {localize} = require('../../../src/functions/localize');

module.exports.run = async function (client, oldPresence, newPresence) {

if (!client.botReadyAt) return;
if (newPresence.member.guild.id !== client.guildID) return;
const moduleConfig = client.configurations['status-roles']['config'];
const roles = moduleConfig.roles;
const status = moduleConfig.words;
const member = newPresence.member;

if (newPresence.activities.length > 0) {
if (newPresence.activities[0].state) {
if (status.some(word => newPresence.activities[0].state.toLowerCase().includes(word.toLowerCase()))) {
return member.roles.add(roles, localize('status-role', 'fulfilled'));
} else {
removeRoles();
}
} else {
removeRoles();
}
} else {
removeRoles();
}

/**
* Removes the roles of an user who no longer fulfills the criteria
*/
function removeRoles() {
for (let i = 0; i < roles.length; i++) {
if (member.roles.cache.has(roles[i])) {
member.roles.remove(roles[i], localize('status-role', 'not-fulfilled'));
}
}
}
};
18 changes: 18 additions & 0 deletions modules/status-roles/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "status-roles",
"humanReadableName-de": "Status-Rollen",
"humanReadableName-en": "Status-roles",
"author": {
"name": "hfgd",
"link": "https://github.com/hfgd123",
"scnxOrgID": "2"
},
"openSourceURL": "https://github.com/hfgd123/CustomDCBot/tree/main/modules/status-roles",
"description-en": "Simple module to reward users who have an invite to your server in their status!",
"description-de": "Einfaches Modul, um Nutzer zu belohnen, die einen Link zu deinem Server in ihrem Status haben!",
"events-dir": "/events",
"config-example-files": [
"configs/config.json"
],
"tags": ["administration"]
}