-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from ShindouMihou/1.0.0-beta
Forwarding into Beta [1.0.0-BETA]
- Loading branch information
Showing
151 changed files
with
4,967 additions
and
4,178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
plugins { | ||
id 'org.jetbrains.kotlin.jvm' version '1.9.10' | ||
id 'java' | ||
} | ||
|
||
group = 'pw.mihou' | ||
version = '1.0.0-beta' | ||
description = 'Nexus is the next-generation Javacord framework that aims to create Discord bots with less code, dynamic, more simplicity and beauty.' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'org.javacord:javacord:3.8.0' | ||
implementation 'org.slf4j:slf4j-api:2.0.3' | ||
testImplementation 'org.jetbrains.kotlin:kotlin-test' | ||
compileOnly 'com.google.code.findbugs:jsr305:3.0.2' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
kotlin { | ||
jvmToolchain { | ||
languageVersion.set(JavaLanguageVersion.of(17)) | ||
} | ||
compilerOptions { | ||
freeCompilerArgs.add('-Xjvm-default=all') | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package pw.mihou.nexus.features.command.validation.examples | ||
|
||
import pw.mihou.nexus.features.command.validation.OptionValidation | ||
import pw.mihou.nexus.features.command.validation.errors.ValidationError | ||
|
||
object OptionValidators { | ||
val PING_PONG_VALIDATOR = OptionValidation.create<String>( | ||
validator = { option -> option.equals("ping", ignoreCase = true) || option.equals("pong", ignoreCase = true) }, | ||
error = { ValidationError.create("❌ You must either use `ping` or `pong` as an answer!") }, | ||
// If you want to support optional values then you must add the line below. | ||
// requirements = OptionValidation.createRequirements { nonNull = null } | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package pw.mihou.nexus.features.command.validation.examples | ||
|
||
import org.javacord.api.interaction.SlashCommandOption | ||
import pw.mihou.nexus.features.command.facade.NexusCommand | ||
import pw.mihou.nexus.features.command.facade.NexusCommandEvent | ||
import pw.mihou.nexus.features.command.facade.NexusHandler | ||
|
||
object PingCommand: NexusHandler { | ||
val name = "ping" | ||
val description = "Does a ping-pong based on your answer." | ||
|
||
val options = NexusCommand.createOptions( | ||
SlashCommandOption.createStringOption("answer", "It must be either ping or pong!", true) | ||
) | ||
|
||
val validators = NexusCommand.createValidators( | ||
OptionValidators.PING_PONG_VALIDATOR.withCollector { event -> event.interaction.getArgumentStringValueByName("answer") } | ||
) | ||
|
||
override fun onEvent(event: NexusCommandEvent) { | ||
event.respondNowWith("Just kidding! Your answer didn't matter in the first place!") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package pw.mihou.nexus.features.command.router.example | ||
|
||
import org.javacord.api.interaction.SlashCommandOption | ||
import org.javacord.api.interaction.SlashCommandOptionType | ||
import pw.mihou.nexus.features.command.facade.NexusCommandEvent | ||
import pw.mihou.nexus.features.command.facade.NexusHandler | ||
import pw.mihou.nexus.features.command.router.SubcommandRouter | ||
|
||
object PingCommand: NexusHandler { | ||
private val name = "ping" | ||
private val description = "Pings and pongs!" | ||
|
||
private val options = listOf( | ||
SlashCommandOption.create(SlashCommandOptionType.SUB_COMMAND, "pong", "Performs a pong!"), | ||
SlashCommandOption.create(SlashCommandOptionType.SUB_COMMAND, "ping", "Performs a ping!") | ||
) | ||
|
||
private val router = SubcommandRouter.create { | ||
route("ping", PingSubcommand) | ||
route("pong", PongSubcommand) | ||
} | ||
|
||
override fun onEvent(event: NexusCommandEvent) = router.accept(event) { | ||
// Optionally you can add additional shared data such as this: | ||
event.store("message", "Ping pong! You can add stuff like this here!") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pw.mihou.nexus.features.command.router.example | ||
|
||
import org.javacord.api.interaction.SlashCommandInteractionOption | ||
import pw.mihou.nexus.features.command.facade.NexusCommandEvent | ||
import pw.mihou.nexus.features.command.router.types.Routeable | ||
|
||
object PingSubcommand: Routeable { | ||
override fun accept(event: NexusCommandEvent, option: SlashCommandInteractionOption) { | ||
val message = event["message", String::class.java] | ||
event.respondNowWith("Pong! $message") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pw.mihou.nexus.features.command.router.example | ||
|
||
import org.javacord.api.interaction.SlashCommandInteractionOption | ||
import pw.mihou.nexus.features.command.facade.NexusCommandEvent | ||
import pw.mihou.nexus.features.command.router.types.Routeable | ||
|
||
object PongSubcommand: Routeable { | ||
override fun accept(event: NexusCommandEvent, option: SlashCommandInteractionOption) { | ||
val message = event["message", String::class.java] | ||
event.respondNowWith("Ping! $message") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.