Skip to content
This repository was archived by the owner on Dec 13, 2021. It is now read-only.

Release 1.0 #40

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 10 additions & 3 deletions .github/workflows/votebot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,23 @@ jobs:
- name: Test with Gradle
run: ./gradlew test ktlintCheck
- name: Build with Gradle
run: ./gradlew classes
- name: Make Distribution with Gradle
if: github.ref == 'refs/heads/main'
run: ./gradlew installDist
- name: Login
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.DOCKER_TOKEN }}
run: docker login ghcr.io --username ci --password "$GITHUB_TOKEN"
run: docker login ghcr.io --username ci --password "$GITHUB_TOKEN"
- name: Build & Tag
run: docker build -t ghcr.io/votebot/votebot/bot:latest -t ghcr.io/votebot/votebot/bot:"$GITHUB_SHA" .
if: github.ref == 'refs/heads/main'
run: docker build -t ghcr.io/votebot/votebot/bot:latest -t ghcr.io/votebot/votebot/bot:"$GITHUB_SHA" .
- name: Push
run: docker push ghcr.io/votebot/votebot/bot:latest
if: github.ref == 'refs/heads/main'
run: docker push ghcr.io/votebot/votebot/bot:latest
- name: Push specific tag
if: github.ref == 'refs/heads/main'
run: docker push ghcr.io/votebot/votebot/bot:"$GITHUB_SHA"
- name: Create Sentry Release
if: github.ref == 'refs/heads/main'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ gradle-app.setting
**/build/

# End of https://www.toptal.com/developers/gitignore/api/kotlin,gradle


.env
10 changes: 10 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/votebot.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM adoptopenjdk/openjdk16

WORKDIR /usr/app

COPY build/install .

ENTRYPOINT ["bin/votebot"]
17 changes: 16 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,26 @@ repositories {
}

dependencies {
implementation("io.github.microutils", "kotlin-logging", "2.0.8")

implementation("dev.kord", "kord-core", "0.7.x-SNAPSHOT")

implementation("dev.schlaubi", "envconf", "1.0")

implementation("io.github.microutils", "kotlin-logging", "2.0.8")
implementation("ch.qos.logback", "logback-classic", "1.3.0-alpha5")
implementation("io.sentry", "sentry", "4.3.0")
implementation("io.sentry", "sentry-logback", "4.3.0")
}

tasks {
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
freeCompilerArgs =
listOf(
"-Xopt-in=dev.kord.common.annotation.KordPreview",
"-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=kotlin.ExperimentalStdlibApi"
)
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
57 changes: 57 additions & 0 deletions src/main/kotlin/dev/schlaubi/votebot/Launcher.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* VoteBot - A feature-rich bot to create votes on Discord guilds.
*
* Copyright (C) 2019-2021 Michael Rittmeister & Yannick Seeger
*
* 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 dev.schlaubi.votebot

import ch.qos.logback.classic.Logger
import dev.schlaubi.votebot.config.Config
import io.sentry.Sentry
import io.sentry.SentryOptions
import mu.KotlinLogging
import org.slf4j.LoggerFactory
import dev.schlaubi.votebot.core.VoteBotImpl as VoteBot

private val LOG = KotlinLogging.logger { }

suspend fun main() {
initializeLogging()
initializeSentry()

VoteBot().start()
}

private fun initializeLogging() {
val rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME) as Logger
rootLogger.level = Config.LOG_LEVEL

Thread.setDefaultUncaughtExceptionHandler { thread, throwable ->
LOG.error(throwable) { "Got unhandled error on $thread" }
}
}

private fun initializeSentry() {
val configure: (SentryOptions) -> Unit =
if (Config.ENVIRONMENT.useSentry) {
{ it.dsn = Config.SENTRY_TOKEN; }
} else {
{ it.dsn = "" }
}

Sentry.init(configure)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Votebot - A feature-rich bot to create votes on Discord guilds.
*
* Copyright (C) 2019-2021 Michael Rittmeister & Yannick Seeger
*
* 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 dev.schlaubi.votebot.command

import dev.schlaubi.votebot.command.context.Context
import kotlin.coroutines.CoroutineContext

/**
* Functional interface to properly handle Errors during command execution.
*/
fun interface CommandErrorHandler {
/**
* Handels a [throwable] that was thrown in [context] and [coroutineContext].
*/
suspend fun handleCommandError(context: Context, coroutineContext: CoroutineContext, throwable: Throwable)
}
31 changes: 31 additions & 0 deletions src/main/kotlin/dev/schlaubi/votebot/command/DescriptiveCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Votebot - A feature-rich bot to create votes on Discord guilds.
*
* Copyright (C) 2019-2021 Michael Rittmeister & Yannick Seeger
*
* 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 dev.schlaubi.votebot.command

/**
* A command which has registration data.
*
* @property name the name of the command
* @property description the description of the command
*/
sealed interface DescriptiveCommand {
val name: String
val description: String
}
Loading