-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add functionality to give role to users #25
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
Conversation
…-closed' to NON_BASELINE_FEATURES
| if (!guild) { | ||
| await interaction.reply({ | ||
| content: 'This command can only be used in a server.', | ||
| flags: MessageFlags.Ephemeral, | ||
| }); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idea for future: should add a custom function that does exactly this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo file names should be kebab-case
src/util/addRoleToUser.ts
Outdated
| 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, | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
No description provided.