Skip to content

Commit

Permalink
Allow users to set custom colors for the embeds (#120)
Browse files Browse the repository at this point in the history
* Start splitting settings in multiple commands

* Add twitter link to botinfo (Closes #110)

* Split the settings up in multiple files

* Create db!setcolor

* More specific imports

* Use embed builder for better performance

* Fix a few codacy issues

* Use args.isEmpty()

* JDK 11

* Add the option to change the color to the dashboard

* Split web server up in classes

* Fix imports

* Make executable

* Remove test job

* Fix codacy issues

* Replace compile with implementation

* Add some vallidation to the suggest input

* Close the connection to the database after executing
  • Loading branch information
duncte123 authored and ramidzkh committed Nov 5, 2018
1 parent 48157f7 commit 3e0a55d
Show file tree
Hide file tree
Showing 74 changed files with 2,678 additions and 1,277 deletions.
10 changes: 2 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ version: 2
jobs:
build:
docker:
- image: circleci/openjdk:10-jdk-node-browsers
- image: circleci/openjdk:11-jdk-node-browsers
steps:
- checkout
- run: ./gradlew assemble
- run: ./gradlew build
test:
docker:
- image: circleci/openjdk:10-jdk-node-browsers
steps:
- checkout
- run: ./gradlew test
workflows:
version: 2
build_and_test:
jobs:
- build
- test
51 changes: 26 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ plugins {
id 'maven'
id 'application'
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'org.jetbrains.kotlin.jvm' version '1.2.71'
id 'org.jetbrains.kotlin.jvm' version '1.3.0'
}
apply plugin: 'kotlin'

group = "ml.duncte123.skybot"
version "3.81.3_${getGitHash()}"
version "3.82.0_${getGitHash()}"

def javaVersion = JavaVersion.VERSION_11

Expand All @@ -63,64 +63,65 @@ repositories {

dependencies {
//Weeb api
compile group: 'me.duncte123', name: 'weebJava', version: '2.1.1'
// implementation group: 'me.duncte123', name: 'weebJava', version: '2.1.1'
implementation group: 'com.github.duncte123', name: 'weeb.java', version: '78d064c500'

//My little utils
compile group: 'com.github.duncte123', name: 'botCommons', version: 'fbb8f98'
implementation group: 'com.github.duncte123', name: 'botCommons', version: '8c9ad29'

//JDA (java discord api)
// compile (group: 'com.github.DV8FromTheWorld', name: 'JDA', version: 'a7c5b3c') {
compile(group: 'net.dv8tion', name: 'JDA', version: '3.8.1_439') {
// implementation (group: 'com.github.DV8FromTheWorld', name: 'JDA', version: 'a7c5b3c') {
implementation(group: 'net.dv8tion', name: 'JDA', version: '3.8.1_439') {
exclude module: 'opus-java'
}

//Lavaplayer/Lavalink
compile group: 'com.sedmelluq', name: 'lavaplayer', version: '1.3.10'
implementation group: 'com.sedmelluq', name: 'lavaplayer', version: '1.3.10'
// compile group: 'com.github.FredBoat', name: 'Lavalink-Client', version: '125b074'
compile group: 'com.github.DuncteBot', name: 'Lavalink-Client', version: '08e1ce5'
implementation group: 'com.github.DuncteBot', name: 'Lavalink-Client', version: '08e1ce5'

// MySQL
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.13'
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.13'
// SQLite
compile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.25.2'
implementation group: 'org.xerial', name: 'sqlite-jdbc', version: '3.25.2'

//groovy
// compile group: 'org.codehaus.groovy', name: 'groovy-jsr223', version: '2.5.2'
implementation group: 'com.github.apache.groovy', name: 'groovy-jsr223', version: '43d9f2178f'

//groovy sandbox
compile group: 'org.kohsuke', name: 'groovy-sandbox', version: '1.19'
implementation group: 'org.kohsuke', name: 'groovy-sandbox', version: '1.19'

// Logback classic
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'

// cp scraping stuffz
compile group: 'org.reflections', name: 'reflections', version: '0.9.11'
implementation group: 'org.reflections', name: 'reflections', version: '0.9.11'

//Spotify API
compile group: 'se.michaelthelin.spotify', name: 'spotify-web-api-java', version: '2.1.1'
implementation group: 'se.michaelthelin.spotify', name: 'spotify-web-api-java', version: '2.1.1'
// Youtube api
compile group: 'com.google.apis', name: 'google-api-services-youtube', version: 'v3-rev206-1.25.0'
implementation group: 'com.google.apis', name: 'google-api-services-youtube', version: 'v3-rev206-1.25.0'

//Add kotlin
compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
compile group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version
compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '1.0.0'
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: kotlin_version
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: kotlin_version
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: '1.0.0'

//Spark for website
compile group: 'com.sparkjava', name: 'spark-kotlin', version: '1.0.0-alpha'
compile group: 'com.sparkjava', name: 'spark-core', version: '2.8.0' // Override spark to the latest version
compile group: 'com.sparkjava', name: 'spark-template-jtwig', version: '2.7.1'
implementation group: 'com.sparkjava', name: 'spark-kotlin', version: '1.0.0-alpha'
implementation group: 'com.sparkjava', name: 'spark-core', version: '2.8.0' // Override spark to the latest version
implementation group: 'com.sparkjava', name: 'spark-template-jtwig', version: '2.7.1'
// Oauth
compile group: 'com.github.JDA-Applications.JDA-Utilities', name: 'jda-utilities-oauth2', version: 'b98962c'
implementation group: 'com.github.JDA-Applications.JDA-Utilities', name: 'jda-utilities-oauth2', version: 'b98962c'

compile group: 'com.jagrosh', name: 'JagTag', version: '0.5'
implementation group: 'com.jagrosh', name: 'JagTag', version: '0.5'

//Wolfaram alpha
implementation group: 'com.github.DuncteBot', name: 'wolfram-alpha-java-binding', version: '5c123ae'

// https://mvnrepository.com/artifact/org.ocpsoft.prettytime/prettytime
compile group: 'org.ocpsoft.prettytime', name: 'prettytime', version: '4.0.2.Final'
implementation group: 'org.ocpsoft.prettytime', name: 'prettytime', version: '4.0.2.Final'
}

task sourcesForRelease(type: Copy) {
Expand Down Expand Up @@ -163,7 +164,7 @@ shadowJar {

compileKotlin {
kotlinOptions {
jvmTarget = "11"
jvmTarget = "1.8"
}
}

Expand Down
Empty file modified gradlew.bat
100644 → 100755
Empty file.
8 changes: 7 additions & 1 deletion src/main/java/ml/duncte123/skybot/BotListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ private void loadPatrons(@NotNull ShardManager manager) {

} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

});
Expand Down Expand Up @@ -677,7 +683,7 @@ private boolean doAutoModChecks(@NotNull GuildMessageReceivedEvent event, GuildS
}
}

if (settings.getEnableSpamFilter()) {
if (settings.isEnableSpamFilter()) {
Message messageToCheck = event.getMessage();
long[] rates = settings.getRatelimits();
spamFilter.applyRates(rates);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/ml/duncte123/skybot/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@ public List<ICommand> getSortedCommands() {
if (commandsSorted.isEmpty()) {
List<ICommand> commandSet = new ArrayList<>();
List<String> names = new ArrayList<>();

getCommands().stream().filter(cmd -> cmd.getCategory() != CommandCategory.UNLISTED)
.collect(Collectors.toSet()).forEach(c -> names.add(c.getName()));
Collections.sort(names);

names.forEach(n -> commandSet.add(getCommand(n)));
commandsSorted.addAll(commandSet);
}

return commandsSorted;
}

Expand Down Expand Up @@ -306,7 +309,7 @@ public void dispatchCommand(String invoke, List<String> args, GuildMessageReceiv

public void dispatchCommand(ICommand cmd, String invoke, List<String> args, GuildMessageReceivedEvent event) {

if(cmd == null) {
if (cmd == null) {
return;
}

Expand Down
5 changes: 1 addition & 4 deletions src/main/java/ml/duncte123/skybot/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
import gnu.trove.list.TLongList;
import gnu.trove.list.array.TLongArrayList;

import java.awt.*;

import static java.awt.Color.decode;
import static java.lang.System.getProperty;

@Author(nickname = "duncte123", author = "Duncan Sterken")
Expand All @@ -37,7 +34,7 @@ public class Settings {
public static final String KOTLIN_VERSION = "@kotlinVersion@";
public static final String DEFAULT_NAME = "DuncteBot";
public static final String DEFAULT_ICON = "https://bot.duncte123.me/img/favicon.png";
public static final Color defaultColour = decode("#0751c6");
public static final int defaultColour = 0x0751c6;
public static final boolean enableUpdaterCommand = getProperty("updater") != null;
public static final boolean useJSON = false;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ml/duncte123/skybot/SkyBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import ml.duncte123.skybot.objects.config.DunctebotConfig;
import ml.duncte123.skybot.utils.GuildSettingsUtils;
import ml.duncte123.skybot.utils.HelpEmbeds;
import ml.duncte123.skybot.web.WebServer;
import ml.duncte123.skybot.web.WebHolder;
import net.dv8tion.jda.bot.sharding.DefaultShardManagerBuilder;
import net.dv8tion.jda.bot.sharding.ShardManager;
import net.dv8tion.jda.core.EmbedBuilder;
Expand Down Expand Up @@ -154,7 +154,7 @@ private SkyBot() throws Exception {

if (!config.discord.local) {
// init web server
new WebServer(shardManager, variables);
new WebHolder(shardManager, variables);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ml/duncte123/skybot/Variables.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public WeebApi getWeebApi() {
return weebApi;
}

boolean isSql() {
public boolean isSql() {
return isSql;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import static java.awt.Color.decode;
import static me.duncte123.botcommons.messaging.EmbedUtils.defaultEmbed;
import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbed;
import static me.duncte123.botcommons.messaging.MessageUtils.sendEmbedRaw;

@Author(nickname = "duncte123", author = "Duncan Sterken")
public class ColorCommand extends Command {
Expand All @@ -51,7 +51,7 @@ public void executeCommand(@NotNull CommandContext ctx) {
name, hex, integer, rgb, brightness);
embed.setDescription(desc);

sendEmbed(ctx.getEvent(), embed.build());
sendEmbedRaw(ctx.getChannel(), embed.build(), null);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ else if (invoke.endsWith("3"))
});
}

sendEmbed(targetChannel, embed.build());
sendEmbed(targetChannel, embed);
MessageUtils.sendSuccess(event.getMessage());
break;
}
Expand Down
Loading

0 comments on commit 3e0a55d

Please sign in to comment.