Skip to content

Commit

Permalink
feat: add own NanoId port from java
Browse files Browse the repository at this point in the history
feat!: stream line component creation
chore!: remove gson from code base
  • Loading branch information
itsmefox committed Jul 11, 2022
1 parent c73cce6 commit 950aaf3
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 225 deletions.
8 changes: 1 addition & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group "io.viascom.discord.bot"
version "0.0.23_5.0.0-alpha.13"
version "0.0.24_5.0.0-alpha.13"

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -50,8 +50,6 @@ repositories {
ext {
jdaVersion = "5.0.0-alpha.13"
retrofitVersion = "2.9.0"
gsonVersion = "2.9.0"
gsonJavatimeVersion = "1.1.1"
jacksonSpringBootVersion = "2.7.1"
jacksonVersion = "2.13.3"
graalvmJsVersion = "22.1.0.1"
Expand Down Expand Up @@ -82,10 +80,6 @@ dependencies {
//====== JDA ======
api "net.dv8tion:JDA:$jdaVersion"

//====== Gson ======
compileOnly "com.google.code.gson:gson:$gsonVersion"
compileOnly "com.fatboyindustrial.gson-javatime-serialisers:gson-javatime-serialisers:$gsonJavatimeVersion"

//====== Jackson ======
implementation "org.springframework.boot:spring-boot-starter-json:$jacksonSpringBootVersion"
implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ import org.springframework.stereotype.Service
@ConditionalOnJdaEnabled
@ConditionalOnExpression("\${aluna.debug.enable-debug-configuration-log:true} && \${aluna.production-mode:false} == false")
class DebugInfoPrinter(
private val interactions: List<InteractionScopedObject>,
private val commands: List<DiscordCommand>,
private val contextMenus: List<DiscordContextMenu>,
private val alunaProperties: AlunaProperties,
private val ownerIdProvider: OwnerIdProvider,
private val moderatorIdProvider: ModeratorIdProvider
Expand All @@ -58,7 +59,7 @@ class DebugInfoPrinter(
###############################################
Configuration
-> interaction: ${interactions.size}
-> interaction: ${commands.size + contextMenus.size}
-> ownerIds: ${ownerIdProvider.getOwnerIds().joinToString { it.toString() }.ifBlank { "n/a" }}
-> modIds: ${moderatorIdProvider.getModeratorIds().joinToString { it.toString() }.ifBlank { "n/a" }}
-> applicationId: ${alunaProperties.discord.applicationId ?: "n/a"}
Expand All @@ -70,4 +71,4 @@ class DebugInfoPrinter(
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class GenerateEmojiEnumProvider(
rows.add(ActionRow.of(row1))

val row2 = arrayListOf<ItemComponent>()
row2.add(createDangerButton("cancel-remove", "Cancel"))
row2.add(dangerButton("cancel-remove", "Cancel"))
rows.add(ActionRow.of(row2))

return rows
Expand All @@ -112,8 +112,8 @@ class GenerateEmojiEnumProvider(
val rows = arrayListOf<ActionRow>()

val row1 = arrayListOf<ItemComponent>()
row1.add(createPrimaryButton("add", "Add Server"))
row1.add(createDangerButton("remove", "Remove Server", disabled = selectedServerIds.isEmpty()))
row1.add(primaryButton("add", "Add Server"))
row1.add(dangerButton("remove", "Remove Server", disabled = selectedServerIds.isEmpty()))
rows.add(ActionRow.of(row1))

val row2 = arrayListOf<ItemComponent>()
Expand All @@ -127,8 +127,8 @@ class GenerateEmojiEnumProvider(
rows.add(ActionRow.of(row2))

val row3 = arrayListOf<ItemComponent>()
row3.add(createDangerButton("cancel", "Cancel"))
row3.add(createSuccessButton("generate", "Generate File"))
row3.add(dangerButton("cancel", "Cancel"))
row3.add(successButton("generate", "Generate File"))
rows.add(ActionRow.of(row3))

return rows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class GenerateStickerEnumProvider(
rows.add(ActionRow.of(row1))

val row2 = arrayListOf<ItemComponent>()
row2.add(createDangerButton("cancel-remove", "Cancel"))
row2.add(dangerButton("cancel-remove", "Cancel"))
rows.add(ActionRow.of(row2))

return rows
Expand All @@ -112,8 +112,8 @@ class GenerateStickerEnumProvider(
val rows = arrayListOf<ActionRow>()

val row1 = arrayListOf<ItemComponent>()
row1.add(createPrimaryButton("add", "Add Server"))
row1.add(createDangerButton("remove", "Remove Server", disabled = selectedServerIds.isEmpty()))
row1.add(primaryButton("add", "Add Server"))
row1.add(dangerButton("remove", "Remove Server", disabled = selectedServerIds.isEmpty()))
rows.add(ActionRow.of(row1))

val row2 = arrayListOf<ItemComponent>()
Expand All @@ -127,8 +127,8 @@ class GenerateStickerEnumProvider(
rows.add(ActionRow.of(row2))

val row3 = arrayListOf<ItemComponent>()
row3.add(createDangerButton("cancel", "Cancel"))
row3.add(createSuccessButton("generate", "Generate File"))
row3.add(dangerButton("cancel", "Cancel"))
row3.add(successButton("generate", "Generate File"))
rows.add(ActionRow.of(row3))

return rows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import io.viascom.discord.bot.aluna.bot.command.SystemCommand
import io.viascom.discord.bot.aluna.bot.queueAndRegisterInteraction
import io.viascom.discord.bot.aluna.configuration.condition.ConditionalOnJdaEnabled
import io.viascom.discord.bot.aluna.configuration.condition.ConditionalOnSystemCommandEnabled
import io.viascom.discord.bot.aluna.util.createDangerButton
import io.viascom.discord.bot.aluna.util.createSuccessButton
import io.viascom.discord.bot.aluna.util.dangerButton
import io.viascom.discord.bot.aluna.util.getTypedOption
import io.viascom.discord.bot.aluna.util.removeActionRows
import io.viascom.discord.bot.aluna.util.successButton
import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.entities.Guild
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent
Expand Down Expand Up @@ -82,8 +82,8 @@ class LeaveServerProvider(
.setDescription("❓ Do you really want that this Bot leaves the server **${server.name}**?")
lastHook.editOriginalEmbeds(lastEmbed.build()).setActionRows(
ActionRow.of(
createDangerButton("yes", "Yes"),
createSuccessButton("no", "No")
dangerButton("yes", "Yes"),
successButton("no", "No")
)
).queueAndRegisterInteraction(lastHook, command, duration = Duration.ofMinutes(2))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import io.viascom.discord.bot.aluna.bot.command.SystemCommand
import io.viascom.discord.bot.aluna.bot.queueAndRegisterInteraction
import io.viascom.discord.bot.aluna.configuration.condition.ConditionalOnJdaEnabled
import io.viascom.discord.bot.aluna.configuration.condition.ConditionalOnSystemCommandEnabled
import io.viascom.discord.bot.aluna.util.createTextInput
import io.viascom.discord.bot.aluna.util.getTypedOption
import io.viascom.discord.bot.aluna.util.getValueAsString
import io.viascom.discord.bot.aluna.util.textInput
import net.dv8tion.jda.api.Permission
import net.dv8tion.jda.api.entities.GuildMessageChannel
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent
Expand Down Expand Up @@ -90,7 +90,7 @@ class PurgeMessagesProvider(
selectedChannel = channel

//Show modal
val amount: TextInput = createTextInput("amount", "Amount of messages", TextInputStyle.SHORT)
val amount: TextInput = textInput("amount", "Amount of messages", TextInputStyle.SHORT)

val modal: Modal = Modal.create("purge", "Purge")
.addActionRows(ActionRow.of(amount))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import io.viascom.discord.bot.aluna.bot.queueAndRegisterInteraction
import io.viascom.discord.bot.aluna.configuration.condition.ConditionalOnJdaEnabled
import io.viascom.discord.bot.aluna.configuration.condition.ConditionalOnSystemCommandEnabled
import io.viascom.discord.bot.aluna.model.Webhook
import io.viascom.discord.bot.aluna.util.createTextInput
import io.viascom.discord.bot.aluna.util.getGuildTextChannel
import io.viascom.discord.bot.aluna.util.getPrivateChannelByUser
import io.viascom.discord.bot.aluna.util.getValueAsString
import io.viascom.discord.bot.aluna.util.textInput
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
import net.dv8tion.jda.api.interactions.InteractionHook
Expand All @@ -58,9 +58,9 @@ class SendMessageProvider(

override fun execute(event: SlashCommandInteractionEvent, hook: InteractionHook?, command: SystemCommand) {
//Show modal
val serverId: TextInput = createTextInput("serverId", "Server ID (0 = current or if DM)", TextInputStyle.SHORT)
val channelId: TextInput = createTextInput("channelId", "Channel ID (0 = current, @<id> = for DM)", TextInputStyle.SHORT)
val message: TextInput = createTextInput("message", "Message", TextInputStyle.PARAGRAPH)
val serverId: TextInput = textInput("serverId", "Server ID (0 = current or if DM)", TextInputStyle.SHORT)
val channelId: TextInput = textInput("channelId", "Channel ID (0 = current, @<id> = for DM)", TextInputStyle.SHORT)
val message: TextInput = textInput("message", "Message", TextInputStyle.PARAGRAPH)

val modal: Modal = Modal.create("send_message", "Send Message")
.addActionRows(ActionRow.of(serverId), ActionRow.of(channelId), ActionRow.of(message))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,14 @@ class StatusChangerProvider(
activitySelect.addOption("Streaming", "streaming", isDefault = ("streaming" == activityId))
rows.add(ActionRow.of(activitySelect.build()))

val setTextButton = createPrimaryButton("set_text", "Set Text")
val setTextButton = primaryButton("set_text", "Set Text")
val save =
createSuccessButton(
successButton(
"save",
"Save",
disabled = ((activityId != "null" && activityText.isEmpty()) || (activityId == "streaming" && !Activity.isValidStreamingUrl(activityUrl)))
)
val cancel = createDangerButton("cancel", "Cancel")
val cancel = dangerButton("cancel", "Cancel")
rows.add(ActionRow.of(setTextButton, save, cancel))

return rows
Expand Down

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions src/main/kotlin/io/viascom/discord/bot/aluna/util/GsonUtil.kt

This file was deleted.

Loading

0 comments on commit 950aaf3

Please sign in to comment.