feat: add functionality to give role to users#25
Merged
Conversation
…-closed' to NON_BASELINE_FEATURES
wiktoriavh
requested changes
Nov 4, 2025
Comment on lines
+14
to
+20
| if (!guild) { | ||
| await interaction.reply({ | ||
| content: 'This command can only be used in a server.', | ||
| flags: MessageFlags.Ephemeral, | ||
| }); | ||
| return; | ||
| } |
Member
There was a problem hiding this comment.
idea for future: should add a custom function that does exactly this check.
hmd-ali
commented
Nov 5, 2025
Contributor
Author
There was a problem hiding this comment.
imo file names should be kebab-case
hmd-ali
commented
Nov 5, 2025
src/util/addRoleToUser.ts
Outdated
Comment on lines
22
to
40
| export async function addRoleToUser( | ||
| member: GuildMember, | ||
| role: Role, | ||
| interaction: ComponentInteraction | ||
| ) { | ||
| const hasRole = member.roles.cache.has(role.id); | ||
| if (hasRole) { | ||
| await interaction.reply({ | ||
| content: `You already have the ${role.name} role.`, | ||
| flags: MessageFlags.Ephemeral, | ||
| }); | ||
| } else { | ||
| await member.roles.add(role); | ||
| await interaction.reply({ | ||
| content: `You have been given the ${role.name} role!`, | ||
| flags: MessageFlags.Ephemeral, | ||
| }); | ||
| } | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This should handle only the the role part, i.e checking for the role we're assigning and adding it to the user. It should return a boolean that we can use to then handle what we want to do in the consuming file
in this case we would reply to the interaction.
wiktoriavh
previously approved these changes
Nov 12, 2025
wiktoriavh
approved these changes
Nov 16, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.