Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ddivad195 committed Mar 29, 2024
2 parents 737ce23 + 25717ae commit 82b6499
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import java.util.*

group = "me.ddivad"
version = "3.1"
version = "3.2"
description = "A bot to add and maintain a symbol as a prefix or suffix in staff names.\n"

plugins {
Expand Down
6 changes: 3 additions & 3 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
| nick | LowerMemberArg, Theme, [Nickname] | Set a member's nickname |

## ReactionRole
| Commands | Arguments | Description |
|--------------------|-------------------------|------------------------------|
| createReactionRole | Roles, EmbedDescription | Create a reaction role embed |
| Commands | Arguments | Description |
|--------------------|------------------------------------------|------------------------------|
| createReactionRole | Roles, EmbedDescription, [AllowMultiple] | Create a reaction role embed |

## Utility
| Commands | Arguments | Description |
Expand Down
11 changes: 7 additions & 4 deletions src/main/kotlin/me/ddivad/hawk/commands/ReactionRoleCommands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import me.ddivad.hawk.dataclasses.Permissions
import me.ddivad.hawk.dataclasses.ReactionRole
import me.ddivad.hawk.embeds.createReactionRoleMenu
import me.ddivad.hawk.services.LoggingService
import me.jakejmattson.discordkt.arguments.BooleanArg
import me.jakejmattson.discordkt.arguments.EveryArg
import me.jakejmattson.discordkt.commands.commands
import me.jakejmattson.discordkt.dsl.edit
Expand All @@ -15,18 +16,20 @@ fun reactionRoleCommands(configuration: Configuration, loggingService: LoggingSe
slash("createReactionRole", "Create a reaction role embed", Permissions.ADMINISTRATOR) {
execute(
EveryArg("Roles", "Role IDs to be added. If using multiple roles, separate IDs with a space"),
EveryArg("EmbedDescription", "Text to be added to reaction role embed")
EveryArg("EmbedDescription", "Text to be added to reaction role embed"),
BooleanArg("AllowMultiple", "yes", "no", "Allow more than 1 role to be chosen. Defualts to yes").optional(true)
) {
val (roleIds, descriptionText) = args
val (roleIds, descriptionText, allowMultiple) = args
try {
val roles = roleIds.split(" ").map { guild.getRole(it.toSnowflake()) }
val guildConfig = configuration[guild.id] ?: return@execute
val roles = roleIds.split(" ").map { guild.getRole(it.toSnowflake()) }
val reactionRole = ReactionRole(
guildConfig.reactionRoles.size + 1,
descriptionText,
roles.map { it.id }.toMutableList(),
null,
channel.id
channel.id,
allowMultiple
)
reactionRole.messageId = respondMenu {
createReactionRoleMenu(discord, guild, reactionRole)
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/me/ddivad/hawk/dataclasses/Configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ data class ReactionRole(
val description: String,
val roles: MutableList<Snowflake>,
var messageId: Snowflake?,
val channel: Snowflake
val channel: Snowflake,
val allowMultiple: Boolean = true
)
13 changes: 10 additions & 3 deletions src/main/kotlin/me/ddivad/hawk/embeds/ReactionRole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@ suspend fun MenuBuilder.createReactionRoleMenu(discord: Discord, guild: Guild, r
}
buttons {
runBlocking {
reactionRole.roles.forEach {
val liveRole = guild.getRole(it)
reactionRole.roles.forEach { role ->
val liveRole = guild.getRole(role)

actionButton(liveRole.name, null) {
val member = guild.getMemberOrNull(this.user.id) ?: return@actionButton
if (!member.roles.toList().contains(liveRole)) {
if (!member.roleIds.contains(role)) {
if (!reactionRole.allowMultiple) {
reactionRole.roles.forEach { role ->
if (member.roleIds.contains(role)) {
member.removeRole(role)
}
}
}
member.addRole(liveRole.id, "Reaction button clicked")
respondEphemeral { content = "Assigned role ${liveRole.name}" }
loggingService.reactionRoleAdded(guild, member, liveRole)
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/bot.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Sat Apr 01 18:01:31 IST 2023
#Fri Mar 29 00:53:13 GMT 2024
name=Hawk
description=A bot to add and maintain a symbol as a prefix or suffix in staff names.\n
version=3.0.0-RC1
version=3.1
url=https\://github.com/the-programmers-hangout/Hawk/

0 comments on commit 82b6499

Please sign in to comment.