diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100755 index 0000000..5b49ccc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Build and release + +on: + push: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: v${{ github.run_number }} + release_name: Release ${{ github.run_number }} + body: | + Automated release + draft: false + prerelease: false + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./build/libs/dunctebot-dashboard-1.0.jar + asset_name: dunctebot-dashboard-1.0.jar + asset_content_type: application/java-archive diff --git a/build.gradle.kts b/build.gradle.kts index cd2d30c..0429ddd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,10 +26,11 @@ plugins { // java application kotlin("jvm") version "1.4.0" + id("com.github.johnrengelman.shadow") version "6.1.0" } group = "com.dunctebot" -version = "1.0-SNAPSHOT" +version = "1.0" repositories { jcenter() @@ -91,4 +92,7 @@ tasks { gradleVersion = "6.1.1" distributionType = Wrapper.DistributionType.ALL } + shadowJar { + archiveClassifier.set("") + } } diff --git a/src/main/kotlin/com/dunctebot/jda/tojson/JDAToJson.kt b/src/main/kotlin/com/dunctebot/jda/tojson/JDAToJson.kt deleted file mode 100644 index 722e958..0000000 --- a/src/main/kotlin/com/dunctebot/jda/tojson/JDAToJson.kt +++ /dev/null @@ -1,111 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2020 Duncan Sterken - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package com.dunctebot.jda.tojson - -import net.dv8tion.jda.api.entities.* -import net.dv8tion.jda.api.utils.data.DataArray -import net.dv8tion.jda.api.utils.data.DataObject - -fun Guild.toJsonWithChannels(): DataObject { - val mainJson = this.toJson() - - val textChannelCache = this.textChannelCache - - if (!textChannelCache.isEmpty) { - val channelsArray = DataArray.empty() - - textChannelCache.forEach { - channelsArray.add(it.toJson(false)) - } - - mainJson.put("text_channels", channelsArray) - } - - val voiceChannelCache = this.voiceChannelCache - - if (!voiceChannelCache.isEmpty) { - val channelsArray = DataArray.empty() - - voiceChannelCache.forEach { - channelsArray.add(it.toJson(false)) - } - - mainJson.put("voice_channels", channelsArray) - } - - val roleCache = this.roleCache - - if (!roleCache.isEmpty) { - val rolesArray = DataArray.empty() - - roleCache.forEach { - rolesArray.add(it.toJson(false)) - } - - mainJson.put("roles", rolesArray) - } - - return mainJson -} - -fun Guild.toJson(): DataObject { - val json = DataObject.empty() - - json.put("id", this.id) - .put("name", this.name) - .put("icon", this.iconId) - .put("splash", this.splashId) - .put("discovery_splash", null) - .put("owner", false) - .put("owner_id", this.ownerId) - .put("region", this.regionRaw) - .put("afk_channel_id", this.afkChannel?.id) - .put("afk_timeout", this.afkTimeout.seconds) - .put("verification_level", this.verificationLevel.key) - .put("default_message_notifications", this.defaultNotificationLevel.key) - .put("explicit_content_filter", this.explicitContentLevel.key) - .put("roles", this.roleCache.map { it.toJson(false) }) - .put("emojis", this.emoteCache.map { it.toJson(false) }) - .put("features", this.features) - .put("mfa_level", this.requiredMFALevel.key) - - return json -} - -fun Emote.toJson(withGuild: Boolean = true): DataObject { - return DataObject.empty() -} - -fun Role.toJson(withGuild: Boolean = true): DataObject { - return DataObject.empty() -} - -fun TextChannel.toJson(withGuild: Boolean = true): DataObject { - return DataObject.empty() -} - -fun VoiceChannel.toJson(withGuild: Boolean = true): DataObject { - return DataObject.empty() -}