Skip to content

Commit

Permalink
refactor: refactor some code
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmefox committed Jul 4, 2022
1 parent 0b3ec62 commit 06b3f40
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,9 @@ abstract class DiscordCommand(
subCommandElements.putIfAbsent(element.getName(), element)

if (element::class.isSubclassOf(DiscordSubCommand::class)) {
this.addSubcommands(element as DiscordSubCommand)
element as DiscordSubCommand
element.initCommandOptions()
this.addSubcommands(element)
}

if (element::class.isSubclassOf(DiscordSubCommandGroup::class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ abstract class DiscordSubCommand(name: String, description: String) : Subcommand

abstract fun execute(event: SlashCommandInteractionEvent, hook: InteractionHook?, command: DiscordCommand)

open fun initCommandOptions() {}

open fun onButtonInteraction(event: ButtonInteractionEvent): Boolean {
return true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class AdminSearchDataProvider(

val emojis = checkForEmoji(arg)
if (emojis != null && emojis.isNotEmpty()) {
event.replyChoices(emojis.map { net.dv8tion.jda.api.interactions.commands.Command.Choice(it.name + " (Emote) (${it.guild?.name ?: ""})", it.id) })
event.replyChoices(emojis.map { net.dv8tion.jda.api.interactions.commands.Command.Choice(it.name + " (Emote) (${it.guild.name})", it.id) })
.queue()
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class AdminSearchOverviewPage(
embedBuilder.addField("Name", discordEmote.name, true)
embedBuilder.addField("Mention", "`${discordEmote.formatted}`", true)
embedBuilder.addField("Time Created", discordEmote.timeCreated.toDiscordTimestamp(TimestampFormat.SHORT_DATE_TIME), true)
discordEmote.guild?.let { embedBuilder.addField("Server", "${it.name} (`${it.id}`)", false) }
discordEmote.guild.let { embedBuilder.addField("Server", "${it.name} (`${it.id}`)", false) }
embedBuilder.addField("Url", "`${discordEmote.imageUrl}`", false)
embedBuilder.addField(
"Is Animated",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,4 @@ class OnGenericEmojiEvent(source: Any, @Nonnull val event: GenericEmojiEvent) :
class OnGenericEmojiUpdateEvent(source: Any, @Nonnull val event: GenericEmojiUpdateEvent<*>) : ApplicationEvent(source)
class OnGenericPermissionOverrideEvent(source: Any, @Nonnull val event: GenericPermissionOverrideEvent) : ApplicationEvent(source)
class OnEvent(source: Any, @Nonnull val event: Event) : ApplicationEvent(source)
class OnModalInteractionEvent(source: Any, @Nonnull event: ModalInteractionEvent) : ApplicationEvent(source)
class OnModalInteractionEvent(source: Any, @Nonnull val event: ModalInteractionEvent) : ApplicationEvent(source)

0 comments on commit 06b3f40

Please sign in to comment.