Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0 #26

Merged
merged 54 commits into from
Mar 7, 2023
Merged
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f1e7014
Reformat command data
Goksi Jan 27, 2023
0928905
Adding support for subcommands
Goksi Jan 27, 2023
47cdaa3
Merge pull request #19 from Goksi/subcommands
Goksi Jan 27, 2023
64b7e5a
Merge pull request #20 from Goksi/main
Goksi Jan 27, 2023
548e54d
Update PteroBot.kt
Goksi Jan 28, 2023
dd89948
Merge branch 'v2.0' of https://github.com/Goksi/PteroBot into v2.0
Goksi Jan 28, 2023
0f52847
Link migrated
Goksi Jan 30, 2023
fe920bb
Unlink migrated
Goksi Jan 30, 2023
d892484
Register migrate
Goksi Jan 30, 2023
ef33857
Update AccountCommand.kt
Goksi Jan 31, 2023
6ad7fe8
Migrate node info
Goksi Jan 31, 2023
1f0200c
Text changes
Goksi Jan 31, 2023
ce22f9d
Refactoring
Goksi Feb 1, 2023
29963e7
Migrate node status
Goksi Feb 1, 2023
1839875
Implementing await PteroAction
Goksi Feb 1, 2023
47cfcd8
Merge pull request #21 from Goksi/PteroAction/await()
Goksi Feb 1, 2023
afe6f2b
Migrating servers command
Goksi Feb 1, 2023
16d78fe
Merge pull request #22 from Goksi/subcommands-migrate
Goksi Feb 1, 2023
74a54a2
Using await action
Goksi Feb 1, 2023
7eba3e9
hmm
Goksi Feb 4, 2023
0c4eca3
This should work
Goksi Feb 4, 2023
8b7789c
Adapting to new system
Goksi Feb 5, 2023
c974d11
chore: Lint
Goksi Feb 5, 2023
d7dacf7
New system
Goksi Feb 5, 2023
cc82ce3
Temp fix for multi event call, don't know cause yet
Goksi Feb 5, 2023
a4b32d0
SMH
Goksi Feb 5, 2023
5efedbd
Update NodeCommand.kt
Goksi Feb 5, 2023
8b9c695
Merge pull request #23 from Goksi/fix/abstraction
Goksi Feb 5, 2023
149b1e2
Parsing logic
Goksi Feb 5, 2023
1c0f1c4
chore: lint
Goksi Feb 5, 2023
47948e2
Migrating generics
Goksi Feb 5, 2023
9b90e0f
Node info migrate
Goksi Feb 6, 2023
649b5af
Node status migrate
Goksi Feb 6, 2023
3dcd59e
Server command migrate
Goksi Feb 6, 2023
1d2c7f2
Update server_list_command.yml
Goksi Feb 6, 2023
272183a
Update server_list.yml
Goksi Feb 6, 2023
d635cfe
server info migrate
Goksi Feb 6, 2023
53423d4
Shouldn't be list smh
Goksi Feb 7, 2023
7afb0ab
Null check
Goksi Feb 7, 2023
f2db86b
Adapting to new system
Goksi Feb 7, 2023
4b21292
Adapting
Goksi Feb 7, 2023
484d3d1
lint
Goksi Feb 7, 2023
9fef6b8
Merge pull request #24 from Goksi/json-to-yaml
Goksi Feb 7, 2023
a8bbbef
Update README.md
Goksi Feb 7, 2023
1ec841e
Typo
Goksi Mar 7, 2023
2ccf269
Update CooldownManager.kt
Goksi Mar 7, 2023
00f5f4d
Update PteroBot.kt
Goksi Mar 7, 2023
3d2b78a
Migrated embed from server list to account info command
Goksi Mar 7, 2023
d300b79
Lint
Goksi Mar 7, 2023
6d2d377
Merge pull request #25 from Goksi/account-info-command
Goksi Mar 7, 2023
7ca47a7
Readme update some of images
Goksi Mar 7, 2023
77d54ef
Update AccountCommand.kt
Goksi Mar 7, 2023
a212530
Update README.md
Goksi Mar 7, 2023
1fb6032
Update README.md
Goksi Mar 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
New system
  • Loading branch information
Goksi committed Feb 5, 2023
commit d7dacf76971b3c35d1700eb281f7fa5a0fc7c6ba
Original file line number Diff line number Diff line change
@@ -2,30 +2,35 @@ package tech.goksi.pterobot.commands.manager

import net.dv8tion.jda.api.JDA
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData
import tech.goksi.pterobot.commands.manager.abs.SimpleCommand
import tech.goksi.pterobot.commands.manager.abs.CommandBase
import tech.goksi.pterobot.commands.manager.abs.StandaloneCommand
import tech.goksi.pterobot.commands.manager.abs.TopLevelCommand

class SimpleCommandData {
private val commands: MutableList<SimpleCommand>
private val commands: MutableList<CommandBase>

init {
commands = ArrayList()
}

fun addCommands(vararg commands: SimpleCommand) {
fun addCommands(vararg commands: CommandBase) {
this.commands.addAll(commands)
}

fun buildData(): List<SlashCommandData> {
val data: MutableList<SlashCommandData> = ArrayList()
for (command in this.commands) {
data.add(command.buildCommand())
if (command is TopLevelCommand) data.add(command.buildCommand()) // TODO: this is quite a shitty
else if (command is StandaloneCommand) data.add(command.buildCommand())
}
return data
}

fun registerListeners(jda: JDA) {
commands.forEach {
jda.addEventListener(it)
if (it is TopLevelCommand) {
it.subcommands.forEach(jda::addEventListener)
} else jda.addEventListener(it)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
package tech.goksi.pterobot.commands.manager.abs

import net.dv8tion.jda.api.events.GenericEvent
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
import net.dv8tion.jda.api.hooks.EventListener
import net.dv8tion.jda.api.interactions.commands.build.OptionData
import tech.goksi.pterobot.events.hook.CoroutineListenerAdapter

abstract class ExecutableCommand(
override val name: String,
val description: String,
val options: List<OptionData>
) : CommandBase, EventListener {
) : CoroutineListenerAdapter(), CommandBase {

abstract fun execute(slashEvent: SlashCommandInteractionEvent)
abstract suspend fun execute(event: SlashCommandInteractionEvent)

open fun shouldExecute(slashEvent: SlashCommandInteractionEvent): Boolean {
return name == slashEvent.name
open fun shouldExecute(event: SlashCommandInteractionEvent): Boolean {
return name == event.name
}

override fun onEvent(genericEvent: GenericEvent) {
if (genericEvent is SlashCommandInteractionEvent) {
onSlashCommandInteraction(genericEvent)
override suspend fun onSlashCommandInteraction(event: SlashCommandInteractionEvent) {
if (shouldExecute(event)) {
execute(event)
}
}

private fun onSlashCommandInteraction(slashEvent: SlashCommandInteractionEvent) {
if (shouldExecute(slashEvent)) {
execute(slashEvent)
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ abstract class SimpleSubcommand(
private val baseCommand: String
) : ExecutableCommand(name, description, options) {

override fun shouldExecute(slashEvent: SlashCommandInteractionEvent): Boolean {
return "$baseCommand $name" == slashEvent.fullCommandName
override fun shouldExecute(event: SlashCommandInteractionEvent): Boolean {
return "$baseCommand $name" == event.fullCommandName
}

fun buildSubcommand(): SubcommandData {