feat: project was set up, started on base, add logging into Discord Bot
This commit is contained in:
commit
0c3cee73a1
15 changed files with 901 additions and 0 deletions
53
src/main/kotlin/de/limited_dev/botendo/Bot.kt
Normal file
53
src/main/kotlin/de/limited_dev/botendo/Bot.kt
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Botendo
|
||||
* Copyright (C) 2023 limited_dev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.limited_dev.botendo
|
||||
|
||||
import de.limited_dev.botendo.util.Logger
|
||||
import de.limited_dev.botendo.util.TokenManager
|
||||
import dev.kord.core.Kord
|
||||
import dev.kord.gateway.Intent
|
||||
import dev.kord.gateway.PrivilegedIntent
|
||||
|
||||
object Bot {
|
||||
//The kord object gets set at app launch
|
||||
var kord: Kord? = null
|
||||
suspend fun start() {
|
||||
//Load config
|
||||
TokenManager.load()
|
||||
|
||||
|
||||
//Don't run the bot when there is no bot token in config
|
||||
if (TokenManager.token == "empty") {
|
||||
Logger.out("The config does not contain a bot token")
|
||||
return
|
||||
}
|
||||
|
||||
// start the bot
|
||||
kord = Kord(TokenManager.token)
|
||||
kord!!.login {
|
||||
// Load gateway privileges
|
||||
@OptIn(PrivilegedIntent::class)
|
||||
intents += Intent.GuildMembers
|
||||
|
||||
@OptIn(PrivilegedIntent::class)
|
||||
intents += Intent.MessageContent
|
||||
}
|
||||
}
|
||||
}
|
39
src/main/kotlin/de/limited_dev/botendo/Main.kt
Normal file
39
src/main/kotlin/de/limited_dev/botendo/Main.kt
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Botendo
|
||||
* Copyright (C) 2023 limited_dev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.limited_dev.botendo
|
||||
|
||||
import de.limited_dev.botendo.build.BuildConstants
|
||||
|
||||
|
||||
///Show the splash and launch the Bot
|
||||
suspend fun main() {
|
||||
println(
|
||||
"M#\"\"\"\"\"\"\"'M dP dP \n" +
|
||||
"## mmmm. `M 88 88 \n" +
|
||||
"#' .M .d8888b. d8888P .d8888b. 88d888b. .d888b88 .d8888b. \n" +
|
||||
"M# MMMb.'YM 88' `88 88 88ooood8 88' `88 88' `88 88' `88 \n" +
|
||||
"M# MMMM' M 88. .88 88 88. ... 88 88 88. .88 88. .88 \n" +
|
||||
"M# .;M `88888P' dP `88888P' dP dP `88888P8 `88888P' \n" +
|
||||
"M#########M \n" +
|
||||
" "
|
||||
)
|
||||
println("Bot ver.${BuildConstants.version}")
|
||||
Bot.start()
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Botendo
|
||||
* Copyright (C) 2023 limited_dev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.limited_dev.botendo.commands.slash
|
||||
|
||||
abstract class SlashCommand(val name: String, val description: String, val options: Array<String>? = null) {
|
||||
|
||||
fun onSlashCommand() {}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Botendo
|
||||
* Copyright (C) 2023 limited_dev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.limited_dev.botendo.commands.slash
|
||||
|
||||
object SlashCommandManager {
|
||||
|
||||
fun register() {
|
||||
|
||||
}
|
||||
|
||||
fun registerAtDiscord(commands: List<SlashCommand>) {
|
||||
//Bot.kord.createGlobalApplicationCommands {
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
42
src/main/kotlin/de/limited_dev/botendo/util/Logger.kt
Normal file
42
src/main/kotlin/de/limited_dev/botendo/util/Logger.kt
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Botendo
|
||||
* Copyright (C) 2023 limited_dev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.limited_dev.botendo.util
|
||||
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
object Logger {
|
||||
private val dtf: DateTimeFormatter = DateTimeFormatter.ofPattern("yy/MM/dd HH:mm:ss")
|
||||
|
||||
fun out(msg: String) {
|
||||
val caller = Thread.currentThread().stackTrace[2]
|
||||
val now: LocalDateTime = LocalDateTime.now()
|
||||
try {
|
||||
println(
|
||||
("[" + Class.forName(caller.className).simpleName + "." +
|
||||
caller.methodName + ":" + caller.lineNumber + "] [" + dtf.format(now)).toString() + "] <" + msg + ">"
|
||||
)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
// Ich kann nicht mehr
|
||||
// [Klasse.Funktion] [T/M HH:MM] <NACHRICHT>
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Botendo
|
||||
* Copyright (C) 2023 limited_dev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.limited_dev.botendo.util
|
||||
|
||||
object SlashCommandListener {
|
||||
|
||||
fun check() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Botendo
|
||||
* Copyright (C) 2023 limited_dev
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package de.limited_dev.botendo.build
|
||||
|
||||
internal object BuildConstants {
|
||||
const val version = "${version}"
|
||||
const val ownerID = "${ownerID}"
|
||||
const val kordVersion = "${kordversion}"
|
||||
const val lavaVersion = "${lavaversion}"
|
||||
const val coroutinesVersion = "${coroutinesversion}"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue