Skip to content

Commit

Permalink
Make the client ID and IPs command work the same way the user command…
Browse files Browse the repository at this point in the history
… works, change to show all CIDs
  • Loading branch information
MrPowerGamerBR committed Nov 16, 2024
1 parent d001b07 commit 1ea0b94
Showing 1 changed file with 17 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
override suspend fun execute(context: ApplicationCommandContext, args: SlashCommandArguments) {
context.deferChannelMessage(true)

// Because we did stuff in a... unconventional way, we will get all matched user arguments in a unconventional way: By getting all resolved objects!
val usersIds = args[options.userIds]
.replace(", ", "")
.split(" ")
Expand Down Expand Up @@ -153,10 +152,9 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap

context.reply(true) {
val messageContent = buildString {
val moreThanOneUsersMatches = matchedSameClientIds.filter { it.value.size > 1 }
if (moreThanOneUsersMatches.isNotEmpty()) {
appendLine("**Loritta Client IDs com múltiplos users:**")
for (matchedSameClientId in moreThanOneUsersMatches) {
if (matchedSameClientIds.isNotEmpty()) {
appendLine("**Loritta Client IDs:**")
for (matchedSameClientId in matchedSameClientIds) {
appendLine("- **${matchedSameClientId.key}:** ${matchedSameClientId.value.joinToString()}")
}
}
Expand All @@ -176,21 +174,17 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap

inner class DailyCheckByIpExecutor : LorittaSlashCommandExecutor() {
inner class Options : ApplicationCommandOptions() {
init {
// Register 25 different users
repeat(25) {
optionalString("ip${it + 1}", "IP para ver os dailies")
}
}
val ips = string("ips", "IP para ver os dailies")
}

override val options = Options()

override suspend fun execute(context: ApplicationCommandContext, args: SlashCommandArguments) {
context.deferChannelMessage(true)

// Because we did stuff in a... unconventional way, we will get all matched user arguments in a unconventional way: By getting all resolved objects!
val ips = context.event.options.map { it.asString }
val ips = args[options.ips]
.replace(", ", "")
.split(" ")

if (ips.isEmpty()) {
context.reply(true) {
Expand Down Expand Up @@ -281,10 +275,9 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
}
appendLine()
}
val moreThanOneUsersMatches = matchedSameClientIds.filter { it.value.size > 1 }
if (moreThanOneUsersMatches.isNotEmpty()) {
appendLine("**Loritta Client IDs com múltiplos users:**")
for (matchedSameClientId in moreThanOneUsersMatches) {
if (matchedSameClientIds.isNotEmpty()) {
appendLine("**Loritta Client IDs:**")
for (matchedSameClientId in matchedSameClientIds) {
appendLine("- **${matchedSameClientId.key}:** ${matchedSameClientId.value.joinToString()}")
}
}
Expand All @@ -304,12 +297,7 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap

inner class DailyCheckByLorittaClientIdExecutor : LorittaSlashCommandExecutor() {
inner class Options : ApplicationCommandOptions() {
init {
// Register 25 different users
repeat(25) {
optionalString("cid${it + 1}", "Client ID para ver os dailies")
}
}
val clientIds = string("cids", "Client IDs para ver os dailies")
}

override val options = Options()
Expand All @@ -318,7 +306,9 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
context.deferChannelMessage(true)

// Because we did stuff in a... unconventional way, we will get all matched user arguments in a unconventional way: By getting all resolved objects!
val clientIds = context.event.options.map { it.asString }
val clientIds = args[options.clientIds]
.replace(", ", "")
.split(" ")
.map { UUID.fromString(it) }

if (clientIds.isEmpty()) {
Expand Down Expand Up @@ -410,10 +400,9 @@ class DailyCheckCommand(val helper: LorittaHelper) : SlashCommandDeclarationWrap
}
appendLine()
}
val moreThanOneUsersMatches = matchedSameClientIds.filter { it.value.size > 1 }
if (moreThanOneUsersMatches.isNotEmpty()) {
appendLine("**Loritta Client IDs com múltiplos users:**")
for (matchedSameClientId in moreThanOneUsersMatches) {
if (matchedSameClientIds.isNotEmpty()) {
appendLine("**Loritta Client IDs:**")
for (matchedSameClientId in matchedSameClientIds) {
appendLine("- **${matchedSameClientId.key}:** ${matchedSameClientId.value.joinToString()}")
}
}
Expand Down

0 comments on commit 1ea0b94

Please sign in to comment.