├── gradle.properties ├── settings.gradle.kts ├── .gitattributes ├── img └── Discord_Vk6UUOMmbq.png ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── src └── main │ ├── resources │ └── simplelogger.properties │ └── kotlin │ └── net │ └── axay │ └── blaubot │ ├── config │ ├── data │ │ └── DiscordApplication.kt │ └── ConfigManager.kt │ ├── Values.kt │ ├── commands │ ├── api │ │ ├── SlashCommand.kt │ │ └── CommandRegistry.kt │ └── implementation │ │ ├── Contribute.kt │ │ ├── Bingus.kt │ │ ├── Ping.kt │ │ ├── Fox.kt │ │ ├── GithubProfile.kt │ │ ├── PlayerSkin.kt │ │ ├── Floppa.kt │ │ ├── Sogga.kt │ │ ├── ChatCommand.kt │ │ ├── Dice.kt │ │ ├── AnimeSearch.kt │ │ └── RandomAnime.kt │ └── Manager.kt ├── docker-compose.yml ├── Dockerfile ├── readme.md ├── gradlew.bat └── gradlew /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "BlauBot" 2 | 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /img/Discord_Vk6UUOMmbq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakobkmar/BlauBot/HEAD/img/Discord_Vk6UUOMmbq.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle 2 | .gradle/ 3 | build/ 4 | 5 | # IDE 6 | .idea/ 7 | 8 | # Secret 9 | config/ 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jakobkmar/BlauBot/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/main/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | #org.slf4j.simpleLogger.defaultLogLevel=trace 2 | org.slf4j.simpleLogger.logFile=System.out 3 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/config/data/DiscordApplication.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.config.data 2 | 3 | class DiscordApplication( 4 | val token: String? = null 5 | ) 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | 3 | blaubot: 4 | image: bluefireoly/blaubot:latest 5 | restart: unless-stopped 6 | volumes: 7 | - ./config:/app/config/ 8 | 9 | watchtower: 10 | image: containrrr/watchtower 11 | volumes: 12 | - /var/run/docker.sock:/var/run/docker.sock 13 | command: --interval 120 14 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/Values.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot 2 | 3 | import kotlinx.serialization.json.Json 4 | 5 | object Values { 6 | val jsonInstance = Json { 7 | ignoreUnknownKeys = true 8 | isLenient = true 9 | encodeDefaults = false 10 | allowSpecialFloatingPointValues = true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG BUILD_DIR="/usr/src/BlauBot/" 2 | 3 | 4 | FROM openjdk:11-slim AS builder 5 | 6 | ARG BUILD_DIR 7 | 8 | WORKDIR $BUILD_DIR 9 | COPY . . 10 | RUN chmod +x ./gradlew 11 | RUN ./gradlew installDist --no-daemon 12 | 13 | 14 | FROM openjdk:11-jre-slim 15 | 16 | ARG BUILD_DIR 17 | 18 | WORKDIR /app/ 19 | COPY --from=builder $BUILD_DIR/build/install/BlauBot/ . 20 | 21 | CMD ["./bin/BlauBot"] 22 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # BlauBot 2 | 3 | ![](img/Discord_Vk6UUOMmbq.png) 4 | 5 | Er ist sehr schlau! (und cool) 6 | 7 | Invite him to your server: [Invite](https://discord.com/api/oauth2/authorize?client_id=738532931038871622&permissions=8&scope=applications.commands%20bot) 8 | 9 | If you want to change the behaviour of the bot or add your own feature, feel free to do so. Just create a pull request - the bot will update automatically thanks to CI/CD. 10 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/config/ConfigManager.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.config 2 | 3 | import com.typesafe.config.ConfigFactory 4 | import io.github.config4k.extract 5 | import net.axay.blaubot.config.data.DiscordApplication 6 | import java.io.File 7 | 8 | object ConfigManager { 9 | class ConfigFile(path: String) : File(path) { 10 | init { 11 | if (!parentFile.exists()) parentFile.mkdirs() 12 | if (!exists()) createNewFile() 13 | } 14 | } 15 | 16 | val discordApplication = 17 | ConfigFactory.parseFile(ConfigFile("./config/discordApplication.conf")).extract() 18 | } 19 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/api/SlashCommand.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.api 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.entity.interaction.CommandInteraction 5 | import dev.kord.core.entity.interaction.InteractionCommand 6 | import dev.kord.rest.builder.interaction.ApplicationCommandCreateBuilder 7 | 8 | @KordPreview 9 | abstract class SlashCommand( 10 | val name: String, 11 | val description: String, 12 | val builder: ApplicationCommandCreateBuilder.() -> Unit = { }, 13 | val test: Boolean = false, 14 | ) { 15 | init { 16 | @Suppress("LeakingThis") 17 | CommandRegistry.registeredCommands[name] = this 18 | } 19 | 20 | abstract suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) 21 | } 22 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/Contribute.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import net.axay.blaubot.commands.api.SlashCommand 8 | 9 | @KordPreview 10 | object Contribute : SlashCommand( 11 | "contribute", 12 | "Shows you how you can contribute to the bot" 13 | ) { 14 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 15 | interaction.acknowledgePublic().followUp { 16 | content = "Go to the following GitHub repository to contribute to the bot. A contribution can be a whole new command or feature, but also an issue or feature request (if you cannot code). https://github.com/bluefireoly/BlauBot" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/Bingus.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import dev.kord.rest.builder.interaction.embed 8 | import net.axay.blaubot.commands.api.SlashCommand 9 | 10 | @KordPreview 11 | object Bingus : SlashCommand( 12 | "bingus", 13 | "Shows bingus to you" 14 | ) { 15 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 16 | interaction.acknowledgePublic().followUp { 17 | embed { 18 | title = "Bingus" 19 | image = "https://i.kym-cdn.com/photos/images/newsfeed/001/920/524/12f.jpg" 20 | description = "An internet meme of a Sphynx cat, this cat has come to be known as ‘Bingus’" 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/Ping.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import dev.kord.x.emoji.Emojis 8 | import net.axay.blaubot.commands.api.SlashCommand 9 | import kotlin.random.Random 10 | 11 | @KordPreview 12 | object Ping : SlashCommand( 13 | "ping", 14 | "Play table tennis with the bot" 15 | ) { 16 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 17 | val peng = Random.nextInt(6) == 1 18 | interaction.acknowledgePublic().followUp { 19 | content = if (peng) "Peng!" else "${Emojis.pingPong}" 20 | } 21 | if (peng) 22 | interaction.channel.createMessage("${Emojis.fullMoonWithFace}${Emojis.gun}") 23 | else 24 | interaction.channel.createMessage("Pong! ${Emojis.grinning}") 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/Fox.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import io.ktor.client.request.* 8 | import kotlinx.coroutines.Dispatchers 9 | import kotlinx.coroutines.withContext 10 | import kotlinx.serialization.Serializable 11 | import net.axay.blaubot.commands.api.SlashCommand 12 | import net.axay.blaubot.ktorClient 13 | 14 | @KordPreview 15 | object Fox : SlashCommand( 16 | "fox", 17 | "Shows a cool fox for your enjoyment" 18 | ) { 19 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 20 | interaction.acknowledgePublic().followUp { 21 | content = withContext(Dispatchers.IO) { 22 | ktorClient.get("https://randomfox.ca/floof/").image 23 | } 24 | } 25 | } 26 | 27 | @Serializable 28 | private data class RandomFox(val image: String, val link: String) 29 | } 30 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/Manager.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.Kord 5 | import io.ktor.client.* 6 | import io.ktor.client.engine.cio.* 7 | import io.ktor.client.features.json.* 8 | import io.ktor.client.features.json.serializer.* 9 | import net.axay.blaubot.commands.api.CommandRegistry 10 | import net.axay.blaubot.commands.implementation.* 11 | import net.axay.blaubot.config.ConfigManager 12 | 13 | val ktorClient = HttpClient(CIO) { 14 | install(JsonFeature) { 15 | serializer = KotlinxSerializer(Values.jsonInstance) 16 | } 17 | } 18 | 19 | @KordPreview 20 | suspend fun main() { 21 | val token = ConfigManager.discordApplication.token 22 | ?: error("Configure the application before running it") 23 | 24 | val bot = Kord(token) 25 | 26 | Sogga 27 | AnimeSearch 28 | Bingus 29 | ChatCommand 30 | Contribute 31 | Dice 32 | Floppa 33 | Fox 34 | Ping 35 | PlayerSkin 36 | RandomAnime 37 | GithubProfile 38 | 39 | CommandRegistry.applyToBot(bot) 40 | 41 | println("Logging in...") 42 | 43 | bot.login() 44 | } 45 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/GithubProfile.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import dev.kord.core.entity.interaction.string 8 | import dev.kord.rest.builder.interaction.embed 9 | import net.axay.blaubot.commands.api.SlashCommand 10 | 11 | @KordPreview 12 | object GithubProfile : SlashCommand( 13 | "githubprofile", 14 | "Shows you the profile of a given user", 15 | { 16 | string("user", "The name of the user") 17 | } 18 | ) { 19 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 20 | interaction.acknowledgePublic().followUp { 21 | embed { 22 | val user = command.options["user"]?.string().orEmpty() 23 | title = user 24 | description = "This is the profile of $user" 25 | image = "https://api.vollkorn.me/githubUser/?user=$user" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/PlayerSkin.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import dev.kord.core.entity.interaction.string 8 | import dev.kord.rest.builder.interaction.embed 9 | import net.axay.blaubot.commands.api.SlashCommand 10 | 11 | @KordPreview 12 | object PlayerSkin : SlashCommand( 13 | "playerskin", 14 | "Shows you the skin of the given player", 15 | { 16 | string("playername", "The name of the player") 17 | } 18 | ) { 19 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 20 | interaction.acknowledgePublic().followUp { 21 | embed { 22 | val playerName = command.options["playername"]?.string().orEmpty() 23 | title = playerName 24 | description = "This is the skin of $playerName" 25 | image = "https://minecraftskinstealer.com/api/v1/skin/render/fullbody/$playerName/700" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/Floppa.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import dev.kord.rest.builder.interaction.embed 8 | import net.axay.blaubot.commands.api.SlashCommand 9 | 10 | @KordPreview 11 | object Floppa : SlashCommand( 12 | "floppa", 13 | "Shows floppa to you" 14 | ) { 15 | private val floppaImages = listOf( 16 | "https://media.tenor.com/images/40401b6421797ab623387168d8ecc88d/tenor.gif", 17 | "https://media.tenor.com/images/8f4b75ce9292825efa37a66ba85f3335/tenor.gif", 18 | "https://media.tenor.com/images/09f2bba19bd9615695b856c0f1235a36/tenor.gif", 19 | ) 20 | 21 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 22 | interaction.acknowledgePublic().followUp { 23 | embed { 24 | title = "Floppa" 25 | image = floppaImages.random() 26 | description = "This is floppa. Some people even say that he is better than bingus." 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/Sogga.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import dev.kord.rest.builder.interaction.embed 8 | import net.axay.blaubot.commands.api.SlashCommand 9 | 10 | @KordPreview 11 | object Sogga : SlashCommand( 12 | "sogga", 13 | "Shows sogga to you", 14 | ) { 15 | private val soggaImages = listOf( 16 | "https://i.kym-cdn.com/entries/icons/original/000/036/896/soggacover.jpg", 17 | "https://media1.tenor.com/images/4c771b4cd0aaedbedb6e87cd6feaaf3d/tenor.gif", 18 | "https://static.wikia.nocookie.net/floppapedia-revamped/images/6/6c/Obraz_2021-02-15_135626.webp/revision/latest/top-crop/width/360/height/450?cb=20210224164127" 19 | ) 20 | 21 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 22 | interaction.acknowledgePublic().followUp { 23 | embed { 24 | title = "Sogga" 25 | image = soggaImages.random() 26 | description = "Sogga is an extension meme of Floppa. Both characters are often used in the same way." 27 | } 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/ChatCommand.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.common.entity.Permission 5 | import dev.kord.core.behavior.interaction.followUp 6 | import dev.kord.core.behavior.interaction.followUpEphemeral 7 | import dev.kord.core.entity.interaction.CommandInteraction 8 | import dev.kord.core.entity.interaction.InteractionCommand 9 | import dev.kord.core.entity.interaction.string 10 | import net.axay.blaubot.commands.api.SlashCommand 11 | 12 | @KordPreview 13 | object ChatCommand : SlashCommand( 14 | "chat", 15 | "Allows you to chat via the bot", 16 | { 17 | string("message", "The message which should be send") 18 | } 19 | ) { 20 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 21 | val isAdmin = interaction.user.asMemberOrNull(interaction.data.guildId.value ?: return) 22 | ?.getPermissions()?.contains(Permission.Administrator) == true 23 | 24 | if (isAdmin) { 25 | val message = command.options["message"]?.string().orEmpty() 26 | 27 | val response = interaction.acknowledgePublic() 28 | response.followUp { 29 | content = message 30 | }.delete() 31 | 32 | interaction.channel.createMessage(message) 33 | } else { 34 | interaction.acknowledgeEphemeral().followUpEphemeral { content = "Insufficient permissions" } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/Dice.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.channel.createEmbed 5 | import dev.kord.core.behavior.interaction.followUp 6 | import dev.kord.core.entity.interaction.CommandInteraction 7 | import dev.kord.core.entity.interaction.InteractionCommand 8 | import dev.kord.rest.builder.interaction.embed 9 | import dev.kord.x.emoji.Emojis 10 | import kotlinx.coroutines.delay 11 | import net.axay.blaubot.commands.api.SlashCommand 12 | 13 | @KordPreview 14 | object Dice : SlashCommand( 15 | "dice", 16 | "Rolls a random number for you" 17 | ) { 18 | private val numberEmojis = listOf( 19 | Emojis.one, 20 | Emojis.two, 21 | Emojis.three, 22 | Emojis.four, 23 | Emojis.five, 24 | Emojis.six, 25 | ) 26 | 27 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 28 | val ack = interaction.acknowledgePublic() 29 | 30 | val loadingImg = interaction.channel.createEmbed { 31 | image = "https://www.animierte-gifs.net/data/media/710/animiertes-wuerfel-bild-0104.gif" 32 | } 33 | 34 | delay(2000) 35 | 36 | loadingImg.delete() 37 | 38 | ack.followUp { 39 | embed { 40 | title = "You rolled the dice" 41 | field { 42 | name = "Result" 43 | value = "${Emojis.flushed} ${Emojis.pointRight} ${numberEmojis.random()}" 44 | } 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/api/CommandRegistry.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.api 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.common.entity.Snowflake 5 | import dev.kord.core.Kord 6 | import dev.kord.core.behavior.createApplicationCommand 7 | import dev.kord.core.entity.interaction.CommandInteraction 8 | import dev.kord.core.event.interaction.InteractionCreateEvent 9 | import dev.kord.core.on 10 | import kotlinx.coroutines.coroutineScope 11 | import kotlinx.coroutines.flow.collect 12 | import kotlinx.coroutines.launch 13 | 14 | @KordPreview 15 | object CommandRegistry { 16 | val registeredCommands = HashMap() 17 | 18 | suspend fun applyToBot(kord: Kord) = coroutineScope { 19 | for ((_, slashCommand) in registeredCommands) { 20 | if (!slashCommand.test) 21 | kord.createGlobalApplicationCommand(slashCommand.name, slashCommand.description, slashCommand.builder) 22 | } 23 | launch { 24 | kord.globalCommands.collect { 25 | if (!registeredCommands.containsKey(it.name) || registeredCommands[it.name]?.test == true) 26 | it.delete() 27 | } 28 | } 29 | println("Set up global commands") 30 | 31 | val testguild = kord.getGuild(Snowflake(738122976280707125)) 32 | if (testguild != null) { 33 | for ((_, slashCommand) in registeredCommands) { 34 | if (slashCommand.test) 35 | testguild.createApplicationCommand(slashCommand.name, slashCommand.description, slashCommand.builder) 36 | } 37 | launch { 38 | testguild.commands.collect { 39 | if (!registeredCommands.containsKey(it.name) || registeredCommands[it.name]?.test == false) 40 | it.delete() 41 | } 42 | } 43 | println("Set up test guild") 44 | } 45 | 46 | kord.on { 47 | val commandInteraction = interaction as? CommandInteraction ?: return@on 48 | registeredCommands[commandInteraction.command.rootName]?.execute(commandInteraction, commandInteraction.command) 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/AnimeSearch.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import dev.kord.core.entity.interaction.string 8 | import dev.kord.rest.builder.interaction.embed 9 | import io.ktor.client.request.* 10 | import kotlinx.coroutines.Dispatchers 11 | import kotlinx.coroutines.withContext 12 | import kotlinx.serialization.Serializable 13 | import net.axay.blaubot.commands.api.SlashCommand 14 | import net.axay.blaubot.ktorClient 15 | import org.apache.commons.lang3.StringUtils 16 | 17 | @KordPreview 18 | object AnimeSearch : SlashCommand( 19 | "animesearch", 20 | "Get information about any anime", 21 | { 22 | string("searchterm", "The search input") 23 | }, 24 | test = true 25 | ) { 26 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 27 | val searchterm = command.options["searchterm"]?.string().orEmpty() 28 | 29 | interaction.acknowledgePublic().followUp { 30 | val animeSearchResult = withContext(Dispatchers.IO) { 31 | ktorClient.get>("https://kitsu.io/api/edge/anime?filter[text]=$searchterm") 32 | }.firstOrNull() 33 | 34 | if (animeSearchResult != null) { 35 | embed { 36 | title = "Anime Search" 37 | 38 | image = animeSearchResult.attributes?.coverImage?.original 39 | 40 | field { 41 | name = "Search term" 42 | value = searchterm 43 | } 44 | field { 45 | name = "Name" 46 | value = """ 47 | English: ${animeSearchResult.attributes?.titles?.en ?: NOT_AVAILABLE} 48 | Japanese: ${animeSearchResult.attributes?.titles?.ja_jp ?: NOT_AVAILABLE} 49 | """.trimIndent() 50 | } 51 | field { 52 | name = "Description" 53 | value = StringUtils.abbreviate( 54 | animeSearchResult.attributes?.description ?: NOT_AVAILABLE, 1024 55 | ) 56 | } 57 | field { 58 | name = "Rating" 59 | value = "${animeSearchResult.attributes?.averageRating ?: NOT_AVAILABLE}%" 60 | } 61 | field { 62 | name = "Age Rating" 63 | value = animeSearchResult.attributes?.ageRatingGuide ?: NOT_AVAILABLE 64 | } 65 | field { 66 | name = "Status" 67 | value = animeSearchResult.attributes?.status ?: NOT_AVAILABLE 68 | } 69 | } 70 | } else { 71 | embed { 72 | title = "Anime Search" 73 | 74 | field { 75 | name = "Nicht gefunden" 76 | value = 77 | "Zu deinem gesuchten Begriff wurde entweder nix gefunden oder die Ergebnisse waren nicht Jugendfrei." 78 | } 79 | } 80 | } 81 | } 82 | } 83 | 84 | private const val NOT_AVAILABLE = "Information not available" 85 | 86 | @Serializable 87 | private data class AnimeSearchResult( 88 | val attributes: Attributes? = null, 89 | ) { 90 | @Serializable 91 | data class Attributes( 92 | val titles: Titles? = null, 93 | val description: String? = null, 94 | val coverImage: CoverImage? = null, 95 | val averageRating: String? = null, 96 | val ageRatingGuide: String? = null, 97 | val status: String? = null, 98 | ) { 99 | @Serializable 100 | data class Titles( 101 | val en: String? = null, 102 | val ja_jp: String? = null, 103 | ) 104 | 105 | @Serializable 106 | data class CoverImage( 107 | val original: String? = null, 108 | ) 109 | } 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /src/main/kotlin/net/axay/blaubot/commands/implementation/RandomAnime.kt: -------------------------------------------------------------------------------- 1 | package net.axay.blaubot.commands.implementation 2 | 3 | import dev.kord.common.annotation.KordPreview 4 | import dev.kord.core.behavior.interaction.followUp 5 | import dev.kord.core.entity.interaction.CommandInteraction 6 | import dev.kord.core.entity.interaction.InteractionCommand 7 | import dev.kord.rest.builder.interaction.embed 8 | import dev.kord.x.emoji.Emojis 9 | import net.axay.blaubot.commands.api.SlashCommand 10 | 11 | @KordPreview 12 | object RandomAnime : SlashCommand( 13 | "randomanime", 14 | "Picks a random anime from a predefined list" 15 | ) { 16 | override suspend fun execute(interaction: CommandInteraction, command: InteractionCommand) { 17 | interaction.acknowledgePublic().followUp { 18 | embed { 19 | title = "Der Zufall entscheidet - Welcher Anime?" 20 | field { 21 | val random = animeList.random() 22 | name = random 23 | value = "Cool, da hat sich der Bot wohl für $random entschieden ${Emojis.slightSmile}! Viel Spaß damit!" 24 | } 25 | } 26 | } 27 | } 28 | 29 | private val animeList = listOf( 30 | "2.43: Seiin High School Boys Volleyball Club", 31 | "22/7", 32 | "A Silent Voice", 33 | "Akame ga Kill!", 34 | "Angels Beats", 35 | "Angels of Death", 36 | "Anohana", 37 | "Arrietty- Die wundersame Welt der Borger", 38 | "Arte", 39 | "Assassination Classroom", 40 | "Attack on Titan", 41 | "Azur Lane", 42 | "BNA", 43 | "Back Arrow", 44 | "Bakuman", 45 | "Banana Fish", 46 | "Beastars", 47 | "Berserk", 48 | "Black Bullet", 49 | "Black Clover", 50 | "Black Lagon", 51 | "Bleach", 52 | "Blue Exorcist", 53 | "Boruto", 54 | "Bungou Stray Dogs", 55 | "Bunny Girl", 56 | "Cells At Work", 57 | "Charlotte", 58 | "Chihiros Reise ins Zauberland", 59 | "Code Geass: Lelouch of the Rebellion", 60 | "Cowboy Bebop", 61 | "Danmachi", 62 | "Darker Than Black", 63 | "Darwins Game", 64 | "Das Königreich der Katzen", 65 | "Das Schloss im Himmel", 66 | "Das Wandelnde Schloss", 67 | "Date A Live", 68 | "Date a live", 69 | "Deadman Wonderland", 70 | "Death Note", 71 | "Death Parade", 72 | "Demon Slayer", 73 | "Der Mohnblumenberg", 74 | "Detektiv Conan", 75 | "Devilman Crybaby", 76 | "Devils' Line", 77 | "Dia no Ace", 78 | "Die Chroniken von Erdsee", 79 | "Die Legende Der Prinzessin Kaguya", 80 | "Die Walkinder", 81 | "Digimon", 82 | "Dororo", 83 | "Dr Stone", 84 | "Dragonball", 85 | "Durarara", 86 | "Durarara", 87 | "Erased", 88 | "Erinnerung an Marnie", 89 | "Fairy Gone", 90 | "Fate", 91 | "Fire Force", 92 | "Flüstern Des Meeres Ocean Waves", 93 | "Food Wars! Shokugeki no Soma", 94 | "From the New World", 95 | "Fruits Basket", 96 | "Fullmetal Alchemist: Brotherhood", 97 | "GOD Eater", 98 | "Gintama", 99 | "Gleipnir", 100 | "Go-Toubun no Hanayome", 101 | "Goblin Slayer", 102 | "Goblin Slayer", 103 | "Golden Time", 104 | "Golden boy", 105 | "Gotoubun no Hanayome", 106 | "Grand Blue", 107 | "Great Pretender", 108 | "Great Teacher Onizuka", 109 | "Gurren Lagann", 110 | "Haikyu!!", 111 | "Hataraku Maou-sama", 112 | "heute und für immer", 113 | "Hotarobi no Mori e", 114 | "Hunter × Hunter", 115 | "ID Invaded", 116 | "IWGP", 117 | "Is this a Zombie?", 118 | "Japan Sinkt 2020", 119 | "Jibaku Shounen Hanako-kun", 120 | "JoJo no Kimyō na Bōken", 121 | "Jujutsu Kaisen", 122 | "Jujutsu Kaisen", 123 | "K", 124 | "Kaguya-sama: Love is War", 125 | "Kakegurui", 126 | "Kikisx Kleiner Lieferservice", 127 | "Kimi no Suizou wo Tabetai", 128 | "Kono Subarashii Sekai ni Shukufuku o!", 129 | "Kono Yūsha ga Ore Tsuē Kuse ni Shinchō Sugiru", 130 | "Kuma Kuma Kuma Bear", 131 | "Kuroko's Basketball", 132 | "Listeners", 133 | "Log Horizon", 134 | "Made in Abyss", 135 | "Magi: Sinbad no Bouken", 136 | "Magi: The Labyrinth of Magic", 137 | "Magic Kaito", 138 | "Mein Nachbar Totoro", 139 | "Mirai Nikki", 140 | "Mob Psycho 100", 141 | "Monogatari", 142 | "My Hero Academia", 143 | "Nausicaä aus dem Tal der Winde", 144 | "Neon Genesis Evangelion", 145 | "No Game No Life", 146 | "Noragami", 147 | "One Piece; Naruto", 148 | "One Punch Man", 149 | "Oregairu", 150 | "Oregairu", 151 | "Overlord", 152 | "Owari no Seraph", 153 | "Parasyte the maxim", 154 | "Plunderer", 155 | "Pokemon", 156 | "Pom Poko", 157 | "Ponyo - Das große Abenteuer am Meer", 158 | "Porco Rosso", 159 | "Prinzessin Mononoke", 160 | "Psycho Pass", 161 | "Puella Magi Madoka Magica", 162 | "Rage Of Bahamut", 163 | "Re:Zero – Starting Life in Another World", 164 | "Rental Girlfriend (Kanojo, Okarishimasu)", 165 | "Rokudenashi Majutsu Koushi to Akashic Records", 166 | "SK8", 167 | "Saenai Heroine no Sodatekata", 168 | "Sakura-sou no Pet na Kanojo", 169 | "Seven Deadly Sins", 170 | "So im a spider so what?", 171 | "Soul eater", 172 | "Steins;Gate", 173 | "Stimme des Herzens", 174 | "Sword Art Online", 175 | "TONIKAWA: Over the Moon for You", 176 | "Terror in Tokio", 177 | "That Time i got reincarnated as a slime", 178 | "The God Of Highschool", 179 | "The Millionair Detective", 180 | "The Pet Girl of Sakurasou", 181 | "The Pet Girl of Sakurasou", 182 | "The Promised Neverland", 183 | "The Rising of The Shield Hero", 184 | "The hidden dungeon only i can enter", 185 | "Toaru No Index/railgun", 186 | "Tobaku Mokushiroku Kaiji", 187 | "Toilend-bound Hanako-kun", 188 | "Tokyo Ghoul", 189 | "Toradora", 190 | "Toradora", 191 | "Tower of God", 192 | "Trinity Seven", 193 | "Tränen der Erinnerung", 194 | "Um ein Schnurrhaar", 195 | "Vinland Saga", 196 | "Violet Evergarden", 197 | "Weathering with your", 198 | "Wie der Wind sich hebt", 199 | "Wotakio: Love is Hard for Otaku", 200 | "Your Name. – Gestern", 201 | "Your lie in april", 202 | "Yu Yu Hakusho", 203 | "Yu-Gi-Oh!", 204 | "Yuri on ice", 205 | "Zankyou no Terror", 206 | ) 207 | } 208 | --------------------------------------------------------------------------------