-
Notifications
You must be signed in to change notification settings - Fork 48
Created module status-roles #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d83c31f
Created module status-roles
hfgd123 312d8dd
This moment when ESLint just hates you
hfgd123 9ff55ef
Fixed changes suggested by SCDerox (now checking if state, removed ca…
hfgd123 c97de54
Made for loop better readable
hfgd123 079586d
removed exactly one space...
hfgd123 8ff6bd3
Now using separate removeRoles() function and added lines 22-23
hfgd123 626249c
Added comment for removeRoles()
hfgd123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": [] | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { | ||
hfgd123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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')); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"] | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.