-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ff1c89b
Showing
92 changed files
with
3,807 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Compiled class file | ||
*.class | ||
.gradle | ||
build/ | ||
bin/ | ||
target/ | ||
.idea/ | ||
.vscode/ | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
replay_pid* |
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,22 @@ | ||
# Luminia Discord Bot | ||
|
||
This Discord bot written for Minecraft server Luminia | ||
|
||
> [!IMPORTANT] | ||
> This bot is written for the Luminia server Discord in Java + Kotlin and is currently no longer supported | ||
## 🛠 Building the JAR File | ||
To build the project from source: | ||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/MEFRREEX/Luminia-Discord-Bot.git | ||
``` | ||
2. Navigate to the project directory: | ||
```bash | ||
cd Luminia-Discord-Bot | ||
``` | ||
3. Build the JAR file using Gradle: | ||
```bash | ||
gradle build | ||
``` | ||
The compiled artifact will be located in the `bot/build/libs` directory |
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,19 @@ | ||
plugins { | ||
kotlin("jvm") version "1.9.21" | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(21) | ||
} | ||
|
||
tasks.withType<Jar> { | ||
archiveFileName.set("Luminia-Discord-Bot-API-${project.version}.jar") | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
srcDirs("src/main/kotlin") | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
api/src/main/kotlin/com/luminia/discord/api/command/Command.kt
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 com.luminia.discord.api.command | ||
|
||
import com.luminia.discord.api.command.data.CommandData | ||
import net.dv8tion.jda.api.events.Event | ||
|
||
abstract class Command<T : Event> { | ||
|
||
abstract fun getCommandData(): CommandData | ||
|
||
abstract fun getCommandType(): CommandType | ||
|
||
abstract fun execute(event: T) | ||
} |
22 changes: 22 additions & 0 deletions
22
api/src/main/kotlin/com/luminia/discord/api/command/CommandManager.java
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,22 @@ | ||
package com.luminia.discord.api.command; | ||
|
||
import net.dv8tion.jda.api.JDA; | ||
import net.dv8tion.jda.api.events.interaction.command.GenericCommandInteractionEvent; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public interface CommandManager { | ||
|
||
JDA getJDA(); | ||
|
||
Map<CommandType, Map<String, Command<?>>> getCommands(); | ||
|
||
default Command<?> getCommand(CommandType type, String name) { | ||
return this.getCommands().getOrDefault(type, Collections.emptyMap()).get(name); | ||
} | ||
|
||
void register(Command<?>... command); | ||
|
||
void execute(Command<?> command, GenericCommandInteractionEvent event); | ||
} |
7 changes: 7 additions & 0 deletions
7
api/src/main/kotlin/com/luminia/discord/api/command/CommandType.java
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,7 @@ | ||
package com.luminia.discord.api.command; | ||
|
||
public enum CommandType { | ||
SLASH, | ||
MESSAGE, | ||
USER | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/main/kotlin/com/luminia/discord/api/command/MessageCommand.kt
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,10 @@ | ||
package com.luminia.discord.api.command | ||
|
||
import net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent | ||
|
||
abstract class MessageCommand : Command<MessageContextInteractionEvent>() { | ||
|
||
override fun getCommandType(): CommandType { | ||
return CommandType.MESSAGE | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/main/kotlin/com/luminia/discord/api/command/SlashCommand.kt
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,10 @@ | ||
package com.luminia.discord.api.command | ||
|
||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent | ||
|
||
abstract class SlashCommand : Command<SlashCommandInteractionEvent>() { | ||
|
||
override fun getCommandType(): CommandType { | ||
return CommandType.SLASH | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/main/kotlin/com/luminia/discord/api/command/UserCommand.kt
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,10 @@ | ||
package com.luminia.discord.api.command | ||
|
||
import net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent | ||
|
||
abstract class UserCommand : Command<UserContextInteractionEvent>() { | ||
|
||
override fun getCommandType(): CommandType { | ||
return CommandType.USER | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
api/src/main/kotlin/com/luminia/discord/api/command/data/CommandData.kt
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 @@ | ||
package com.luminia.discord.api.command.data | ||
|
||
import com.luminia.discord.api.command.permission.CommandPermission | ||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions | ||
import net.dv8tion.jda.api.interactions.commands.build.Commands | ||
import net.dv8tion.jda.api.interactions.commands.build.CommandData as JDACommandData | ||
|
||
interface CommandData { | ||
|
||
fun getJDACommandData(): JDACommandData | ||
|
||
fun getPermission(): CommandPermission | ||
|
||
fun setName(name: String): CommandData | ||
|
||
fun setDefaultPermissions(permission: DefaultMemberPermissions): CommandData | ||
|
||
fun setPermission(permission: CommandPermission): CommandData | ||
|
||
fun setGuildOnly(guildOnly: Boolean): CommandData | ||
|
||
fun setNSFW(nsfw: Boolean): CommandData | ||
|
||
companion object { | ||
|
||
fun slash(name: String, description: String): SlashCommandDataBuilder = SlashCommandDataBuilder(Commands.slash(name, description)) | ||
|
||
fun message(name: String): CommandDataBuilder = CommandDataBuilder(Commands.message(name)) | ||
|
||
fun context(name: String): CommandDataBuilder = CommandDataBuilder(Commands.user(name)) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
api/src/main/kotlin/com/luminia/discord/api/command/data/CommandDataBuilder.kt
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,39 @@ | ||
package com.luminia.discord.api.command.data | ||
|
||
import com.luminia.discord.api.command.permission.CommandPermission | ||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions | ||
import net.dv8tion.jda.api.interactions.commands.build.CommandData as JDACommandData | ||
|
||
open class CommandDataBuilder(private val jdaCommandData: JDACommandData) : CommandData { | ||
|
||
private var permission: CommandPermission = CommandPermission.DEFAULT | ||
|
||
override fun getJDACommandData(): JDACommandData = jdaCommandData | ||
|
||
override fun getPermission(): CommandPermission = permission | ||
|
||
override fun setName(name: String): CommandDataBuilder { | ||
jdaCommandData.setName(name) | ||
return this | ||
} | ||
|
||
override fun setDefaultPermissions(permission: DefaultMemberPermissions): CommandDataBuilder { | ||
jdaCommandData.setDefaultPermissions(permission) | ||
return this | ||
} | ||
|
||
override fun setPermission(permission: CommandPermission): CommandDataBuilder { | ||
this.permission = permission | ||
return this | ||
} | ||
|
||
override fun setGuildOnly(guildOnly: Boolean): CommandDataBuilder { | ||
jdaCommandData.setGuildOnly(guildOnly) | ||
return this | ||
} | ||
|
||
override fun setNSFW(nsfw: Boolean): CommandDataBuilder { | ||
jdaCommandData.setNSFW(nsfw) | ||
return this | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
api/src/main/kotlin/com/luminia/discord/api/command/data/SlashCommandData.kt
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,29 @@ | ||
package com.luminia.discord.api.command.data | ||
|
||
import net.dv8tion.jda.api.interactions.commands.OptionType | ||
import net.dv8tion.jda.api.interactions.commands.build.OptionData | ||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData | ||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData | ||
|
||
interface SlashCommandData : CommandData { | ||
|
||
fun setDescription(description: String): SlashCommandData | ||
|
||
fun addOptions(vararg options: OptionData): SlashCommandData | ||
|
||
fun addOptions(options: Collection<OptionData>): SlashCommandData | ||
|
||
fun addOption(type: OptionType, name: String, description: String, required: Boolean, autoComplete: Boolean): SlashCommandData | ||
|
||
fun addOption(type: OptionType, name: String, description: String, required: Boolean): SlashCommandData | ||
|
||
fun addOption(type: OptionType, name: String, description: String): SlashCommandData | ||
|
||
fun addSubcommands(vararg subcommands: SubcommandData): SlashCommandData | ||
|
||
fun addSubcommands(subcommands: Collection<SubcommandData>): SlashCommandData | ||
|
||
fun addSubcommandGroups(vararg groups: SubcommandGroupData): SlashCommandData | ||
|
||
fun addSubcommandGroups(groups: Collection<SubcommandGroupData>): SlashCommandData | ||
} |
66 changes: 66 additions & 0 deletions
66
api/src/main/kotlin/com/luminia/discord/api/command/data/SlashCommandDataBuilder.kt
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,66 @@ | ||
package com.luminia.discord.api.command.data | ||
|
||
import net.dv8tion.jda.api.interactions.commands.OptionType | ||
import net.dv8tion.jda.api.interactions.commands.build.OptionData | ||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData | ||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData | ||
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData as JDASlashCommandData | ||
|
||
class SlashCommandDataBuilder(private val jdaCommandData: JDASlashCommandData) : CommandDataBuilder(jdaCommandData), SlashCommandData { | ||
|
||
override fun setDescription(description: String): SlashCommandDataBuilder { | ||
jdaCommandData.setDescription(description) | ||
return this | ||
} | ||
|
||
override fun addOptions(vararg options: OptionData): SlashCommandDataBuilder { | ||
jdaCommandData.addOptions(*options) | ||
return this | ||
} | ||
|
||
override fun addOptions(options: Collection<OptionData>): SlashCommandDataBuilder { | ||
jdaCommandData.addOptions(options) | ||
return this | ||
} | ||
|
||
override fun addOption( | ||
type: OptionType, | ||
name: String, | ||
description: String, | ||
required: Boolean, | ||
autoComplete: Boolean | ||
): SlashCommandDataBuilder { | ||
jdaCommandData.addOption(type, name, description, required, autoComplete) | ||
return this | ||
} | ||
|
||
override fun addOption(type: OptionType, name: String, description: String, required: Boolean): SlashCommandDataBuilder { | ||
jdaCommandData.addOption(type, name, description, required) | ||
return this | ||
} | ||
|
||
override fun addOption(type: OptionType, name: String, description: String): SlashCommandDataBuilder { | ||
jdaCommandData.addOption(type, name, description) | ||
return this | ||
} | ||
|
||
override fun addSubcommands(vararg subcommands: SubcommandData): SlashCommandDataBuilder { | ||
jdaCommandData.addSubcommands(*subcommands) | ||
return this | ||
} | ||
|
||
override fun addSubcommands(subcommands: Collection<SubcommandData>): SlashCommandDataBuilder { | ||
jdaCommandData.addSubcommands(subcommands) | ||
return this | ||
} | ||
|
||
override fun addSubcommandGroups(vararg groups: SubcommandGroupData): SlashCommandDataBuilder { | ||
jdaCommandData.addSubcommandGroups(*groups) | ||
return this | ||
} | ||
|
||
override fun addSubcommandGroups(groups: Collection<SubcommandGroupData>): SlashCommandDataBuilder { | ||
jdaCommandData.addSubcommandGroups(groups) | ||
return this | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
api/src/main/kotlin/com/luminia/discord/api/command/permission/CommandPermission.kt
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,44 @@ | ||
package com.luminia.discord.api.command.permission | ||
|
||
import net.dv8tion.jda.api.Permission | ||
import net.dv8tion.jda.api.entities.Member | ||
import net.dv8tion.jda.api.entities.Role | ||
|
||
interface CommandPermission { | ||
|
||
fun defaultValue(): Boolean { | ||
return false | ||
} | ||
|
||
fun test(member: Member): Boolean | ||
|
||
companion object { | ||
|
||
fun role(roleId: Long): CommandPermission { | ||
return object : CommandPermission { | ||
override fun test(member: Member): Boolean { | ||
return member.roles.stream().anyMatch { role: Role -> role.idLong == roleId } | ||
} | ||
} | ||
} | ||
|
||
fun permission(permission: Permission?): CommandPermission { | ||
return object : CommandPermission { | ||
override fun test(member: Member): Boolean { | ||
return member.hasPermission(permission) | ||
} | ||
} | ||
} | ||
|
||
val DEFAULT: CommandPermission = object : CommandPermission { | ||
|
||
override fun defaultValue(): Boolean { | ||
return true; | ||
} | ||
|
||
override fun test(member: Member): Boolean { | ||
return true | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
api/src/main/kotlin/com/luminia/discord/api/handler/EventManager.java
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,16 @@ | ||
package com.luminia.discord.api.handler; | ||
|
||
import net.dv8tion.jda.api.events.GenericEvent; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Consumer; | ||
|
||
public interface EventManager { | ||
|
||
Map<Class<? extends GenericEvent>, Set<Consumer<GenericEvent>>> getHandlers(); | ||
|
||
void register(Object... listeners); | ||
|
||
void handle(GenericEvent event); | ||
} |
Oops, something went wrong.