diff --git a/.github/dependabot.yml b/.github/dependabot.yml
deleted file mode 100644
index e46c16f6..00000000
--- a/.github/dependabot.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-# To get started with Dependabot version updates, you'll need to specify which
-# package ecosystems to update and where the package manifests are located.
-# Please see the documentation for all configuration options:
-# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
-
-version: 2
-updates:
- - package-ecosystem: "maven" # See documentation for possible values
- directory: "/" # Location of package manifests
- schedule:
- interval: "daily"
- target_branch: "develop"
diff --git a/images/FriendlyBot.png b/.github/images/FriendlyBot.png
similarity index 100%
rename from images/FriendlyBot.png
rename to .github/images/FriendlyBot.png
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
deleted file mode 100644
index 1fc2dda7..00000000
--- a/.github/workflows/maven.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-# This workflow will build a Java project with Maven
-# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
-
-name: Build
-
-on:
- push:
- branches: [ main ]
- pull_request:
- branches: [ main ]
-
-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: Build with Maven
- run: mvn -B package --file pom.xml
- - name: Archive full target folder
- uses: actions/upload-artifact@v2
- with:
- name: friendlybot
- path: target/
- - name: Archive Compiled and Shaded Archive
- uses: actions/upload-artifact@v2
- with:
- name: friendlybot
- path: target/friendlybot-1.0.0-shaded.jar
diff --git a/.gitignore b/.gitignore
index 200f86b4..36a40da0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,15 @@
+# Gradle
+.gradle/
+build/
+
+# Unit testing
+friendlybot.mv.db
+
# Runtime stuff
/*.json
src/test/resources/img*
+friendlybot-locale.properties
+friendlybot.conf
# Private tests
src/test/java/io/paradaux/friendlybot/managers/MailGunManagerTest.java
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index d2f6ba3c..00000000
--- a/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2021 RÃan Errity
-
-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.
diff --git a/Placeholders.md b/Placeholders.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/README.md b/README.md
index e99c21c3..c2b68ef5 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,17 @@
# FriendlyBot

+[](https://www.codefactor.io/repository/github/paradauxio/friendlybot)


-
-
-
+
+
+
FriendlyBot
-
+
The general-purpose discord bot made for the Computer Science Friendly Corner .
YouTrack
@@ -20,7 +21,6 @@
Issues
·
Actions
-
There are plans to generify the codebase to allow for a public discord bot, as well as having a web-based user interface
@@ -34,7 +34,7 @@ production server.
FriendlyBot makes use of a MongoDB database which is integral to the functionality of the bot, the connection url must
be specified in the configuration file. As well as that, a stable internet connection is required at all times; to talk to
-discord and the various web APIs the bot makes use of.
+discord, and the various web APIs the bot makes use of.
The following instructions are to be executed on the command line (terminal) requiring write permissions.
This requires both Maven and Git to be added to your terminal's path, other than that these instructions are fairly platform agnostic.
@@ -67,4 +67,5 @@ Distributed under the MIT License. See [LICENSE.md](https://github.com/ParadauxI
## Contributors
-1. [RÃan Errity](mailto:rian@paradaux.io) — Project Lead — https://paradaux.io
\ No newline at end of file
+1. [RÃan Errity](mailto:rian@paradaux.io) — Project Lead — https://paradaux.io
+2. This could be you o.0
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 00000000..1b7fcdc2
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,76 @@
+plugins {
+ id 'java'
+ id 'io.ebean' version '12.10.0'
+ id 'com.github.johnrengelman.shadow' version '7.0.0'
+}
+
+group 'io.paradaux'
+version '2.0.0'
+
+repositories {
+ gradlePluginPortal()
+ mavenCentral()
+ maven {
+ url = "https://m2.dv8tion.net/releases"
+ }
+
+ maven {
+ url = "https://jitpack.io"
+ }
+
+ maven {
+ url = "https://repo.paradaux.io/releases"
+ }
+
+ maven {
+ url = "https://m2.chew.pro/releases"
+ }
+}
+
+dependencies {
+
+ implementation 'org.postgresql:postgresql:42.2.23'
+ implementation 'net.dv8tion:JDA:4.3.0_300'
+ implementation 'pw.chew:jda-chewtils:1.20'
+ implementation 'org.slf4j:slf4j-api:1.7.32'
+ implementation 'org.slf4j:slf4j-log4j12:1.7.32'
+ implementation 'com.google.code.gson:gson:2.8.8'
+ implementation 'org.mongodb:mongo-java-driver:3.12.10'
+ implementation 'io.paradaux.http:HttpApi:1.1.2'
+ implementation 'io.ebean:ebean:12.11.3'
+ implementation 'com.h2database:h2:1.4.200'
+ implementation 'org.spongepowered:configurate-hocon:4.1.2'
+
+ annotationProcessor 'io.ebean:querybean-generator:12.11.3'
+
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
+ testImplementation 'io.ebean:ebean-test:12.11.3'
+
+ testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
+}
+
+test {
+ useJUnitPlatform()
+}
+
+compileJava {
+ options.release = 11
+ options.encoding('UTF-8')
+}
+
+jar {
+ manifest {
+ attributes(
+ 'Main-Class': 'io.paradaux.friendlybot.FBApplication'
+ )
+ }
+
+ from {
+ configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
+ }
+}
+
+// Allow use of Emojis inline
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 00000000..05679dc3
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100755
index 00000000..4f906e0c
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,185 @@
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=`expr $i + 1`
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=`save "$@"`
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 00000000..107acd32
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 224547fb..00000000
--- a/pom.xml
+++ /dev/null
@@ -1,209 +0,0 @@
-
-
-
-
- 4.0.0
-
- io.paradaux
- friendlybot
- 1.0.0
-
-
- UTF-8
- 1.8
-
-
-
-
-
- org.apache.maven.plugins
-
- maven-compiler-plugin
-
- 3.8.1
-
-
- 11
- 11
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.2.4
-
-
-
- shade
-
-
-
- true
-
-
-
- io.paradaux.friendlybot.FriendlyBot
-
-
-
- ${project.build.directory}/dependency-reduced-pom.xml
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.2.0
-
-
-
- true
- io.paradaux.friendlybot.FriendlyBot
-
-
-
-
-
-
-
-
- src/main/resources
- true
-
-
-
-
-
- src/test/resources
-
-
-
-
-
-
-
- false
-
- jcenter
- jcenter-bintray
- https://jcenter.bintray.com
-
-
-
- jitpack.io
- https://jitpack.io
-
-
-
- paradaux
- https://repo.paradaux.io/releases
-
-
-
-
-
- net.dv8tion
- JDA
- 4.2.0_247
-
-
- club.minnced
- opus-java
-
-
- jar
- compile
-
-
-
- com.jagrosh
- jda-utilities
- 3.0.5
- pom
- compile
-
-
-
- org.slf4j
- slf4j-api
- 1.7.30
- jar
- compile
-
-
-
- org.slf4j
- slf4j-log4j12
- 1.7.30
- jar
- compile
-
-
-
- com.google.code.gson
- gson
- 2.8.6
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- 5.7.1
- test
-
-
-
- org.junit.jupiter
- junit-jupiter-engine
- 5.7.1
- test
-
-
-
- org.mongodb
- mongo-java-driver
- 3.12.8
-
-
-
- io.paradaux.http
- HttpApi
- 1.1.1
-
-
- org.slf4j
- slf4j-log4j12
-
-
-
-
-
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 00000000..4a4c0735
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,2 @@
+rootProject.name = 'FriendlyBot'
+
diff --git a/src/main/java/io/paradaux/friendlybot/FBApplication.java b/src/main/java/io/paradaux/friendlybot/FBApplication.java
new file mode 100644
index 00000000..54a28b14
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/FBApplication.java
@@ -0,0 +1,42 @@
+package io.paradaux.friendlybot;
+
+import io.paradaux.friendlybot.bot.FBot;
+import io.paradaux.friendlybot.core.data.cache.GuildCache;
+import io.paradaux.friendlybot.core.data.config.FConfiguration;
+import io.paradaux.friendlybot.core.data.config.FConfigurationLoader;
+import io.paradaux.friendlybot.core.data.database.EBeanConnection;
+import io.paradaux.friendlybot.core.locale.LocaleLogger;
+import io.paradaux.friendlybot.core.locale.LocaleManager;
+import org.slf4j.LoggerFactory;
+import org.spongepowered.configurate.ConfigurateException;
+
+import javax.security.auth.login.LoginException;
+
+public class FBApplication {
+
+ public static final String VERSION = "2.0";
+
+ private static LocaleManager localeManager;
+ private static LocaleLogger logger;
+ private static FConfiguration config;
+ private static FBot bot;
+ private static GuildCache guildCache;
+ private static EBeanConnection eBeanConnection;
+
+ public static FConfiguration getConfig() {
+ return config;
+ }
+
+ public static void main(String[] args) throws ConfigurateException, LoginException {
+ localeManager = new LocaleManager();
+ logger = new LocaleLogger(LoggerFactory.getLogger(FBApplication.class), true);
+
+ config = FConfigurationLoader.loadConfig();
+ eBeanConnection = new EBeanConnection(config);
+ bot = new FBot(config);
+ guildCache = new GuildCache(bot.getClient());
+ }
+
+
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/FriendlyBot.java b/src/main/java/io/paradaux/friendlybot/FriendlyBot.java
index 322be6c9..c075cebd 100644
--- a/src/main/java/io/paradaux/friendlybot/FriendlyBot.java
+++ b/src/main/java/io/paradaux/friendlybot/FriendlyBot.java
@@ -25,10 +25,9 @@
package io.paradaux.friendlybot;
+import io.paradaux.friendlybot.core.utils.API;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
import io.paradaux.friendlybot.managers.*;
-import io.paradaux.friendlybot.utils.API;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import net.dv8tion.jda.api.utils.concurrent.Task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,7 +56,7 @@ public static API getApi() {
public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger("io.paradaux.friendlybot");
- logger.info("CSBot v1.0.0 - Maintained by RÃan Errity ");
+ logger.info("FriendlyBot v2.0 - Maintained by RÃan Errity ");
logger.info("Initialising Controllers. This may take some time...");
IOManager ioManager = new IOManager(logger);
@@ -66,16 +65,18 @@ public static void main(String[] args) {
ConfigurationEntry config = configManager.getConfig();
MongoManager mongoManager = new MongoManager(config, logger);
- PermissionManager permissionManager = new PermissionManager(logger);
+ GuildSettingsManager guildSettingsManager = new GuildSettingsManager(logger, mongoManager);
+ PermissionManager permissionManager = new PermissionManager(logger, guildSettingsManager);
RoleManager roleManager = new RoleManager(logger, mongoManager);
- DiscordBotManager discordBotManager = new DiscordBotManager(config, logger, permissionManager, mongoManager, roleManager);
- SettingsManager settingsManager = new SettingsManager(logger, mongoManager);
+ UserSettingsManager settingsManager = new UserSettingsManager(logger, mongoManager);
+
+ PunishmentManager punishmentManager = new PunishmentManager();
+ DiscordBotManager discordBotManager = new DiscordBotManager(config, logger, permissionManager, mongoManager, roleManager, guildSettingsManager);
TagManager tagManager = new TagManager(config, logger, mongoManager);
AuditManager auditManager = new AuditManager(config, logger);
MailGunManager mailGunManager = new MailGunManager(config, logger);
VerificationManager verificationManager = new VerificationManager(config, logger, mongoManager, mailGunManager);
- TaskManager taskManager = new TaskManager();
-
+
api = API.builder()
.setLogger(logger)
.setIoManager(ioManager)
@@ -91,7 +92,5 @@ public static void main(String[] args) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
logger.info("Shutting down...");
}));
-
- // TODO unban scheduler
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/FBot.java b/src/main/java/io/paradaux/friendlybot/bot/FBot.java
new file mode 100644
index 00000000..5a390c25
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/FBot.java
@@ -0,0 +1,67 @@
+package io.paradaux.friendlybot.bot;
+
+import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
+import io.paradaux.friendlybot.bot.command.CommandListener;
+import io.paradaux.friendlybot.bot.commands.image.*;
+import io.paradaux.friendlybot.bot.commands.test.CreateUser;
+import io.paradaux.friendlybot.core.data.config.FConfiguration;
+import net.dv8tion.jda.api.JDA;
+import net.dv8tion.jda.api.JDABuilder;
+import net.dv8tion.jda.api.requests.GatewayIntent;
+import net.dv8tion.jda.api.utils.MemberCachePolicy;
+
+import javax.security.auth.login.LoginException;
+
+public class FBot {
+
+ private final FConfiguration config;
+ private final EventWaiter eventWaiter;
+ private final CommandListener commandListener;
+ private final JDA client;
+
+ public FBot(FConfiguration config) throws LoginException {
+ this.config = config;
+ this.eventWaiter = new EventWaiter();
+ this.commandListener = new CommandListener();
+ registerCommands();
+ this.client = login(config.getBotToken());
+ }
+
+ public void registerCommands() {
+ commandListener.registerCommands(
+ new CatCommand(),
+ new CoinFlipCommand(),
+ new DogCommand(),
+ new EightBallCommand(),
+ new InspireCommand(),
+ new MemeCommand(),
+ new MonkeyCommand(),
+ new XKCDCommand(),
+ new CreateUser()
+ );
+ }
+
+ /**
+ * Creates an Instance of JDA from the provided token.
+ * @param token The Discord Token taken from the configuration file.
+ * @return JDA An Instance of JDA
+ * @throws LoginException When logging in proved unsuccessful.
+ * */
+ public JDA login(String token) throws LoginException {
+ JDABuilder builder = JDABuilder.createDefault(token, GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_MESSAGE_REACTIONS)
+ .setMemberCachePolicy(MemberCachePolicy.ALL)
+ .enableIntents(GatewayIntent.GUILD_MEMBERS)
+ .setBulkDeleteSplittingEnabled(false)
+ .addEventListeners(eventWaiter, commandListener);
+
+ if (token == null) {
+ throw new LoginException("The Configuration File does not contain a token.");
+ }
+
+ return builder.build();
+ }
+
+ public JDA getClient() {
+ return client;
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/command/Command.java b/src/main/java/io/paradaux/friendlybot/bot/command/Command.java
new file mode 100644
index 00000000..252dddf4
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/command/Command.java
@@ -0,0 +1,14 @@
+package io.paradaux.friendlybot.bot.command;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Command {
+
+ String name() default "";
+ String description() default "";
+ String permission() default "";
+ String[] aliases() default {};
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/command/CommandBody.java b/src/main/java/io/paradaux/friendlybot/bot/command/CommandBody.java
new file mode 100644
index 00000000..2bc430c0
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/command/CommandBody.java
@@ -0,0 +1,91 @@
+package io.paradaux.friendlybot.bot.command;
+
+import net.dv8tion.jda.api.JDA;
+import net.dv8tion.jda.api.entities.Member;
+import net.dv8tion.jda.api.entities.Message;
+import net.dv8tion.jda.api.entities.MessageChannel;
+import net.dv8tion.jda.api.entities.User;
+
+public class CommandBody {
+
+ private final JDA jda;
+
+ private final String command;
+ private final String permission;
+ private final String description;
+
+ private final String[] args;
+ private final String[] aliases;
+
+ private final Message message;
+ private final MessageChannel channel;
+ private final Member member;
+ private final User user;
+
+ public CommandBody(Message message, String command, String permission, String description, String[] args, String[] aliases) {
+ this.jda = message.getJDA();
+
+ this.command = command;
+ this.permission = permission;
+ this.description = description;
+
+ this.args = args;
+ this.aliases = aliases;
+
+ this.message = message;
+ this.channel = message.getChannel();
+ this.member = message.getMember();
+ if (this.member == null) {
+ throw new IllegalStateException("Member cannot be null");
+ }
+ this.user = member.getUser();
+ }
+
+ public String getArgStr() {
+ return String.join(" ", getArgs());
+ }
+
+ public boolean isArgsEmpty() {
+ return getArgs().length == 0;
+ }
+
+ public JDA getJda() {
+ return jda;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public String[] getArgs() {
+ return args;
+ }
+
+ public Message getMessage() {
+ return message;
+ }
+
+ public MessageChannel getChannel() {
+ return channel;
+ }
+
+ public Member getMember() {
+ return member;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String[] getAliases() {
+ return aliases;
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/command/CommandListener.java b/src/main/java/io/paradaux/friendlybot/bot/command/CommandListener.java
new file mode 100644
index 00000000..f2eb5200
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/command/CommandListener.java
@@ -0,0 +1,131 @@
+package io.paradaux.friendlybot.bot.command;
+
+import io.paradaux.friendlybot.bot.command.exception.CommandException;
+import io.paradaux.friendlybot.core.data.cache.GuildCache;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import net.dv8tion.jda.api.EmbedBuilder;
+import net.dv8tion.jda.api.entities.Message;
+import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
+import net.dv8tion.jda.api.hooks.ListenerAdapter;
+import org.jetbrains.annotations.NotNull;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class CommandListener extends ListenerAdapter {
+
+ private final ArrayList commands;
+
+ public CommandListener() {
+ commands = new ArrayList<>();
+ }
+
+ @Override
+ public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
+ // Get the guild
+ FGuild guild = GuildCache.getInstance().getGuild(event.getGuild().getId());
+
+ // Message stuff
+ Message message = event.getMessage();
+ String messageContent = message.getContentRaw();
+
+ // If it isn't a valid command
+ if (!messageContent.startsWith(guild.getCommandPrefix())) {
+ return;
+ }
+
+ // Command body
+ String command = messageContent.substring(guild.getCommandPrefix().length());
+ String[] args = {};
+
+ // If there's arguments, parse them.
+ if (messageContent.contains(" ")) {
+ String[] components = command.split(" ");
+ args = Arrays.copyOfRange(components, 1, components.length);
+ command = components[0];
+ }
+
+ if (command.equalsIgnoreCase("help")) {
+ helpMenu(message);
+ return;
+ }
+
+ for (DiscordCommand c : commands) {
+ if (c.getNames().contains(command)) {
+ c.execute(guild, new CommandBody(message, command, c.getPermission(), c.getDescription(), args, c.getAliases()));
+ break;
+ }
+ }
+
+ }
+
+
+ /**
+ * Returns a list of commands as a message as a reply.
+ * */
+ public void helpMenu(Message message) {
+ EmbedBuilder builder = new EmbedBuilder();
+
+ StringBuilder descBuilder = new StringBuilder().append("\n\n");
+ for (DiscordCommand c : commands) {
+ descBuilder.append("\\➡ **").append(c.getCommand()).append("**").append(" » ").append(c.getDescription());
+ }
+
+ descBuilder.append("\n\n");
+
+ builder.setAuthor("**FriendlyBot**: Commands");
+ builder.setDescription(descBuilder);
+ builder.setTimestamp(Instant.now());
+ builder.setFooter("N.B: Some commands may be role-locked.");
+
+ message.getChannel().sendMessageEmbeds(builder.build()).queue();
+ }
+
+
+ /**
+ * Registers the requested command.
+ * */
+ public void registerCommand(DiscordCommand command) {
+ if (command.isRegistered()) {
+ throw new CommandException("Command is already marked as registered.");
+ }
+
+ Class> clazz = command.getClass();
+ if (!clazz.isAnnotationPresent(Command.class)) {
+ throw new CommandException("Provided Argument is not a valid command. Not annotated as command.");
+ }
+
+ Command cmd = clazz.getAnnotation(Command.class);
+
+ command.register(cmd.name(), cmd.description(), cmd.permission(), cmd.aliases());
+
+ for (DiscordCommand c : commands) {
+ if (c.getCommand().equals(command.getCommand())) {
+ throw new CommandException("A command by this name has already been registered.");
+ }
+ }
+
+ commands.add(command);
+ }
+
+ /**
+ * Register a list of commands.
+ * */
+ public void registerCommands(DiscordCommand... commands) {
+ for (DiscordCommand command : commands) {
+ registerCommand(command);
+ }
+ }
+
+
+ /**
+ * Unregisters the requested command.
+ * @throws CommandException If the provided command has not been registered.
+ * */
+ public void removeCommand(DiscordCommand command) {
+ if (!commands.remove(command)) {
+ throw new CommandException("This command is not registered.");
+ }
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/command/DiscordCommand.java b/src/main/java/io/paradaux/friendlybot/bot/command/DiscordCommand.java
new file mode 100644
index 00000000..bb852084
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/command/DiscordCommand.java
@@ -0,0 +1,154 @@
+package io.paradaux.friendlybot.bot.command;
+
+import io.paradaux.friendlybot.FBApplication;
+import io.paradaux.friendlybot.core.data.config.FConfiguration;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.exceptions.NoSuchUserException;
+import net.dv8tion.jda.api.EmbedBuilder;
+import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.Member;
+import net.dv8tion.jda.api.entities.Message;
+import net.dv8tion.jda.api.entities.User;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.CheckReturnValue;
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+@Command(name = "undefined", description = "undefined", permission = "undefined")
+public abstract class DiscordCommand {
+
+ private final Logger logger = LoggerFactory.getLogger(DiscordCommand.class);
+
+ private boolean isRegistered;
+ private String command;
+ private String description;
+ private String permission;
+ private String[] aliases;
+
+ private List names;
+
+ public abstract void execute(FGuild guild, CommandBody body);
+
+ public void register(String command, String description, String permission, String[] aliases) {
+ isRegistered = true;
+ this.command = command;
+ this.description = description;
+ this.permission = permission;
+ this.aliases = aliases;
+ this.names = new ArrayList<>();
+ names.addAll(List.of(aliases));
+ names.add(command);
+ }
+
+ public void syntaxError(Message message) {
+ message.addReaction("\uD83D\uDEAB").queue();
+ EmbedBuilder builder = new EmbedBuilder();
+
+ builder.setColor(EmbedColour.ISSUE.getColour());
+ builder.setAuthor(message.getAuthor().getAsTag(), null, message.getAuthor().getAvatarUrl());
+ builder.setDescription("There was an error in your syntax.");
+ builder.setFooter("FriendlyBot v" + FBApplication.VERSION);
+
+ message.getChannel().sendMessageEmbeds(builder.build()).queue();
+ }
+
+ /**
+ * Used for commands which take a user as a parameter. Tries three ways of parsing the user. The first being by an @mention, the second
+ * by a tag (Username#Discriminator) then finally via their discord id. Returns the user object if found, otherwise null.
+ * */
+ @CheckReturnValue
+ @Nullable
+ public User parseTarget(Message message, String userInput) throws NoSuchUserException {
+ try {
+ if (message.getMentionedMembers().size() == 1) {
+ return message.getMentionedMembers().get(0).getUser();
+ }
+
+ User user;
+ try {
+ user = message.getGuild().getJDA().getUserByTag(userInput);
+ } catch (IllegalArgumentException ex) {
+ user = message.getJDA().retrieveUserById(userInput).submit().get();
+ }
+
+ return user;
+ } catch (InterruptedException | ExecutionException | NumberFormatException exception) {
+ throw new NoSuchUserException(exception.getMessage());
+ }
+ }
+
+ /**
+ * Gets a message by guild and user id.
+ * */
+ @CheckReturnValue
+ @Nullable
+ public Member retrieveMember(Guild guild, String userId) {
+ try {
+ return guild.retrieveMemberById(userId)
+ .submit()
+ .get();
+ } catch (InterruptedException | ExecutionException e) {
+ logger.error("Interrupted Exception", e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets a message by guild and User.
+ * */
+ @CheckReturnValue
+ @Nullable
+ public Member retrieveMember(Guild guild, User user) {
+ try {
+ return guild.retrieveMember(user)
+ .submit()
+ .get();
+ } catch (InterruptedException | ExecutionException e) {
+ logger.error("Interrupted Exception", e);
+ }
+
+ return null;
+ }
+
+ public FConfiguration getConfig() {
+ return FBApplication.getConfig();
+ }
+
+ public void unregister() {
+ isRegistered = false;
+ }
+
+ public boolean isRegistered() {
+ return isRegistered;
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Logger getLogger() {
+ return logger;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public String[] getAliases() {
+ return aliases;
+ }
+
+ public List getNames() {
+ return names;
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/command/PermissionHandler.java b/src/main/java/io/paradaux/friendlybot/bot/command/PermissionHandler.java
new file mode 100644
index 00000000..7b310f72
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/command/PermissionHandler.java
@@ -0,0 +1,4 @@
+package io.paradaux.friendlybot.bot.command;
+
+public class PermissionHandler {
+}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/command/exception/CommandException.java b/src/main/java/io/paradaux/friendlybot/bot/command/exception/CommandException.java
new file mode 100644
index 00000000..742f3423
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/command/exception/CommandException.java
@@ -0,0 +1,23 @@
+package io.paradaux.friendlybot.bot.command.exception;
+
+public class CommandException extends RuntimeException {
+
+ public CommandException() {
+ }
+
+ public CommandException(String message) {
+ super(message);
+ }
+
+ public CommandException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public CommandException(Throwable cause) {
+ super(cause);
+ }
+
+ public CommandException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/image/CatCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/image/CatCommand.java
new file mode 100644
index 00000000..5c30cc9f
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/image/CatCommand.java
@@ -0,0 +1,40 @@
+package io.paradaux.friendlybot.bot.commands.image;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.http.HttpApi;
+import net.dv8tion.jda.api.EmbedBuilder;
+import org.json.JSONArray;
+
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.concurrent.CompletableFuture;
+
+@Command(name="cat", description = "Get yourself a cute cat photo!", permission = "command.cat", aliases = {"feline", "kitten"})
+public class CatCommand extends DiscordCommand {
+
+ private static final String CAT_API = "https://api.thecatapi.com/v1/images/search";
+
+ public void execute(FGuild guild, CommandBody body) {
+ HttpApi http = new HttpApi(getLogger());
+ HttpRequest request = http.plainRequest(CAT_API);
+
+ CompletableFuture> responseFtr = http.sendAsync(request, HttpResponse.BodyHandlers.ofString());
+
+ if (responseFtr == null) {
+ throw new IllegalStateException("Cat: Response was null");
+ }
+
+ responseFtr.thenAccept((response) -> {
+ EmbedBuilder builder = new EmbedBuilder()
+ .setImage(new JSONArray(response.body()).getJSONObject(0).getString("url"))
+ .setColor(NumberUtils.randomColor())
+ .setFooter("For " + body.getUser().getName());
+
+ body.getMessage().getChannel().sendMessageEmbeds(builder.build()).queue();
+ }).join();
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/CoinFlipCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/image/CoinFlipCommand.java
similarity index 56%
rename from src/main/java/io/paradaux/friendlybot/commands/fun/CoinFlipCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/image/CoinFlipCommand.java
index 53211933..eaa3ee2f 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/CoinFlipCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/image/CoinFlipCommand.java
@@ -1,33 +1,25 @@
-package io.paradaux.friendlybot.commands.fun;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.RandomUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+package io.paradaux.friendlybot.bot.commands.image;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.RandomUtils;
import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
-import org.slf4j.Logger;
import java.util.concurrent.TimeUnit;
-public class CoinFlipCommand extends BaseCommand {
+@Command(name = "coinflip", description = "Provides a heads/tails result on a €2 coin", permission = "command.coinflip",
+ aliases = {"flip", "cf", "flipcoin"})
+public class CoinFlipCommand extends DiscordCommand {
private static final String COIN_FLIP_GIF = "https://media1.tenor.com/images/49dc6597439a635b1614544d8e090c54/tenor.gif";
private static final String[] TAILS_HEADS_IMAGES = {"https://cdn.paradaux.io/img/jurx4.png", "https://cdn.paradaux.io/img/ofco7.png"};
- public CoinFlipCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "coinflip";
- this.help = "Flips a coin";
- this.aliases = new String[]{"flip", "cf", "flipcoin"};
- }
-
@Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
-
+ public void execute(FGuild guild, CommandBody body) {
int result = new RandomUtils().pickRandomNumber(0, 1);
MessageEmbed waitingEmbed = new EmbedBuilder()
@@ -42,10 +34,10 @@ protected void execute(CommandEvent event) {
.setImage(TAILS_HEADS_IMAGES[result])
.build();
- event.getChannel().sendMessage(waitingEmbed).queue((sentMessage) -> {
+ body.getChannel().sendMessageEmbeds(waitingEmbed).queue((sentMessage) -> {
try {
TimeUnit.MILLISECONDS.sleep(1200);
- sentMessage.editMessage(resultEmbed).queue();
+ sentMessage.editMessageEmbeds(resultEmbed).queue();
} catch (InterruptedException e) {
getLogger().error("Interrupted whilst shaking the magic eight ball..");
}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/image/DogCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/image/DogCommand.java
new file mode 100644
index 00000000..8cee5ee0
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/image/DogCommand.java
@@ -0,0 +1,38 @@
+package io.paradaux.friendlybot.bot.commands.image;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.http.HttpApi;
+import net.dv8tion.jda.api.EmbedBuilder;
+import org.json.JSONObject;
+
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+
+@Command(name = "dog", description = "Get yourself a cute doggo pic!", permission = "command.dog", aliases = {"pupper",
+ "puppers", "pup", "doggo", "doggos"})
+public class DogCommand extends DiscordCommand {
+
+ private static final String DOG_API = "https://dog.ceo/api/breeds/image/random";
+
+ @Override
+ public void execute(FGuild guild, CommandBody body) {
+
+ HttpApi http = new HttpApi(getLogger());
+ HttpRequest request = http.plainRequest(DOG_API);
+
+ http.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenAccept((response) -> {
+ EmbedBuilder builder = new EmbedBuilder()
+ .setImage(new JSONObject(response.body()).getString("message"))
+ .setColor(NumberUtils.randomColor())
+ .setFooter("For " + body.getUser().getName());
+
+ body.getMessage().getChannel().sendMessageEmbeds(builder.build()).queue();
+ }).join();
+
+ }
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/EightBallCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/image/EightBallCommand.java
similarity index 74%
rename from src/main/java/io/paradaux/friendlybot/commands/fun/EightBallCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/image/EightBallCommand.java
index 6dc49a07..b21b8147 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/EightBallCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/image/EightBallCommand.java
@@ -23,43 +23,39 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.fun;
+package io.paradaux.friendlybot.bot.commands.image;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.stream.JsonReader;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.RandomUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.RandomUtils;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
-import org.slf4j.Logger;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-public class EightBallCommand extends BaseCommand {
+@Command(name = "eightball", description = "Asks the all knowing 8ball", permission = "command.eightball", aliases = {"8b", "8ball"})
+public class EightBallCommand extends DiscordCommand {
private static final String WAITING_IMAGE = "https://i.imgur.com/nBRPBMf.gif";
- private final JsonObject eightBallResponses;
+ private static final JsonObject eightBallResponses;
- public EightBallCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "eightball";
- this.help = "Asks the all knowing 8ball";
- this.aliases = new String[]{"8b", "8ball"};
-
- InputStream rawResponseData = getClass().getResourceAsStream("/data/8ball.json");
+ static {
+ InputStream rawResponseData = EightBallCommand.class.getResourceAsStream("/data/8ball.json");
JsonReader reader = new JsonReader(new InputStreamReader(rawResponseData));
- this.eightBallResponses = new Gson().fromJson(reader, JsonObject.class);
+ eightBallResponses = new Gson().fromJson(reader, JsonObject.class);
if (eightBallResponses == null) {
throw new RuntimeException("Eight ball responses not found.");
@@ -67,11 +63,11 @@ public EightBallCommand(ConfigurationEntry config, Logger logger) {
}
@Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
+ public void execute(FGuild guild, CommandBody body) {
+ Message message = body.getMessage();
- if (event.getArgs().isEmpty()) {
- respondSyntaxError(message, ";8ball ");
+ if (body.getArgs().length == 0) {
+ syntaxError(message);
}
RandomUtils rUtils = new RandomUtils(new Random());
@@ -121,6 +117,10 @@ protected void execute(CommandEvent event) {
color = 0xFF0000;
break;
}
+
+ default: {
+ throw new IllegalStateException("Invalid 8ball responses file.");
+ }
}
MessageEmbed responseEmbed = new EmbedBuilder()
@@ -128,10 +128,10 @@ protected void execute(CommandEvent event) {
.setTitle(response)
.build();
- event.getChannel().sendMessage(waitingEmbed).queue((sentMessage) -> {
+ body.getChannel().sendMessageEmbeds(waitingEmbed).queue((sentMessage) -> {
try {
TimeUnit.SECONDS.sleep(4);
- sentMessage.editMessage(responseEmbed).queue();
+ sentMessage.editMessageEmbeds(responseEmbed).queue();
} catch (InterruptedException e) {
getLogger().error("Interrupted whilst shaking the magic eight ball..");
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/InspireCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/image/InspireCommand.java
similarity index 69%
rename from src/main/java/io/paradaux/friendlybot/commands/fun/InspireCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/image/InspireCommand.java
index 16c43e94..7924a2b7 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/InspireCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/image/InspireCommand.java
@@ -23,32 +23,27 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.fun;
+package io.paradaux.friendlybot.bot.commands.image;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.EmbedBuilder;
-import org.slf4j.Logger;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-public class InspireCommand extends BaseCommand {
+@Command(name = "inspire", description = "Sends some heartwarming inspirational quotes!", permission = "command.inspire",
+ aliases = {"inspireme", "im"})
+public class InspireCommand extends DiscordCommand {
private static final String INSPIRE_API = "https://inspirobot.me/api?generate=true";
- public InspireCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "inspire";
- this.aliases = new String[]{"inspireme", "im"};
- this.help = "Sends some heartwarming inspirational quotes!.";
- }
-
@Override
- protected void execute(CommandEvent event) {
+ public void execute(FGuild guild, CommandBody body) {
HttpApi http = new HttpApi(getLogger());
HttpRequest request = http.plainRequest(INSPIRE_API);
@@ -57,9 +52,9 @@ protected void execute(CommandEvent event) {
EmbedBuilder builder = new EmbedBuilder()
.setImage(response.body())
.setColor(NumberUtils.randomColor())
- .setFooter("For " + event.getAuthor().getName());
+ .setFooter("For " + body.getUser().getName());
- event.getMessage().getChannel().sendMessage(builder.build()).queue();
+ body.getChannel().sendMessageEmbeds(builder.build()).queue();
}).join();
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/MemeCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/image/MemeCommand.java
similarity index 78%
rename from src/main/java/io/paradaux/friendlybot/commands/fun/MemeCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/image/MemeCommand.java
index c1fb5ff5..b47227e5 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/MemeCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/image/MemeCommand.java
@@ -23,14 +23,15 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.fun;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.HttpUtils;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.VerificationException;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+package io.paradaux.friendlybot.bot.commands.image;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.HttpUtils;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.models.exceptions.VerificationException;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
@@ -41,7 +42,6 @@
import okhttp3.RequestBody;
import org.json.JSONArray;
import org.json.JSONObject;
-import org.slf4j.Logger;
import java.io.IOException;
import java.io.Reader;
@@ -51,24 +51,17 @@
import java.util.Collections;
import java.util.List;
-public class MemeCommand extends BaseCommand {
+@Command(name = "meme", description = "Meme generation!", permission = "command.meme", aliases = {"m"})
+public class MemeCommand extends DiscordCommand {
private static final String GET_MEMES_API = "https://api.imgflip.com/get_memes";
public static final String CAPTION_MEMES_API = "https://api.imgflip.com/caption_image";
- public MemeCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "meme";
- this.aliases = new String[]{"m"};
- this.help = "Meme generation!";
- }
-
@Override
- protected void execute(CommandEvent event) {
- String[] args = getArgs(event.getArgs());
- Message message = event.getMessage();
+ public void execute(FGuild guild, CommandBody body) {
+ Message message = body.getMessage();
- switch (args[0]) {
+ switch (body.getArgs()[0]) {
case "images": {
message.reply("I'm sending you a list of available images in your DMs...").queue();
@@ -96,9 +89,9 @@ protected void execute(CommandEvent event) {
+ "](" + meme.getString("url") + ")", false);
}
- event.getAuthor().openPrivateChannel().queue((channel) -> {
+ body.getUser().openPrivateChannel().queue((channel) -> {
for (final var embed : embeds) {
- channel.sendMessage(embed).queue();
+ channel.sendMessageEmbeds(embed).queue();
}
});
}).join();
@@ -106,15 +99,15 @@ protected void execute(CommandEvent event) {
}
case "caption": {
- if (args.length < 5) {
- respondSyntaxError(message, ";meme caption | ");
+ if (body.getArgs().length < 5) {
+ syntaxError(message);
return;
}
- String id = args[1];
+ String id = body.getArgs()[1];
List args2 = new ArrayList<>();
- Collections.addAll(args2, args);
+ Collections.addAll(args2, body.getArgs());
args2.remove(0);
args2.remove(0);
@@ -139,11 +132,11 @@ protected void execute(CommandEvent event) {
bodyBuilder.addFormDataPart("text" + i, lines[i]);
}
- RequestBody body = bodyBuilder.build();
+ RequestBody reqBody = bodyBuilder.build();
Request request = new Request.Builder()
.url(CAPTION_MEMES_API)
- .method("POST", body)
+ .method("POST", reqBody)
.build();
HttpUtils.sendAsync(client, request).thenAccept((response -> {
@@ -163,9 +156,9 @@ protected void execute(CommandEvent event) {
EmbedBuilder builder = new EmbedBuilder()
.setImage(responseJson.getJSONObject("data").getString("url"))
.setColor(NumberUtils.randomColor())
- .setFooter("For " + event.getAuthor().getName());
+ .setFooter("For " + body.getUser().getName());
- event.getChannel().sendMessage(builder.build()).queue();
+ body.getChannel().sendMessage(builder.build()).queue();
} catch (IOException ok) {
getLogger().error("Error occurred whilst interacting with mailgun.");
@@ -177,7 +170,7 @@ protected void execute(CommandEvent event) {
}
default: {
- respondSyntaxError(message, ";meme <| separated text blocks>");
+ syntaxError(message);
break;
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/MonkeyCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/image/MonkeyCommand.java
similarity index 61%
rename from src/main/java/io/paradaux/friendlybot/commands/fun/MonkeyCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/image/MonkeyCommand.java
index 5a796f2d..2ca524e4 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/MonkeyCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/image/MonkeyCommand.java
@@ -1,31 +1,25 @@
-package io.paradaux.friendlybot.commands.fun;
+package io.paradaux.friendlybot.bot.commands.image;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.EmbedBuilder;
import org.json.JSONObject;
-import org.slf4j.Logger;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-public class MonkeyCommand extends BaseCommand {
+@Command(name = "monkey", description = "Get a monkey image !", permission = "command.monkey")
+public class MonkeyCommand extends DiscordCommand {
private static final String MONKEY_API = "https://www.placemonkeys.com/500/350?random";
private static final String IMGUR_API = "https://api.imgur.com/3/upload/";
- public MonkeyCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "monkey";
- this.aliases = new String[0];
- this.help = "Get a monkey image !";
- }
-
@Override
- protected void execute(CommandEvent event) {
+ public void execute(FGuild guild, CommandBody body) {
HttpApi http = new HttpApi(getLogger());
@@ -42,9 +36,9 @@ protected void execute(CommandEvent event) {
EmbedBuilder builder = new EmbedBuilder()
.setColor(NumberUtils.randomColor())
.setImage(imgurMeta.getJSONObject("data").getString("link"))
- .setFooter("For " + event.getAuthor().getName());
+ .setFooter("For " + body.getUser().getName());
- event.getChannel().sendMessage(builder.build()).queue();
+ body.getChannel().sendMessageEmbeds(builder.build()).queue();
}).join();
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/XKCDCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/image/XKCDCommand.java
similarity index 79%
rename from src/main/java/io/paradaux/friendlybot/commands/fun/XKCDCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/image/XKCDCommand.java
index 02fa9cba..fc8a0e02 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/XKCDCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/image/XKCDCommand.java
@@ -23,47 +23,42 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.fun;
+package io.paradaux.friendlybot.bot.commands.image;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import org.json.JSONObject;
-import org.slf4j.Logger;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-public class XKCDCommand extends BaseCommand {
+@Command(name = "xkcd", description = "Links to the specified xkcd", permission = "command.xkcd")
+public class XKCDCommand extends DiscordCommand {
private static final String XKCD_SEARCH_API = "https://relevantxkcd.appspot.com/process?action=xkcd&query=%s";
private static final String XKCD_INFO_API = "https://xkcd.com/%s/info.0.json";
private static final String XKCD_PAGE_FORMAT = "https://xkcd.com/%s/";
private static final String XKCD_ICON = "https://webcomicshub.com/uploads/webcomics/xkcd-1280x1024.png";
- public XKCDCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "xkcd";
- this.help = "Links to the specified xkcd";
- }
-
@Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
- String args = event.getArgs();
+ public void execute(FGuild guild, CommandBody body) {
+ Message message = body.getMessage();
+ String[] args = body.getArgs();
- if (args == null || args.isEmpty()) {
- respondSyntaxError(message, ";xkcd ");
+ if (args == null || args.length == 0) {
+ syntaxError(message);
return;
}
HttpApi http = new HttpApi(getLogger());
- HttpRequest request = http.plainRequest(String.format(XKCD_SEARCH_API, args.replace(" ", "%20")));
+ HttpRequest request = http.plainRequest(String.format(XKCD_SEARCH_API, String.join("%20", args)));
http.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenAccept((response) -> {
String returnedId = response.body().split(" ")[2].replaceAll("\n","");
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/joke/CharmanderCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/joke/CharmanderCommand.java
new file mode 100644
index 00000000..21a54c2a
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/joke/CharmanderCommand.java
@@ -0,0 +1,39 @@
+package io.paradaux.friendlybot.bot.commands.joke;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.RandomUtils;
+import net.dv8tion.jda.api.EmbedBuilder;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+@Command(name = "charmander", description = "Cute charmander pics!", permission = "command.charmander", aliases = {"charm"})
+public class CharmanderCommand extends DiscordCommand {
+
+ private static final String CHARMANDER_API = "https://cdn.paradaux.io/static/charmander/";
+ private static final int CHARMANDER_COUNT = 38;
+ private static final List GIFS = new ArrayList<>();
+ private final RandomUtils random = new RandomUtils();
+
+ static {
+ Collections.addAll(GIFS, 26);
+ }
+
+ @Override
+ public void execute(FGuild guild, CommandBody body) {
+ int id = random.pickRandomNumber(1, CHARMANDER_COUNT);
+
+ EmbedBuilder builder = new EmbedBuilder()
+ .setImage(CHARMANDER_API + id + (GIFS.contains(id) ? ".gif" : ".jpg"))
+ .setColor(NumberUtils.randomColor())
+ .setFooter("For " + body.getUser().getName() + " Charmander ID: " + id);
+
+ body.getMessage().getChannel().sendMessageEmbeds(builder.build()).queue();
+ }
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/LmgtfyCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/joke/LmgtfyCommand.java
similarity index 72%
rename from src/main/java/io/paradaux/friendlybot/commands/fun/LmgtfyCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/joke/LmgtfyCommand.java
index 052095d7..4610c58e 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/LmgtfyCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/joke/LmgtfyCommand.java
@@ -23,32 +23,27 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.fun;
+package io.paradaux.friendlybot.bot.commands.joke;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
-import org.slf4j.Logger;
-public class LmgtfyCommand extends BaseCommand {
+@Command(name = "lmgtfy", description = "Let me lmgtfy for you...", permission = "command.lmgtfy")
+public class LmgtfyCommand extends DiscordCommand {
private static final String LMGTFY_LINK = "https://lmgtfy.com/?q=";
- public LmgtfyCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "lmgtfy";
- this.help = "Let me lmgtfy for you...";
- }
-
@Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
- String query = event.getArgs();
+ public void execute(FGuild guild, CommandBody body) {
+ Message message = body.getMessage();
+ String query = String.join(" ", body.getArgs());
if (query.isEmpty()) {
- respondSyntaxError(message, ";lmgtfy ");
+ syntaxError(message);
return;
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/MonkeCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/joke/MonkeCommand.java
similarity index 65%
rename from src/main/java/io/paradaux/friendlybot/commands/fun/MonkeCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/joke/MonkeCommand.java
index 51381cc6..269b8347 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/MonkeCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/joke/MonkeCommand.java
@@ -1,11 +1,13 @@
-package io.paradaux.friendlybot.commands.fun;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.HttpUtils;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.RandomUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+package io.paradaux.friendlybot.bot.commands.joke;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.bot.commands.image.MemeCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.HttpUtils;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.RandomUtils;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import okhttp3.MultipartBody;
@@ -13,14 +15,14 @@
import okhttp3.Request;
import okhttp3.RequestBody;
import org.json.JSONObject;
-import org.slf4j.Logger;
import java.io.IOException;
import java.io.Reader;
import java.util.Collections;
import java.util.HashSet;
-public class MonkeCommand extends BaseCommand {
+@Command(name = "monke", description = "MONKE.", permission = "command.monke", aliases = {})
+public class MonkeCommand extends DiscordCommand {
private static final HashSet MONKE_IDS = new HashSet<>();
@@ -28,15 +30,8 @@ public class MonkeCommand extends BaseCommand {
Collections.addAll(MONKE_IDS, "289081819", "200213111");
}
- public MonkeCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "monke";
- this.aliases = new String[]{"MONKE"};
- this.help = "MONKE.";
- }
-
@Override
- protected void execute(CommandEvent event) {
+ public void execute(FGuild guild, CommandBody body) {
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
@@ -45,20 +40,20 @@ protected void execute(CommandEvent event) {
.addFormDataPart("username", getConfig().getImgflipUsername())
.addFormDataPart("password", getConfig().getImgflipPassword());
- String[] lines = event.getArgs().split("\\|");
+ String[] lines = String.join(" ", body.getArgs()).split("\\|");
if (lines.length != 2) {
- respondSyntaxError(event.getMessage(), ";monke this is line one | this is line 2");
+ syntaxError(body.getMessage());
}
bodyBuilder.addFormDataPart("text0", lines[0]);
bodyBuilder.addFormDataPart("text1", lines[1]);
- RequestBody body = bodyBuilder.build();
+ RequestBody reqBody = bodyBuilder.build();
Request request = new Request.Builder()
.url(MemeCommand.CAPTION_MEMES_API)
- .method("POST", body)
+ .method("POST", reqBody)
.build();
HttpUtils.sendAsync(client, request).thenAccept((response -> {
@@ -75,9 +70,9 @@ protected void execute(CommandEvent event) {
JSONObject responseJson = new JSONObject(strBuilder.toString());
- MessageEmbed embed = new EmbedBuilder().setImage(responseJson.getJSONObject("data").getString("url")).setColor(NumberUtils.randomColor()).setFooter("For " + event.getAuthor().getName()).build();
+ MessageEmbed embed = new EmbedBuilder().setImage(responseJson.getJSONObject("data").getString("url")).setColor(NumberUtils.randomColor()).setFooter("For " + body.getUser().getName()).build();
- event.getChannel().sendMessage(embed).queue();
+ body.getChannel().sendMessage(embed).queue();
} catch (IOException ok) {
getLogger().error("Error occurred whilst interacting with Imgflip");
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/YodaifyCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/joke/YodaifyCommand.java
similarity index 75%
rename from src/main/java/io/paradaux/friendlybot/commands/fun/YodaifyCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/joke/YodaifyCommand.java
index bf47fcb9..0e0cf496 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/YodaifyCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/joke/YodaifyCommand.java
@@ -23,13 +23,15 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.fun;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.HttpUtils;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+package io.paradaux.friendlybot.bot.commands.joke;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.bot.commands.image.MemeCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.HttpUtils;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
@@ -38,32 +40,25 @@
import okhttp3.Request;
import okhttp3.RequestBody;
import org.json.JSONObject;
-import org.slf4j.Logger;
import java.io.IOException;
import java.io.Reader;
-public class YodaifyCommand extends BaseCommand {
+@Command(name = "yodaify", description = "Convert english into Yoga's Language!", permission = "command.yodaify", aliases = {"yoda", "yodify"})
+public class YodaifyCommand extends DiscordCommand {
private static final String YODA_IMAGE_ID = "14371066";
- public YodaifyCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "yodaify";
- this.aliases = new String[]{"yoda", "yodify"};
- this.help = "Convert english into Yoga's Language!";
- }
-
@Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
+ public void execute(FGuild guild, CommandBody body) {
+ Message message = body.getMessage();
- if (event.getArgs().isEmpty()) {
- respondSyntaxError(message, ";yoda ");
+ if (body.getArgs().length == 0) {
+ syntaxError(message);
return;
}
- String[] tokenisedSentence = event.getArgs().split("\\. *");
+ String[] tokenisedSentence = String.join(" ", body.getArgs()).split("\\. *");
StringBuilder builder = new StringBuilder();
@@ -86,11 +81,11 @@ protected void execute(CommandEvent event) {
bodyBuilder.addFormDataPart("text0", builder.toString());
- RequestBody body = bodyBuilder.build();
+ RequestBody reqBody = bodyBuilder.build();
Request request = new Request.Builder()
.url(MemeCommand.CAPTION_MEMES_API)
- .method("POST", body)
+ .method("POST", reqBody)
.build();
HttpUtils.sendAsync(client, request).thenAccept((response -> {
@@ -110,10 +105,10 @@ protected void execute(CommandEvent event) {
MessageEmbed embed = new EmbedBuilder()
.setImage(responseJson.getJSONObject("data").getString("url"))
.setColor(NumberUtils.randomColor())
- .setFooter("For " + event.getAuthor().getName())
+ .setFooter("For " + body.getUser().getName())
.build();
- event.getChannel().sendMessage(embed).queue();
+ body.getChannel().sendMessage(embed).queue();
} catch (IOException ok) {
getLogger().error("Error occurred whilst interacting with Imgflip");
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/AnnouncementCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/AnnouncementCommand.java
similarity index 92%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/moderation/AnnouncementCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/AnnouncementCommand.java
index 297a32cd..ac98f159 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/AnnouncementCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/AnnouncementCommand.java
@@ -1,10 +1,11 @@
-package io.paradaux.friendlybot.commands.staff.moderation;
+package io.paradaux.friendlybot.bot.commands.staff.admin;
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@@ -12,6 +13,7 @@
import java.util.regex.Pattern;
+@Command(name = "", description = "", permission = "", aliases = {})
public class AnnouncementCommand extends PrivilegedCommand {
private static final Pattern URL_PATTERN = Pattern.compile("^(http://|https://)?(www.)?([a-zA-Z0-9]+).[a-zA-Z0-9]*.[a-z]{3}.?([a-z]+)?");
@@ -26,6 +28,11 @@ public AnnouncementCommand(ConfigurationEntry config, Logger logger, PermissionM
@Override
protected void execute(CommandEvent event) {
+
+ if (!isStaff(event.getGuild(), event.getAuthor().getId())) {
+ return;
+ }
+
event.reply("Beginning to build an announcement.");
EmbedBuilder builder = new EmbedBuilder();
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/BanCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/BanCommand.java
similarity index 64%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/moderation/BanCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/BanCommand.java
index a33d129f..7cba62bc 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/BanCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/BanCommand.java
@@ -23,20 +23,18 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.moderation;
+package io.paradaux.friendlybot.bot.commands.staff.admin;
import com.jagrosh.jdautilities.command.CommandEvent;
import io.paradaux.friendlybot.FriendlyBot;
-import io.paradaux.friendlybot.managers.AuditManager;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.MongoManager;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.embeds.moderation.BannedEmbed;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.BanEntry;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
+import io.paradaux.friendlybot.managers.PunishmentManager;
+import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.User;
import org.slf4j.Logger;
/**
@@ -48,12 +46,16 @@
* @see FriendlyBot
* */
+@Command(name = "", description = "", permission = "", aliases = {})
public class BanCommand extends PrivilegedCommand {
+ private final PunishmentManager punishments;
+
public BanCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
super(config, logger, permissionManager);
this.name = "ban";
this.help = "Bans the specified user";
+ this.punishments = PunishmentManager.getInstance();
}
@Override
@@ -64,7 +66,7 @@ protected void execute(CommandEvent event) {
String[] args = getArgs(event.getArgs());
String authorID = event.getAuthor().getId();
- if (!isStaff(authorID)) {
+ if (!isStaff(event.getGuild(), authorID)) {
respondNoPermission(message, "[Moderator, Administrator]");
return;
}
@@ -74,41 +76,18 @@ protected void execute(CommandEvent event) {
return;
}
- User target = parseTarget(message, args[0]);
+ Member target = retrieveMember(event.getGuild(), args[0]);
if (target == null) {
message.getChannel().sendMessage("You did not specify a (valid) target.").queue();
return;
}
- if (isStaff(target.getId())) {
+ if (isStaff(event.getGuild(), target.getId())) {
message.getChannel().sendMessage("You cannot ban a staff member.").queue();
return;
}
- String incidentID = mongo.getNextIncidentID();
- String reason = parseSentance(1, args);
-
- BanEntry entry = new BanEntry()
- .setIncidentID(incidentID)
- .setReason(reason)
- .setStaffID(authorID)
- .setStaffTag(event.getAuthor().getAsTag())
- .setUserID(target.getId())
- .setUserTag(target.getAsTag());
-
- mongo.addBanEntry(entry);
- AuditManager.getInstance().log(ModerationAction.BAN, target,
- event.getAuthor(), reason, incidentID);
-
- message.getChannel().sendMessage("Incident ID: " + incidentID
- + "\nReason: " + reason).queue();
-
- BannedEmbed embed = new BannedEmbed(reason, incidentID);
- target.openPrivateChannel().queue((channel) -> channel.sendMessage(embed.getEmbed())
- .queue());
-
- message.getGuild().ban(target, 0).queue();
-
+ punishments.banUser(event.getGuild(), target, event.getMember(), event.getTextChannel(), parseSentance(1, args));
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/PruneCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/PruneCommand.java
similarity index 87%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/moderation/PruneCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/PruneCommand.java
index 28455070..bf0d897e 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/PruneCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/PruneCommand.java
@@ -23,15 +23,17 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.moderation;
+package io.paradaux.friendlybot.bot.commands.staff.admin;
import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import net.dv8tion.jda.api.entities.Message;
import org.slf4j.Logger;
+@Command(name = "", description = "", permission = "", aliases = {})
public class PruneCommand extends PrivilegedCommand {
public PruneCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
@@ -48,7 +50,7 @@ protected void execute(CommandEvent event) {
String[] args = getArgs(event.getArgs());
String authorID = event.getAuthor().getId();
- if (!isStaff(authorID)) {
+ if (!isStaff(event.getGuild(), authorID)) {
respondNoPermission(message, "[Moderator, Administrator]");
return;
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/SayCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/SayCommand.java
similarity index 83%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/technician/SayCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/SayCommand.java
index c99fec79..2575a6e0 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/SayCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/SayCommand.java
@@ -23,14 +23,16 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.technician;
+package io.paradaux.friendlybot.bot.commands.staff.admin;
import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import org.slf4j.Logger;
+@Command(name = "", description = "", permission = "", aliases = {})
public class SayCommand extends PrivilegedCommand {
public SayCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/SendEmbedCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/SendEmbedCommand.java
similarity index 83%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/technician/SendEmbedCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/SendEmbedCommand.java
index 4996a3ad..49119f3a 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/SendEmbedCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/SendEmbedCommand.java
@@ -23,25 +23,27 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.technician;
+package io.paradaux.friendlybot.bot.commands.staff.admin;
import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.embeds.AuditLogEmbed;
+import io.paradaux.friendlybot.core.utils.embeds.PoliticsRulesEmbed;
+import io.paradaux.friendlybot.core.utils.embeds.RulesEmbed;
+import io.paradaux.friendlybot.core.utils.embeds.moderation.*;
+import io.paradaux.friendlybot.core.utils.embeds.modmail.ModMailSentEmbed;
+import io.paradaux.friendlybot.core.utils.embeds.notices.*;
+import io.paradaux.friendlybot.core.utils.embeds.roleselection.PoliticsOptionEmbed;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.types.ModerationAction;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.embeds.AuditLogEmbed;
-import io.paradaux.friendlybot.utils.embeds.PoliticsRulesEmbed;
-import io.paradaux.friendlybot.utils.embeds.RulesEmbed;
-import io.paradaux.friendlybot.utils.embeds.moderation.*;
-import io.paradaux.friendlybot.utils.embeds.modmail.ModMailSentEmbed;
-import io.paradaux.friendlybot.utils.embeds.notices.*;
-import io.paradaux.friendlybot.utils.embeds.roleselection.PoliticsOptionEmbed;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;
import org.slf4j.Logger;
+@Command(name = "", description = "", permission = "", aliases = {})
public class SendEmbedCommand extends PrivilegedCommand {
public SendEmbedCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/VerificationCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/VerificationCommand.java
similarity index 92%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/technician/VerificationCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/VerificationCommand.java
index b95400b8..dcfe6454 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/VerificationCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/admin/VerificationCommand.java
@@ -23,19 +23,21 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.technician;
+package io.paradaux.friendlybot.bot.commands.staff.admin;
import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.VerificationException;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.MongoManager;
import io.paradaux.friendlybot.managers.PermissionManager;
import io.paradaux.friendlybot.managers.VerificationManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.VerificationException;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import org.slf4j.Logger;
+@Command(name = "", description = "", permission = "", aliases = {})
public class VerificationCommand extends PrivilegedCommand {
public VerificationCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/CiteCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/CiteCommand.java
similarity index 82%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/moderation/CiteCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/CiteCommand.java
index c3c0d25c..0c41ac28 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/CiteCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/CiteCommand.java
@@ -23,18 +23,20 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.moderation;
+package io.paradaux.friendlybot.bot.commands.staff.mod;
import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.embeds.moderation.CiteRuleEmbed;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.embeds.moderation.CiteRuleEmbed;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;
import org.slf4j.Logger;
+@Command(name = "", description = "", permission = "", aliases = {})
public class CiteCommand extends PrivilegedCommand {
public CiteCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
@@ -50,7 +52,7 @@ protected void execute(CommandEvent event) {
String[] args = getArgs(event.getArgs());
String authorID = event.getAuthor().getId();
- if (!isStaff(authorID)) {
+ if (!isStaff(event.getGuild(), authorID)) {
respondNoPermission(message, "[Moderator, Administrator]");
return;
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/DmCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/DmCommand.java
similarity index 59%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/technician/DmCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/DmCommand.java
index acf9f826..8f7ea431 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/DmCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/DmCommand.java
@@ -23,14 +23,17 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.technician;
+package io.paradaux.friendlybot.bot.commands.staff.mod;
import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
+import net.dv8tion.jda.api.entities.User;
import org.slf4j.Logger;
+@Command(name = "", description = "", permission = "", aliases = {})
public class DmCommand extends PrivilegedCommand {
public DmCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
@@ -42,7 +45,31 @@ public DmCommand(ConfigurationEntry config, Logger logger, PermissionManager per
@Override
protected void execute(CommandEvent event) {
- // TODO Command stub
+ if (!isStaff(event.getGuild(), event.getAuthor().getId())) {
+ respondNoPermission(event.getMessage(), "Moderator");
+ return;
+ }
+
+ String[] args = getArgs(event.getArgs());
+
+ if (args.length < 3) {
+ respondSyntaxError(event.getMessage(), ";dm ");
+ return;
+ }
+
+ User target = parseTarget(event.getMessage(), args[0]);
+
+ if (target == null) {
+ respondSyntaxError(event.getMessage(), ";dm ");
+ return;
+ }
+
+ target.openPrivateChannel().queue((channel) -> {
+ String message = parseSentance(1, args);
+ channel.sendMessage(message).queue();
+ event.getChannel().sendMessage("Sent `" + message + "` to target: " + target.getAsTag()).queue();
+ });
+
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/KickCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/KickCommand.java
new file mode 100644
index 00000000..5615d4b9
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/KickCommand.java
@@ -0,0 +1,91 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2021 RÃan Errity
+ * io.paradaux.friendlybot.commands.staff.moderation.KickCommand : 31/01/2021, 01:26
+ *
+ * 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 io.paradaux.friendlybot.bot.commands.staff.mod;
+
+import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.FriendlyBot;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
+import io.paradaux.friendlybot.managers.PermissionManager;
+import io.paradaux.friendlybot.managers.PunishmentManager;
+import net.dv8tion.jda.api.entities.Member;
+import net.dv8tion.jda.api.entities.Message;
+import org.slf4j.Logger;
+
+/**
+ * This is a command which kicks the specified user.
+ *
+ * @author RÃan Errity
+ * @version Last modified for 0.1.0-SNAPSHOT
+ * @since 4/11/2020 DD/MM/YY
+ * @see FriendlyBot
+ * */
+
+@Command(name = "", description = "", permission = "", aliases = {})
+public class KickCommand extends PrivilegedCommand {
+
+ private final PunishmentManager punishments;
+
+ public KickCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
+ super(config, logger, permissionManager);
+ this.name = "kick";
+ this.help = "Kicks the specified user";
+ this.punishments = PunishmentManager.getInstance();
+ }
+
+ @Override
+ protected void execute(CommandEvent event) {
+ Message message = event.getMessage();
+
+ String[] args = getArgs(event.getArgs());
+ String authorID = event.getAuthor().getId();
+
+ if (!isStaff(event.getGuild(), authorID)) {
+ respondNoPermission(message, "[Moderator, Administrator]");
+ return;
+ }
+
+ if (args.length < 2) {
+ respondSyntaxError(message, ";kick ");
+ return;
+ }
+
+ Member target = retrieveMember(event.getGuild(), args[0]);
+
+ if (target == null) {
+ message.getChannel().sendMessage("You did not specify a (valid) target.").queue();
+ return;
+ }
+
+ if (isStaff(event.getGuild(), target.getId())) {
+ message.getChannel().sendMessage("You cannot ban a staff member.").queue();
+ return;
+ }
+
+ punishments.kickUser(event.getGuild(), target, event.getMember(), event.getTextChannel(), parseSentance(1, args));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/LookupCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/LookupCommand.java
similarity index 89%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/moderation/LookupCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/LookupCommand.java
index d6de2ee3..4706f4cc 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/LookupCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/LookupCommand.java
@@ -23,24 +23,26 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.moderation;
+package io.paradaux.friendlybot.bot.commands.staff.mod;
import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.embeds.AuditLogEmbed;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.AuditLogEntry;
+import io.paradaux.friendlybot.core.utils.models.database.BanEntry;
+import io.paradaux.friendlybot.core.utils.models.database.KickEntry;
+import io.paradaux.friendlybot.core.utils.models.database.WarningEntry;
+import io.paradaux.friendlybot.core.utils.models.types.ModerationAction;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.MongoManager;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.embeds.AuditLogEmbed;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.AuditLogEntry;
-import io.paradaux.friendlybot.utils.models.database.BanEntry;
-import io.paradaux.friendlybot.utils.models.database.KickEntry;
-import io.paradaux.friendlybot.utils.models.database.WarningEntry;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import org.slf4j.Logger;
+@Command(name = "", description = "", permission = "", aliases = {})
public class LookupCommand extends PrivilegedCommand {
public LookupCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
@@ -56,7 +58,7 @@ protected void execute(CommandEvent event) {
String[] args = getArgs(event.getArgs());
String authorID = event.getAuthor().getId();
- if (!isStaff(authorID)) {
+ if (!isStaff(event.getGuild(), authorID)) {
respondNoPermission(message, "[Moderator, Administrator]");
return;
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/RespondCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/RespondCommand.java
similarity index 86%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/moderation/RespondCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/RespondCommand.java
index e6b898c2..f25da514 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/RespondCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/RespondCommand.java
@@ -23,16 +23,17 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.moderation;
+package io.paradaux.friendlybot.bot.commands.staff.mod;
import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.ModMailEntry;
+import io.paradaux.friendlybot.core.utils.models.database.ModMailResponse;
+import io.paradaux.friendlybot.core.utils.models.enums.TicketStatus;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.MongoManager;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.ModMailEntry;
-import io.paradaux.friendlybot.utils.models.database.ModMailResponse;
-import io.paradaux.friendlybot.utils.models.enums.TicketStatus;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import org.slf4j.Logger;
@@ -41,6 +42,7 @@
import java.util.Date;
import java.util.List;
+@Command(name = "", description = "", permission = "", aliases = {})
public class RespondCommand extends PrivilegedCommand {
private final MongoManager mongo;
@@ -58,7 +60,7 @@ protected void execute(CommandEvent event) {
String[] args = getArgs(event.getArgs());
String authorID = event.getAuthor().getId();
- if (!isStaff(authorID)) {
+ if (!isStaff(event.getGuild(), authorID)) {
respondNoPermission(message, "[Moderator, Administrator]");
return;
}
@@ -71,13 +73,13 @@ protected void execute(CommandEvent event) {
ModMailEntry entry = mongo.getModMailEntry(args[0]);
if (entry == null) {
- message.addReaction("\uD83D\uDEAB").queue();
+ message.addReaction("🚫").queue();
message.getChannel().sendMessage("That ticket was not found").queue();
return;
}
if (entry.getStatus() == TicketStatus.CLOSED) {
- message.addReaction("\uD83D\uDEAB").queue();
+ message.addReaction("🚫").queue();
message.getChannel().sendMessage("You cannot respond to closed tickets.").queue();
return;
}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/TempBanCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/TempBanCommand.java
new file mode 100644
index 00000000..19ff7240
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/TempBanCommand.java
@@ -0,0 +1,79 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2021 RÃan Errity
+ * io.paradaux.friendlybot.commands.staff.moderation.TempBanCommand : 06/02/2021, 18:10
+ *
+ * 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 io.paradaux.friendlybot.bot.commands.staff.mod;
+
+import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
+import io.paradaux.friendlybot.managers.MongoManager;
+import io.paradaux.friendlybot.managers.PermissionManager;
+import io.paradaux.friendlybot.managers.PunishmentManager;
+import net.dv8tion.jda.api.entities.Member;
+import net.dv8tion.jda.api.entities.Message;
+import org.slf4j.Logger;
+
+@Command(name = "", description = "", permission = "", aliases = {})
+public class TempBanCommand extends PrivilegedCommand {
+
+ private final MongoManager mongo;
+ private final PunishmentManager punishments;
+
+ public TempBanCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager, MongoManager mongo) {
+ super(config, logger, permissionManager);
+ this.mongo = mongo;
+ this.name = "tempban";
+ this.help = "Temporarily bans a user.";
+ this.punishments = PunishmentManager.getInstance();
+ }
+
+ @Override
+ protected void execute(CommandEvent event) {
+
+ Member staff = event.getMember();
+ Message message = event.getMessage();
+ String[] args = getArgs(event.getArgs());
+
+ if (!isStaff(event.getGuild(), staff.getId())) {
+ respondNoPermission(message, "[Moderator, Administrator]");
+ return;
+ }
+
+ if (event.getArgs().isEmpty()) {
+ respondSyntaxError(message, ";tempban ");
+ return;
+ }
+
+ Member target = retrieveMember(event.getGuild(), args[0]);
+
+ if (target == null) {
+ message.reply("User does not exist.").queue();
+ return;
+ }
+
+ punishments.tempBanUser(event.getGuild(), target, event.getMember(), event.getTextChannel(), args[1], parseSentance(2, args));
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/TicketCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/TicketCommand.java
similarity index 90%
rename from src/main/java/io/paradaux/friendlybot/commands/staff/moderation/TicketCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/TicketCommand.java
index 65d9581f..e4847a57 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/TicketCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/TicketCommand.java
@@ -23,19 +23,20 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.staff.moderation;
+package io.paradaux.friendlybot.bot.commands.staff.mod;
import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.TimeUtils;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.ModMailEntry;
+import io.paradaux.friendlybot.core.utils.models.database.ModMailResponse;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.enums.TicketStatus;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
import io.paradaux.friendlybot.managers.DiscordBotManager;
import io.paradaux.friendlybot.managers.MongoManager;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.TimeUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.ModMailEntry;
-import io.paradaux.friendlybot.utils.models.database.ModMailResponse;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.enums.TicketStatus;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
@@ -45,6 +46,7 @@
import java.util.List;
+@Command(name = "", description = "", permission = "", aliases = {})
public class TicketCommand extends PrivilegedCommand {
public TicketCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
@@ -61,7 +63,7 @@ protected void execute(CommandEvent event) {
String ticketNumber;
- if (!isStaff(message.getAuthor().getId())) {
+ if (!isStaff(event.getGuild(), message.getAuthor().getId())) {
respondNoPermission(message, "[Moderator, Administrator]");
return;
}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/WarnCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/WarnCommand.java
new file mode 100644
index 00000000..b04880a6
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/staff/mod/WarnCommand.java
@@ -0,0 +1,87 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2021 RÃan Errity
+ * io.paradaux.friendlybot.commands.staff.moderation.WarnCommand : 31/01/2021, 01:26
+ *
+ * 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 io.paradaux.friendlybot.bot.commands.staff.mod;
+
+import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.FriendlyBot;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.PrivilegedCommand;
+import io.paradaux.friendlybot.managers.PermissionManager;
+import io.paradaux.friendlybot.managers.PunishmentManager;
+import net.dv8tion.jda.api.entities.Member;
+import net.dv8tion.jda.api.entities.Message;
+import org.slf4j.Logger;
+
+/**
+ * This is a command which warns the specified user.
+ *
+ * @author RÃan Errity
+ * @version Last modified for 0.1.0-SNAPSHOT
+ * @since 4/11/2020 DD/MM/YY
+ * @see FriendlyBot
+ * */
+
+@Command(name = "", description = "", permission = "", aliases = {})
+public class WarnCommand extends PrivilegedCommand {
+
+ private final PunishmentManager punishments;
+
+ public WarnCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
+ super(config, logger, permissionManager);
+ this.name = "warn";
+ this.aliases = new String[]{"w"};
+ this.help = "Warns the specified user";
+ this.punishments = PunishmentManager.getInstance();
+ }
+
+ @Override
+ protected void execute(CommandEvent event) {
+ Message message = event.getMessage();
+
+ String[] args = getArgs(event.getArgs());
+ String authorID = event.getAuthor().getId();
+
+ if (!isStaff(event.getGuild(), authorID)) {
+ respondNoPermission(message, "[Moderator, Administrator]");
+ return;
+ }
+
+ if (args.length < 2) {
+ respondSyntaxError(message, ";warn ");
+ return;
+ }
+
+ Member target = retrieveMember(event.getGuild(), args[0]);
+
+ if (target == null) {
+ message.getChannel().sendMessage("You did not specify a (valid) target.").queue();
+ return;
+ }
+
+ punishments.warnUser(event.getGuild(), target, event.getMember(), event.getTextChannel(), parseSentance(1, args));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/test/CreateUser.java b/src/main/java/io/paradaux/friendlybot/bot/commands/test/CreateUser.java
new file mode 100644
index 00000000..90bfc94d
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/test/CreateUser.java
@@ -0,0 +1,28 @@
+package io.paradaux.friendlybot.bot.commands.test;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.data.database.models.FUser;
+
+import java.util.Date;
+
+@Command(name="createuser", permission = "commands.createuser", description = "wefwe")
+public class CreateUser extends DiscordCommand {
+
+ @Override
+ public void execute(FGuild guild, CommandBody body) {
+ FUser user = new FUser();
+
+ user.setId(0);
+ user.setUserId("wefwef");
+ user.setCustomColorRole("wefwef");
+ user.setGuild(guild);
+ user.setLastChangedColor(new Date());
+
+
+ guild.getUsers().add(user);
+ guild.save();
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/util/ClearColorCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/ClearColorCommand.java
new file mode 100644
index 00000000..e1baefbe
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/ClearColorCommand.java
@@ -0,0 +1,54 @@
+package io.paradaux.friendlybot.bot.commands.util;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.models.database.UserSettingsEntry;
+import io.paradaux.friendlybot.managers.UserSettingsManager;
+import net.dv8tion.jda.api.EmbedBuilder;
+import net.dv8tion.jda.api.entities.Message;
+import net.dv8tion.jda.api.entities.Role;
+
+import java.util.List;
+
+@Command(name = "clearcolor", description = "Clear a custom-color role.", permission = "util.usercolor", aliases = {"clearcolour"})
+public class ClearColorCommand extends DiscordCommand {
+
+ @Override
+ public void execute(FGuild guild, CommandBody body) {
+ Message message = body.getMessage();
+
+ UserSettingsManager settings = UserSettingsManager.getInstance();
+ UserSettingsEntry entry = settings.getProfileById(guild.getGuild().getId(), body.getUser().getId());
+
+ if (entry.getCustomColorRole() == null) {
+ message.reply("You do not have a custom color.").queue();
+ return;
+ }
+
+ List customRoles = guild.getGuild().getRolesByName(entry.getCustomColorRole(), true);
+
+ if (customRoles.size() == 0) {
+ message.reply("An error occurred in that you appear to have an invalid custom color.").queue();
+ return;
+ }
+
+ guild.getGuild().removeRoleFromMember(body.getMember(), customRoles.get(0)).queue((success) -> {
+ String customColor = entry.getCustomColorRole();
+ entry.setCustomColorRole(null);
+ settings.updateSettingsProfile(entry);
+
+ if (settings.getProfileCountByColor(guild.getGuild().getId(), customColor) == 0) {
+ customRoles.get(0).delete().queue();
+ }
+
+ message.getChannel().sendMessageEmbeds(new EmbedBuilder()
+ .setColor(NumberUtils.randomColor())
+ .setTitle("Your custom color role has been cleared.")
+ .setDescription("This has not had any effect on your 3-day cooldown, you may not modify your color again until that has expired.")
+ .build()).queue();
+ });
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/CommandsCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/CommandsCommand.java
similarity index 80%
rename from src/main/java/io/paradaux/friendlybot/commands/utility/CommandsCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/util/CommandsCommand.java
index 38f612d7..65a8d54a 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/CommandsCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/CommandsCommand.java
@@ -23,15 +23,15 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.utility;
+package io.paradaux.friendlybot.bot.commands.util;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.TimeUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.TimeUtils;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
-import org.slf4j.Logger;
import java.io.BufferedReader;
import java.io.InputStream;
@@ -39,7 +39,8 @@
import java.util.Date;
import java.util.stream.Collectors;
-public class CommandsCommand extends BaseCommand {
+@Command(name = "commands", description = "Command Information Embed", permission = "command.commands", aliases = {})
+public class CommandsCommand extends DiscordCommand {
private static final String THUMBNAIL_IMAGE = "https://cdn.paradaux.io/img/ybv70.png";
private static final String THIS_EMOJI = "";
@@ -48,11 +49,7 @@ public class CommandsCommand extends BaseCommand {
private final String utilityCommandContent2;
- public CommandsCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "commands";
- this.help = "Command Information Embed";
-
+ public CommandsCommand() {
InputStream inputStream = getClass().getResourceAsStream("/data/funcommands.txt");
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
this.funCommandContent = reader.lines().collect(Collectors.joining("\n"));
@@ -67,8 +64,8 @@ public CommandsCommand(ConfigurationEntry config, Logger logger) {
}
@Override
- protected void execute(CommandEvent event) {
- event.getMessage().delete().queue();
+ public void execute(FGuild guild, CommandBody body) {
+ body.getMessage().delete().queue();
MessageEmbed funCommands = new EmbedBuilder()
.setTitle("FriendlyBot » Commands")
@@ -84,7 +81,7 @@ protected void execute(CommandEvent event) {
.setFooter("Last updated: " + TimeUtils.formatTime(new Date()), "https://cdn.paradaux.io/img/fteuv.png")
.build();
- event.getChannel().sendMessage(funCommands).queue();
- event.getChannel().sendMessage(utilityCommands).queue();
+ body.getChannel().sendMessageEmbeds(funCommands).queue();
+ body.getChannel().sendMessageEmbeds(utilityCommands).queue();
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/InviteCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/InviteCommand.java
similarity index 69%
rename from src/main/java/io/paradaux/friendlybot/commands/utility/InviteCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/util/InviteCommand.java
index f0e50c10..a1a73691 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/InviteCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/InviteCommand.java
@@ -23,13 +23,13 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.utility;
+package io.paradaux.friendlybot.bot.commands.util;
-import com.jagrosh.jdautilities.command.CommandEvent;
import io.paradaux.friendlybot.FriendlyBot;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import net.dv8tion.jda.api.entities.Message;
-import org.slf4j.Logger;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
/**
* This is a command which provides the user with an invite link to the current discord server.
@@ -40,24 +40,14 @@
* @see FriendlyBot
* */
-public class InviteCommand extends BaseCommand {
-
- public InviteCommand(Logger logger) {
- super(logger);
- this.name = "invite";
- this.aliases = new String[]{"inv", "i"};
- this.help = "Provides the user with an invite link to invite the bot.";
- }
+@Command(name = "invite", description = "Provides the user with an invite link to invite the bot.", permission = "commands.invite", aliases = {})
+public class InviteCommand extends DiscordCommand {
@Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
-
- String inviteInfo = "This is a utility discord bot for moderating discord servers pertaining to computer science, with a "
+ public void execute(FGuild guild, CommandBody body) {
+ body.getMessage().getChannel().sendMessage("This is a utility discord bot for moderating discord servers pertaining to computer science, with a "
+ "markov chain-backed artificial intelligence. This particular instance of the bot is hosted by RÃan#6500.\n\n" + "There "
+ "is nothing stopping anyone from starting their own instance, but you will require an SMTP Login to make use " + "of the"
- + " email verification, and a mongodb database for everything else.";
-
- message.getChannel().sendMessage(inviteInfo).queue();
+ + " email verification, and a mongodb database for everything else.").queue();
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/MemeImagesCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/MemeImagesCommand.java
similarity index 80%
rename from src/main/java/io/paradaux/friendlybot/commands/utility/MemeImagesCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/util/MemeImagesCommand.java
index 2d3c0bd9..ff7982ca 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/MemeImagesCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/MemeImagesCommand.java
@@ -23,35 +23,30 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.utility;
+package io.paradaux.friendlybot.bot.commands.util;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.TimeUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.TimeUtils;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.EmbedBuilder;
import org.json.JSONArray;
import org.json.JSONObject;
-import org.slf4j.Logger;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Date;
-public class MemeImagesCommand extends BaseCommand {
+@Command(name = "memeimages", description = "Shows every possible meme image", permission = "commands.memeimages", aliases = {})
+public class MemeImagesCommand extends DiscordCommand {
private static final String GET_MEMES_API = "https://api.imgflip.com/get_memes";
- public MemeImagesCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "memeimages";
- this.help = "Shows every possible meme image";
- }
-
@Override
- protected void execute(CommandEvent event) {
+ public void execute(FGuild guild, CommandBody body) {
HttpApi http = new HttpApi();
HttpRequest request = http.plainRequest(GET_MEMES_API);
@@ -69,7 +64,7 @@ protected void execute(CommandEvent event) {
.setDescription("**ID:** " + meme.getString("id") + "\n**Line count:** " + meme.getInt("box_count"))
.setImage(meme.getString("url"));
- event.getChannel().sendMessage(builder.build()).queue();
+ body.getChannel().sendMessage(builder.build()).queue();
}
EmbedBuilder builder = new EmbedBuilder()
@@ -82,7 +77,7 @@ protected void execute(CommandEvent event) {
.addField(";meme caption 222403160 Meme Documentation | For you to read the documentation", "Caption memes by specifying the ID, then each line separated by a pipe (|)", false)
.setFooter("Last updated: " + TimeUtils.formatTime(new Date()), "https://cdn.paradaux.io/img/fteuv.png");
- event.getChannel().sendMessage(builder.build()).queue();
+ body.getChannel().sendMessage(builder.build()).queue();
}).join();
}
}
\ No newline at end of file
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/PingCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/PingCommand.java
similarity index 72%
rename from src/main/java/io/paradaux/friendlybot/commands/utility/PingCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/util/PingCommand.java
index fb5806b4..937fd2d6 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/PingCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/PingCommand.java
@@ -23,12 +23,13 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.utility;
+package io.paradaux.friendlybot.bot.commands.util;
-import com.jagrosh.jdautilities.command.CommandEvent;
import io.paradaux.friendlybot.FriendlyBot;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import org.slf4j.Logger;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
/**
* Ping Command is used to gauge DiscordAPI Latency.
@@ -39,17 +40,11 @@
* @see FriendlyBot
* */
-
-public class PingCommand extends BaseCommand {
-
- public PingCommand(Logger logger) {
- super(logger);
- this.name = "ping";
- this.help = "Latency Test Command.";
- }
+@Command(name = "ping", description = "Test bot latency", permission = "commands.ping", aliases = {})
+public class PingCommand extends DiscordCommand {
@Override
- protected void execute(CommandEvent event) {
- event.getChannel().sendMessage("Pong!").queue();
+ public void execute(FGuild guild, CommandBody body) {
+ body.getChannel().sendMessage("Pong!").queue();
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/RandomColorCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/RandomColorCommand.java
similarity index 60%
rename from src/main/java/io/paradaux/friendlybot/commands/utility/RandomColorCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/util/RandomColorCommand.java
index c725dcbe..ef49c49f 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/RandomColorCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/RandomColorCommand.java
@@ -1,33 +1,27 @@
-package io.paradaux.friendlybot.commands.utility;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.ImageUtils;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+package io.paradaux.friendlybot.bot.commands.util;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.ImageUtils;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.EmbedBuilder;
import org.json.JSONObject;
-import org.slf4j.Logger;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-public class RandomColorCommand extends BaseCommand {
+@Command(name = "randomcolor", description = "Get a random Hex RGB Color", permission = "commands.randomcolor", aliases = {"randomcolour"})
+public class RandomColorCommand extends DiscordCommand {
private static final String IMGUR_API = "https://api.imgur.com/3/upload/";
- public RandomColorCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "randomcolor";
- this.aliases = new String[]{"randomcolour"};
- this.help = "Get a random Hex RGB Color";
- }
-
@Override
- protected void execute(CommandEvent event) {
+ public void execute(FGuild guild, CommandBody body) {
short color = NumberUtils.randomColor();
EmbedBuilder embed = new EmbedBuilder()
@@ -40,7 +34,7 @@ protected void execute(CommandEvent event) {
imageRaw = ImageUtils.imageToBytes(image, "png");
} catch (IOException ok) {
getLogger().error("An error occurred while creating a solid-color image.");
- event.getMessage().reply("An error occurred whilst creating a solid-color image").queue();
+ body.getMessage().reply("An error occurred whilst creating a solid-color image").queue();
return;
}
@@ -52,7 +46,7 @@ protected void execute(CommandEvent event) {
http.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenAccept((response -> {
JSONObject imgurMeta = new JSONObject(response.body());
embed.setImage(imgurMeta.getJSONObject("data").getString("link"));
- event.getChannel().sendMessage(embed.build()).queue();
+ body.getChannel().sendMessage(embed.build()).queue();
})).join();
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/ServerInfoCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/ServerInfoCommand.java
similarity index 59%
rename from src/main/java/io/paradaux/friendlybot/commands/utility/ServerInfoCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/util/ServerInfoCommand.java
index 91b4a259..868f9556 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/ServerInfoCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/ServerInfoCommand.java
@@ -23,35 +23,28 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.utility;
+package io.paradaux.friendlybot.bot.commands.util;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Emote;
-import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
-import org.slf4j.Logger;
import java.util.List;
-public class ServerInfoCommand extends BaseCommand {
-
- public ServerInfoCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "serverinfo";
- this.help = "Provides information about the server.";
- this.aliases = new String[]{"si, srvinfo"};
- }
+@Command(name = "serverinfo", description = "Provides information about the server", permission = "commands.serverinfo", aliases = {"si", "srvinfo"})
+public class ServerInfoCommand extends DiscordCommand {
@Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
- Guild guild = event.getGuild();
+ public void execute(FGuild guild, CommandBody body) {
+ Message message = body.getMessage();
+
- List emotes = guild.getEmotes();
+ List emotes = guild.getGuild().getEmotes();
StringBuilder builder = new StringBuilder();
for (final var emote : emotes) {
@@ -59,14 +52,13 @@ protected void execute(CommandEvent event) {
}
MessageEmbed embed = new EmbedBuilder()
- .setTitle(guild.getName() + " » Server Information")
+ .setTitle(guild.getGuild().getName() + " » Server Information")
.setColor(0x009999)
- .setThumbnail(guild.getIconUrl())
- .addField("Owner", retrieveMember(guild, guild.getOwnerId()).getUser().getAsTag(), true)
- .addField("Member Count", String.valueOf(guild.getMemberCount()), true)
-// .addField("Emojis", emotes.size() + ": " + builder.toString(), false)
+ .setThumbnail(guild.getGuild().getIconUrl())
+ .addField("Owner", retrieveMember(guild.getGuild(), guild.getGuild().getOwnerId()).getUser().getAsTag(), true)
+ .addField("Member Count", String.valueOf(guild.getGuild().getMemberCount()), true)
.build();
- message.getChannel().sendMessage(embed).queue();
+ message.getChannel().sendMessageEmbeds(embed).queue();
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/SetColorCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/SetColorCommand.java
similarity index 57%
rename from src/main/java/io/paradaux/friendlybot/commands/utility/SetColorCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/util/SetColorCommand.java
index 1ccf7e35..11def3ee 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/SetColorCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/SetColorCommand.java
@@ -1,45 +1,42 @@
-package io.paradaux.friendlybot.commands.utility;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.managers.MongoManager;
+package io.paradaux.friendlybot.bot.commands.util;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.models.database.UserSettingsEntry;
import io.paradaux.friendlybot.managers.RoleManager;
-import io.paradaux.friendlybot.managers.SettingsManager;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.UserSettingsEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.managers.UserSettingsManager;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.Role;
-import org.slf4j.Logger;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
-public class SetColorCommand extends BaseCommand {
+@Command(name = "setcolor", description = "Set your own user color!", permission = "util.usercolor", aliases = {"setcolour"})
+public class SetColorCommand extends DiscordCommand {
private static final short COOLDOWN = 7;
private static final Pattern HEX_PATTERN = Pattern.compile("(0x)?[0-9a-f]+");
private final RoleManager roles;
- public SetColorCommand(ConfigurationEntry config, Logger logger, RoleManager roles) {
- super(config, logger);
- this.name = "setcolor";
- this.aliases = new String[]{"setcolour"};
+ public SetColorCommand(RoleManager roles) {
this.roles = roles;
}
@Override
- protected void execute(CommandEvent event) {
- final Message message = event.getMessage();
- final Guild guild = event.getGuild();
- final String chosenColor = event.getArgs().replace("0x", "").toUpperCase();
+ public void execute(FGuild guild, CommandBody body) {
+ final Message message = body.getMessage();
+ final Guild jDuild = guild.getGuild();
+ final String chosenColor = body.getArgStr().replace("0x", "").toUpperCase();
- if (event.getArgs().isEmpty()) {
- event.getChannel().sendMessage(new EmbedBuilder()
+ if (body.isArgsEmpty()) {
+ body.getChannel().sendMessageEmbeds(new EmbedBuilder()
.setColor(NumberUtils.randomColor())
.setTitle("Setting Your Uniquely Coloured Role")
.setDescription("To get your own coloured role, run `;setcolour `. This has a 3 day cooldown, so make sure "
@@ -50,7 +47,7 @@ protected void execute(CommandEvent event) {
}
if (!(HEX_PATTERN.matcher(chosenColor).results().count() > 0)) {
- message.getChannel().sendMessage(new EmbedBuilder()
+ message.getChannel().sendMessageEmbeds(new EmbedBuilder()
.setColor(0xeb5132)
.setTitle("Invalid Hex Color")
.setDescription("Please format your color as a hex string between `000000` and `FFFFFF`")
@@ -58,8 +55,8 @@ protected void execute(CommandEvent event) {
return;
}
- SettingsManager settings = SettingsManager.getInstance();
- UserSettingsEntry entry = settings.getProfileById(guild.getId(), event.getAuthor().getId());
+ UserSettingsManager settings = UserSettingsManager.getInstance();
+ UserSettingsEntry entry = settings.getProfileById(jDuild.getId(), body.getUser().getId());
if (entry.getLastSetColor() != null && !settings.hasCooldownElapsed(entry)) {
message.reply("You must wait until your cooldown expires before running this command again.").queue();
return;
@@ -70,16 +67,16 @@ protected void execute(CommandEvent event) {
return;
}
- List allRoles = guild.getRolesByName("Color Roles Begin Here", true);
+ List allRoles = jDuild.getRolesByName("Color Roles Begin Here", true);
if (allRoles.isEmpty()) {
throw new RuntimeException("Color role separator not present.");
}
Role separatorRole = allRoles.get(0);
- if (roles.checkForConflicts(guild, chosenColor)) {
+ if (roles.checkForConflicts(jDuild, chosenColor)) {
// role already exists, let's not create a duplicate
- guild.addRoleToMember(event.getMember(), guild.getRolesByName(chosenColor, true).get(0)).queue();
+ jDuild.addRoleToMember(body.getMember(), jDuild.getRolesByName(chosenColor, true).get(0)).queue();
entry.setCustomColorRole(chosenColor)
.setLastSetColor(new Date());
@@ -88,9 +85,9 @@ protected void execute(CommandEvent event) {
return;
}
- roles.createRole(guild, chosenColor).queue((role -> {
- guild.modifyRolePositions().selectPosition(role).moveTo(separatorRole.getPosition() - 1).queue();
- guild.addRoleToMember(event.getMember(), role).queue();
+ roles.createRole(jDuild, chosenColor).queue((role -> {
+ jDuild.modifyRolePositions().selectPosition(role).moveTo(separatorRole.getPosition() - 1).queue();
+ jDuild.addRoleToMember(body.getMember(), role).queue();
entry.setCustomColorRole(chosenColor)
.setLastSetColor(new Date());
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/TagCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/TagCommand.java
similarity index 60%
rename from src/main/java/io/paradaux/friendlybot/commands/utility/TagCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/util/TagCommand.java
index 56b27c0d..8f82a392 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/TagCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/TagCommand.java
@@ -16,53 +16,49 @@
*
* 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
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO body 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 io.paradaux.friendlybot.commands.utility;
+package io.paradaux.friendlybot.bot.commands.util;
-import com.jagrosh.jdautilities.command.CommandEvent;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.StringUtils;
+import io.paradaux.friendlybot.core.utils.TimeUtils;
+import io.paradaux.friendlybot.core.utils.models.database.TagEntry;
import io.paradaux.friendlybot.managers.MongoManager;
import io.paradaux.friendlybot.managers.TagManager;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.TimeUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.TagEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
-import net.dv8tion.jda.api.entities.User;
-import org.slf4j.Logger;
import java.util.Date;
import java.util.Locale;
-public class TagCommand extends PrivilegedCommand {
+@Command(name = "tag", description = "Manage tags", permission = "util.managetags", aliases = {"t"})
+public class TagCommand extends DiscordCommand {
private final MongoManager mongo;
- public TagCommand(ConfigurationEntry config, Logger logger, MongoManager mongo) {
- super(config, logger);
+ public TagCommand(MongoManager mongo) {
this.mongo = mongo;
- this.name = "tag";
- this.help = "Manage tags.";
}
@Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
- String[] args = getArgs(event.getArgs());
+ public void execute(FGuild guild, CommandBody body) {
+ Message message = body.getMessage();
+ String[] args = body.getArgs();
if (args.length == 0) {
- respondSyntaxError(message, ";tag [id] [content]");
+ syntaxError(message);
return;
}
@@ -70,23 +66,23 @@ protected void execute(CommandEvent event) {
switch (args[0]) {
case "create": {
- TagEntry entry = tags.getTagById(event.getGuild().getId(), args[1].toLowerCase(Locale.ROOT));
+ TagEntry entry = tags.getTagById(guild.getGuild().getId(), args[1].toLowerCase(Locale.ROOT));
if (entry != null) {
MessageEmbed embed = new EmbedBuilder()
.setColor(0xeb5132)
.setTitle("This tag already exists")
- .setDescription("This tag is owned by " + retrieveMember(event.getGuild(), entry.getDiscordId()))
+ .setDescription("This tag is owned by " + retrieveMember(guild.getGuild(), entry.getDiscordId()))
.build();
- message.getChannel().sendMessage(embed).queue();
+ message.getChannel().sendMessageEmbeds(embed).queue();
}
// Tag doesn't exist, make a new one.
entry = new TagEntry()
.setId(args[1].toLowerCase(Locale.ROOT))
- .setContent(parseSentance(2, args))
- .setDiscordId(event.getAuthor().getId())
- .setGuild(event.getGuild().getId())
+ .setContent(StringUtils.parseSentence(2, args))
+ .setDiscordId(body.getUser().getId())
+ .setGuildId(guild.getGuild().getId())
.setTimeCreated(new Date());
tags.addTag(entry);
@@ -96,31 +92,31 @@ protected void execute(CommandEvent event) {
.setColor(0x00cc99)
.build();
- event.getChannel().sendMessage(embed).queue();
+ body.getChannel().sendMessageEmbeds(embed).queue();
break;
}
case "delete": {
- TagEntry entry = tags.getTagById(event.getGuild().getId(), args[1]);
+ TagEntry entry = tags.getTagById(guild.getGuild().getId(), args[1]);
if (entry == null) {
MessageEmbed embed = new EmbedBuilder()
.setColor(0xeb5132)
.setTitle("This tag does not exist.")
.build();
- message.getChannel().sendMessage(embed).queue();
+ message.getChannel().sendMessageEmbeds(embed).queue();
return;
}
- if (!(entry.getDiscordId().equals(event.getAuthor().getId()) || isStaff(event.getAuthor().getId()))) {
- // Not staff, not the owner.
- MessageEmbed embed = new EmbedBuilder()
- .setColor(0xeb5132)
- .setTitle("You do not have permission to modify this tag.")
- .setDescription("This tag is owned by " + retrieveMember(event.getGuild(), entry.getDiscordId()))
- .build();
- message.getChannel().sendMessage(embed).queue();
- return;
- }
+// if (!(entry.getDiscordId().equals(body.getUser().getId()) || isStaff(guild.getGuild(), body.getUser().getId()))) {
+// // Not staff, not the owner.
+// MessageEmbed embed = new EmbedBuilder()
+// .setColor(0xeb5132)
+// .setTitle("You do not have permission to modify this tag.")
+// .setDescription("This tag is owned by " + retrieveMember(guild.getGuild(), entry.getDiscordId()))
+// .build();
+// message.getChannel().sendMessageEmbeds(embed).queue();
+// return;
+// }
tags.removeTag(entry);
@@ -129,23 +125,23 @@ protected void execute(CommandEvent event) {
.setColor(0x00cc99)
.build();
- message.getChannel().sendMessage(embed).queue();
+ message.getChannel().sendMessageEmbeds(embed).queue();
break;
}
case "view": {
- TagEntry entry = tags.getTagById(event.getGuild().getId(), args[1].toLowerCase(Locale.ROOT));
+ TagEntry entry = tags.getTagById(guild.getGuild().getId(), args[1].toLowerCase(Locale.ROOT));
if (entry == null) {
MessageEmbed embed = new EmbedBuilder()
.setColor(0xeb5132)
.setTitle("This tag does not exist.")
.build();
- message.getChannel().sendMessage(embed).queue();
+ message.getChannel().sendMessageEmbeds(embed).queue();
return;
}
- Member owner = retrieveMember(event.getGuild(), entry.getDiscordId());
+ Member owner = retrieveMember(guild.getGuild(), entry.getDiscordId());
String tag = owner != null ? owner.getUser().getAsTag() : "User no longer in guild.";
MessageEmbed embed = new EmbedBuilder()
@@ -155,12 +151,12 @@ protected void execute(CommandEvent event) {
.addField("Created", TimeUtils.formatTime(entry.getTimeCreated()), true)
.build();
- message.getChannel().sendMessage(embed).queue();
+ message.getChannel().sendMessageEmbeds(embed).queue();
break;
}
default: {
- respondSyntaxError(message, ";tag [id] [content]");
+ syntaxError(message);
}
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/util/TagsCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/TagsCommand.java
new file mode 100644
index 00000000..db687d14
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/TagsCommand.java
@@ -0,0 +1,22 @@
+package io.paradaux.friendlybot.bot.commands.util;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import net.dv8tion.jda.api.EmbedBuilder;
+import org.slf4j.Logger;
+
+@Command(name = "tags", description = "Sends a link to the tag web viewer, so you can see all of the tags currently set in the given guild.", permission = "command.tags", aliases = {})
+public class TagsCommand extends DiscordCommand {
+
+ private static final String TAGS_URL = "https://paradaux.io/projects/friendlybot/tools/tag_viewer.html?serverid=%s";
+
+ @Override
+ public void execute(FGuild guild, CommandBody body) {
+ body.getChannel().sendMessageEmbeds(new EmbedBuilder()
+ .setColor(NumberUtils.randomColor()).setDescription("**You can view all tags for this guild here**: \n"
+ + String.format(TAGS_URL, guild.getGuild().getId())).build()).queue();
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/util/UserInfoCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/UserInfoCommand.java
new file mode 100644
index 00000000..06ea4b3a
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/UserInfoCommand.java
@@ -0,0 +1,83 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2021 RÃan Errity
+ * io.paradaux.friendlybot.commands.utility.UserInfoCommand : 31/01/2021, 01:26
+ *
+ * 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 io.paradaux.friendlybot.bot.commands.util;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.StringUtils;
+import io.paradaux.friendlybot.core.utils.TimeUtils;
+import io.paradaux.friendlybot.core.utils.embeds.command.UserInfoEmbed;
+import net.dv8tion.jda.api.entities.Member;
+import net.dv8tion.jda.api.entities.Role;
+
+import java.util.List;
+
+@Command(name = "userinfo", description = "Shows information about yourself or the specified user.", permission = "commands.userinfo", aliases = {"info", "ui"})
+public class UserInfoCommand extends DiscordCommand {
+
+ @Override
+ public void execute(FGuild guild, CommandBody body) {
+ Member member;
+ String argument = body.getArgStr();
+
+// if (!argument.isEmpty() && isStaff(guild.getGuild(), body.getUser().getId())) {
+// member = retrieveMember(guild.getGuild(), parseTarget(body.getMessage(), body.getArgs()[0]));
+//
+// if (member == null) {
+// syntaxError(body.getMessage());
+// return;
+// }
+// } else {
+// member = body.getMember();
+// }
+
+// String tag = member.getUser().getAsTag();
+ // String avatarUrl = member.getUser().getAvatarUrl();
+
+ // String status = StringUtils.toTitleCase(member.getOnlineStatus().toString());
+
+ // String accountCreated = TimeUtils.formatTime(member.getUser().getTimeCreated());
+ // String joinedServer = TimeUtils.formatTime(member.getTimeJoined());
+ // String nickname = member.getNickname() != null ? member.getNickname() : "No Nickname.";
+
+ //List roles = member.getRoles();
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("[ ");
+ int i = 0;
+ // for (; i < member.getRoles().size()-1; i++) {
+ // builder.append(member.getRoles().get(i).getName()).append(", ");
+ // }
+
+ //builder.append(roles.get(i).getName()).append(" ]");
+
+ // UserInfoEmbed embed = new UserInfoEmbed(tag, avatarUrl, status, accountCreated, joinedServer, builder.toString(), nickname);
+ // embed.sendEmbed(guild.getGuild().getJDA().getTextChannelById(body.getMessage().getChannel().getId()));
+
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/WeatherCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/WeatherCommand.java
similarity index 77%
rename from src/main/java/io/paradaux/friendlybot/commands/utility/WeatherCommand.java
rename to src/main/java/io/paradaux/friendlybot/bot/commands/util/WeatherCommand.java
index 01e6cbe0..89e3c7b0 100644
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/WeatherCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/WeatherCommand.java
@@ -1,55 +1,50 @@
-package io.paradaux.friendlybot.commands.utility;
+package io.paradaux.friendlybot.bot.commands.util;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.StringUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.StringUtils;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageEmbed;
-import org.slf4j.Logger;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
-public class WeatherCommand extends BaseCommand {
+@Command(name = "weather", description = "View weather information", permission = "commands.weather", aliases = {"w"})
+public class WeatherCommand extends DiscordCommand {
- private static final String WEATHER_API = "http://api.openweathermap.org/data/2.5/weather?q=%s&appid=%s";
+ private static final String WEATHER_API = "https://api.openweathermap.org/data/2.5/weather?q=%s&appid=%s";
private static final String MORE_INFORMATION_LINK = "https://openweathermap.org/city/%d";
- private static final String WEATHER_ICON_LINK = "http://openweathermap.org/img/wn/%s@4x.png";
+ private static final String WEATHER_ICON_LINK = "https://openweathermap.org/img/wn/%s@4x.png";
private static final String TEMPERATURE_FORMAT = "%.2f°C (%.2f°F)";
private static final String WIND_FORMAT = "%.1fm/s %.0f° (%s)";
- public WeatherCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "weather";
- this.help = "View weather information";
- }
-
@Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
+ public void execute(FGuild guild, CommandBody body) {
+ Message message = body.getMessage();
HttpApi http = new HttpApi(getLogger());
- if (event.getArgs().isEmpty()) {
- respondSyntaxError(message, ";weather ");
+ if (body.getArgs().length == 0) {
+ syntaxError(message);
return;
}
- String place = StringUtils.toTitleCase(event.getArgs());
+ String place = StringUtils.toTitleCase(String.join(" ", body.getArgs()));
- HttpRequest request = http.plainRequest(String.format(WEATHER_API, place.replace(" ", "%20"), getConfig().getWeatherApiKey()));
+ HttpRequest request = http.plainRequest(String.format(WEATHER_API, place.replace(" ", "%20"), getConfig().getOpenWeatherMapApiKey()));
http.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenAccept((response) -> {
JsonObject weatherData = JsonParser.parseString(response.body()).getAsJsonObject();
if (!(weatherData.get("cod").getAsInt() == 200)) {
- event.getChannel().sendMessage(new EmbedBuilder()
+ body.getChannel().sendMessage(new EmbedBuilder()
.setColor(0xeb5132)
.setTitle("Error: " + weatherData.get("cod").getAsInt())
.setDescription("**Message**: " + weatherData.get("message").getAsString())
@@ -89,7 +84,7 @@ protected void execute(CommandEvent event) {
.setFooter("Weather Information reflects the current weather conditions, this information is provided courtesy of OpenWeatherMap.org")
.build();
- event.getChannel().sendMessage(embed).queue();
+ body.getChannel().sendMessageEmbeds(embed).queue();
}).join();
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/bot/commands/util/WolframAlphaCommand.java b/src/main/java/io/paradaux/friendlybot/bot/commands/util/WolframAlphaCommand.java
new file mode 100644
index 00000000..934f1c1f
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/bot/commands/util/WolframAlphaCommand.java
@@ -0,0 +1,95 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2021 RÃan Errity
+ * io.paradaux.friendlybot.commands.utility.WolframAlphaCommand : 31/01/2021, 01:26
+ *
+ * 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 io.paradaux.friendlybot.bot.commands.util;
+
+import io.paradaux.friendlybot.bot.command.Command;
+import io.paradaux.friendlybot.bot.command.CommandBody;
+import io.paradaux.friendlybot.bot.command.DiscordCommand;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.http.HttpApi;
+import net.dv8tion.jda.api.EmbedBuilder;
+import net.dv8tion.jda.api.entities.Message;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+
+@Command(name = "", description = "", permission = "", aliases = {})
+public class WolframAlphaCommand extends DiscordCommand {
+ @Override
+ public void execute(FGuild guild, CommandBody body) {
+
+ }
+
+// private static final String WOLFRAM_API = "https://api.wolframalpha.com/v1/result?i=%s&appid=%s&";
+// private static final String WOLFRAM_USER_LINK = "https://www.wolframalpha.com/input/?i=%s";
+// private static final String IMGUR_API = "https://api.imgur.com/3/upload/";
+// private static final String WOLFRAM_ICON = "https://www.wolframalpha.com/_next/static/images/share_3G6HuGr6.png";
+//
+// public WolframAlphaCommand(ConfigurationEntry config, Logger logger) {
+// super(config, logger);
+// this.name = "wolframalpha";
+// this.aliases = new String[]{"wa"};
+// this.help = "Queries WolframAlpha's API.";
+// }
+//
+// @Override
+// public void execute(FGuild guild, CommandBody body) {
+// Message message = event.getMessage();
+// String args = event.getArgs();
+//
+// if (args == null || args.isEmpty()) {
+// respondSyntaxError(message, ";wa ");
+// return;
+// }
+//
+// HttpApi http = new HttpApi(getLogger());
+//
+// // Get's the image from WA
+// HttpRequest request = http.plainRequest(String.format(WOLFRAM_API, args.replace(" ", "%20"), getConfig().getWolframAlphaApplicationId()));
+// http.sendAsync(request, HttpResponse.BodyHandlers.ofByteArray()).thenAccept((response) -> {
+// // Send that image to imgur
+// String[] headers = {"Authorization", "Client-ID " + getConfig().getImgurClientId()};
+// HttpRequest request2 = http.postBytes(IMGUR_API, response.body(), headers);
+//
+// HttpResponse response2 = http.sendSync(request2, HttpResponse.BodyHandlers.ofString());
+// JSONObject imgurMeta = new JSONObject(response2.body());
+//
+// EmbedBuilder builder = new EmbedBuilder()
+// .setAuthor("Wolfram Alpha Query.", String.format(WOLFRAM_USER_LINK, args.replace(" ", "%20")), WOLFRAM_ICON)
+// .setColor(NumberUtils.randomColor())
+// .setImage(imgurMeta.getJSONObject("data").getString("link"))
+// .setFooter("Query: " + args);
+//
+// message.getChannel().sendMessage(builder.build()).queue();
+// }).join();
+//
+// }
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/CatCommand.java b/src/main/java/io/paradaux/friendlybot/commands/fun/CatCommand.java
deleted file mode 100644
index 4fbc73e9..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/CatCommand.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package io.paradaux.friendlybot.commands.fun;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import io.paradaux.http.HttpApi;
-import net.dv8tion.jda.api.EmbedBuilder;
-import org.json.JSONArray;
-import org.slf4j.Logger;
-
-import java.net.http.HttpRequest;
-import java.net.http.HttpResponse;
-
-public class CatCommand extends BaseCommand {
-
- private static final String CAT_API = "https://api.thecatapi.com/v1/images/search";
-
- public CatCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "cat";
- this.aliases = new String[]{"meow"};
- this.help = "Add a little more meow to your life!";
- }
-
- @Override
- protected void execute(CommandEvent event) {
-
- HttpApi http = new HttpApi(getLogger());
- HttpRequest request = http.plainRequest(CAT_API);
-
- http.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenAccept((response) -> {
- EmbedBuilder builder = new EmbedBuilder()
- .setImage(new JSONArray(response.body()).getJSONObject(0).getString("url"))
- .setColor(NumberUtils.randomColor())
- .setFooter("For " + event.getAuthor().getName());
-
- event.getMessage().getChannel().sendMessage(builder.build()).queue();
- }).join();
-
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/fun/DogCommand.java b/src/main/java/io/paradaux/friendlybot/commands/fun/DogCommand.java
deleted file mode 100644
index f55e76ba..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/fun/DogCommand.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package io.paradaux.friendlybot.commands.fun;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import io.paradaux.http.HttpApi;
-import net.dv8tion.jda.api.EmbedBuilder;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-
-import java.net.http.HttpRequest;
-import java.net.http.HttpResponse;
-
-public class DogCommand extends BaseCommand {
-
- private static final String DOG_API = "https://dog.ceo/api/breeds/image/random";
-
- public DogCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "dog";
- this.aliases = new String[]{"pupper", "puppers"};
- this.help = "Woof, Woof!";
- }
-
- @Override
- protected void execute(CommandEvent event) {
-
- HttpApi http = new HttpApi(getLogger());
- HttpRequest request = http.plainRequest(DOG_API);
-
- http.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenAccept((response) -> {
- EmbedBuilder builder = new EmbedBuilder()
- .setImage(new JSONObject(response.body()).getString("message"))
- .setColor(NumberUtils.randomColor())
- .setFooter("For " + event.getAuthor().getName());
-
- event.getMessage().getChannel().sendMessage(builder.build()).queue();
- }).join();
-
- }
-
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/KickCommand.java b/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/KickCommand.java
deleted file mode 100644
index 194ac126..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/KickCommand.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.commands.staff.moderation.KickCommand : 31/01/2021, 01:26
- *
- * 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 io.paradaux.friendlybot.commands.staff.moderation;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.FriendlyBot;
-import io.paradaux.friendlybot.managers.AuditManager;
-import io.paradaux.friendlybot.managers.DiscordBotManager;
-import io.paradaux.friendlybot.managers.MongoManager;
-import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.KickEntry;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Member;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.MessageEmbed;
-import net.dv8tion.jda.api.entities.User;
-import org.slf4j.Logger;
-
-import java.util.Date;
-
-/**
- * This is a command which kicks the specified user.
- *
- * @author RÃan Errity
- * @version Last modified for 0.1.0-SNAPSHOT
- * @since 4/11/2020 DD/MM/YY
- * @see FriendlyBot
- * */
-
-public class KickCommand extends PrivilegedCommand {
-
- public KickCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
- super(config, logger, permissionManager);
- this.name = "kick";
- this.help = "Kicks the specified user";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
-
- String[] args = getArgs(event.getArgs());
- String authorID = event.getAuthor().getId();
-
- if (!isStaff(authorID)) {
- respondNoPermission(message, "[Moderator, Administrator]");
- return;
- }
- if (args.length < 2) {
- respondSyntaxError(message, ";kick ");
- return;
- }
-
- User target = parseTarget(message, args[0]);
-
- if (target == null) {
- message.getChannel().sendMessage("You did not specify a (valid) target.").queue();
- return;
- }
-
- if (isStaff(target.getId())) {
- message.getChannel().sendMessage("You cannot ban a staff member.").queue();
- return;
- }
-
- MongoManager mongo = MongoManager.getInstance();
-
- String incidentID = mongo.getNextIncidentID();
- String reason = parseSentance(1, args);
-
- KickEntry entry = new KickEntry()
- .setIncidentID(incidentID)
- .setReason(reason)
- .setStaffID(authorID)
- .setStaffTag(event.getAuthor().getAsTag())
- .setUserID(target.getId())
- .setUserTag(target.getAsTag());
-
- mongo.addKickEntry(entry);
-
- AuditManager.getInstance().log(ModerationAction.KICK, target,
- event.getAuthor(), reason, incidentID);
-
- MessageEmbed publicAudit = new EmbedBuilder()
- .setColor(0xffff99)
- .setTitle(target.getAsTag() + " has been kicked.")
- .setDescription("**Reason**: " + reason)
- .setFooter("Incident ID: " + incidentID + ". For more information, reach out to the moderation team via mod-mail.")
- .setTimestamp(new Date().toInstant())
- .build();
-
- DiscordBotManager.getInstance().getChannel(getConfig().getPublicAuditLogChannelId()).sendMessage(publicAudit).queue();
- message.getChannel().sendMessage(publicAudit).queue();
-
- target.openPrivateChannel().queue((channel) -> {
- MessageEmbed kickNotification = new EmbedBuilder()
- .setColor(0xffff99)
- .setTitle("You have been kicked.")
- .setDescription("**Reason**: " + reason)
- .setFooter("Incident ID: " + incidentID + ". For more information, reach out to the moderation team via mod-mail.")
- .setTimestamp(new Date().toInstant())
- .build();
-
- channel.sendMessage(kickNotification).queue();
-
- Member targetMember = retrieveMember(message.getGuild(), target);
-
- if (targetMember == null) {
- message.getChannel().sendMessage("The user specified is not a member of this discord")
- .queue();
- return;
- }
-
- targetMember.kick(reason).queue();
- });
-
- }
-}
\ No newline at end of file
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/PunishmentCommand.java b/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/PunishmentCommand.java
deleted file mode 100644
index a55563ae..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/PunishmentCommand.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package io.paradaux.friendlybot.commands.staff.moderation;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.managers.DiscordBotManager;
-import io.paradaux.friendlybot.managers.MongoManager;
-import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.RescindmentEntry;
-import io.paradaux.friendlybot.utils.models.database.WarningEntry;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.MessageEmbed;
-import net.dv8tion.jda.api.entities.User;
-import org.slf4j.Logger;
-
-import java.util.Date;
-
-public class PunishmentCommand extends PrivilegedCommand {
-
- private final MongoManager mongo;
-
- public PunishmentCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager, MongoManager mongo) {
- super(config, logger, permissionManager);
- this.mongo = mongo;
- this.name = "punishment";
- this.help = "Utility for managing previously logged infractions.";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
- String[] args = getArgs(event.getArgs());
-
- if (!isStaff(event.getAuthor().getId())) {
- respondNoPermission(message, "[Moderator, Administrator]");
- return;
- }
-
- if (args.length < 3) {
- respondSyntaxError(message, ";punishment ");
- return;
- }
-
- switch (args[0]) {
-
- case "delwarn": {
- WarningEntry entry = mongo.getWarningEntry(args[1]);
-
- if (entry == null) {
- message.reply("This warning does not exist.");
- return;
- }
-
- mongo.deleteWarning(args[1]);
- String incidentId = mongo.getNextIncidentID();
-
- RescindmentEntry rescindment = new RescindmentEntry()
- .setAction(ModerationAction.WARN)
- .setIncidentId(incidentId)
- .setIncidentIdOfPunishment(entry.getIncidentID())
- .setUserTag(entry.getUserTag())
- .setUserId(entry.getUserID())
- .setStaffTag(message.getAuthor().getAsTag())
- .setStaffId(message.getAuthor().getId())
- .setReason(parseSentance(2, args))
- .setTimeOfPunishment(entry.getTimestamp())
- .setTimeOfRescindment(new Date());
-
- mongo.addRescindment(rescindment);
-
- MessageEmbed publicAudit = new EmbedBuilder()
- .setColor(0x34eb9b)
- .setTitle("Punishment Rescinded. | Warning of " + entry.getUserTag())
- .setDescription(rescindment.getReason())
- .setFooter("Punishment ID: " + args[1] + " Incident ID: " + incidentId)
- .setTimestamp(new Date().toInstant())
- .build();
-
- DiscordBotManager.getInstance().getChannel(getConfig().getPublicAuditLogChannelId()).sendMessage(publicAudit).queue();
- message.getChannel().sendMessage(publicAudit).queue();
-
- User target = DiscordBotManager.getInstance().getUser(entry.getUserID());
-
- target.openPrivateChannel().queue((channel) -> {
- MessageEmbed rescindmentNotification = new EmbedBuilder()
- .setColor(0x33cccc)
- .setTitle("A warning levied against you has been taken back..")
- .setDescription("** Original Reason**: " + entry.getReason() + "\n" + rescindment.getReason())
- .setFooter("Punishment ID: " + args[1] + " Incident ID: " + incidentId)
- .setTimestamp(new Date().toInstant())
- .build();
-
- channel.sendMessage(rescindmentNotification).queue();
- });
- }
-
- }
-
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/TempBanCommand.java b/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/TempBanCommand.java
deleted file mode 100644
index 4bafb923..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/TempBanCommand.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.commands.staff.moderation.TempBanCommand : 06/02/2021, 18:10
- *
- * 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 io.paradaux.friendlybot.commands.staff.moderation;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.managers.AuditManager;
-import io.paradaux.friendlybot.managers.DiscordBotManager;
-import io.paradaux.friendlybot.managers.MongoManager;
-import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.TimeUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.TempBanEntry;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.MessageEmbed;
-import net.dv8tion.jda.api.entities.TextChannel;
-import net.dv8tion.jda.api.entities.User;
-import org.slf4j.Logger;
-
-import java.util.Date;
-
-public class TempBanCommand extends PrivilegedCommand {
-
- private final MongoManager mongo;
-
- public TempBanCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager, MongoManager mongo) {
- super(config, logger, permissionManager);
- this.mongo = mongo;
- this.name = "tempban";
- this.help = "Temporarily bans a user.";
- }
-
- @Override
- protected void execute(CommandEvent event) {
-
- User staff = event.getAuthor();
- Message message = event.getMessage();
- String[] args = getArgs(event.getArgs());
-
- if (!isStaff(staff.getId())) {
- respondNoPermission(message, "[Moderator, Administrator]");
- return;
- }
-
- if (event.getArgs().isEmpty()) {
- respondSyntaxError(message, ";tempban ");
- return;
- }
-
- User target = parseTarget(message, args[0]);
-
- if (target == null) {
- message.reply("User does not exist.").queue();
- return;
- }
-
- long period = TimeUtils.getTime(args[1]);
- Date expiry = new Date(System.currentTimeMillis() + period);
-
- TempBanEntry entry = new TempBanEntry()
- .setIncidentId(mongo.getNextIncidentID())
- .setUserTag(target.getAsTag())
- .setUserId(target.getId())
- .setStaffTag(staff.getAsTag())
- .setStaffId(staff.getId())
- .setReason(parseSentance(2, args))
- .setTimestamp(new Date())
- .setExpiry(expiry);
-
- mongo.addTempBanEntry(entry);
-
- MessageEmbed publicAudit = new EmbedBuilder()
- .setColor(0xeb5132)
- .setTitle(target.getAsTag() + " has been temporarily banned.")
- .setDescription("**Reason**: " + entry.getReason() + "\n**Period**: " + TimeUtils.millisecondsToDisplay(period))
- .setFooter("Incident ID: " + entry.getIncidentId() + ". For more information, reach out to the moderation team via mod-mail.")
- .setTimestamp(new Date().toInstant())
- .build();
-
- TextChannel channel = DiscordBotManager.getInstance().getChannel(getConfig().getPublicAuditLogChannelId());
- channel.sendMessage(publicAudit).queue();
- event.getChannel().sendMessage(publicAudit).queue();
- AuditManager.getInstance().log(ModerationAction.TEMP_BAN, target, staff, entry.getReason(), entry.getIncidentId());
-
- target.openPrivateChannel().queue((privateChannel) -> {
- MessageEmbed banNotification = new EmbedBuilder()
- .setColor(0xeb5132)
- .setTitle("You have been temporarily banned.")
- .setDescription("**Reason**: " + entry.getReason() + "\n**Period**: " + TimeUtils.millisecondsToDisplay(period))
- .setFooter("Incident ID: " + entry.getIncidentId() + ". For more information, reach out to a member of the moderation team.")
- .setTimestamp(new Date().toInstant())
- .build();
-
- privateChannel.sendMessage(banNotification).queue((message2) -> {
- message.getGuild().ban(target, 0).queue();
- });
-
- });
-
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/TimeOutCommand.java b/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/TimeOutCommand.java
deleted file mode 100644
index 1dec77f5..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/TimeOutCommand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.commands.staff.moderation.TimeOutCommand : 31/01/2021, 01:27
- *
- * 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 io.paradaux.friendlybot.commands.staff.moderation;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
-import org.slf4j.Logger;
-
-public class TimeOutCommand extends PrivilegedCommand {
-
- public TimeOutCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
- super(config, logger, permissionManager);
- this.name = "timeout";
- this.aliases = new String[]{"to", "quarantine"};
- this.help = "Prevents a user from sending messages for a period of time.";
- }
-
- @Override
- protected void execute(CommandEvent event) {
-
- event.getChannel().sendMessage("TimeOut is not implemented yet. "
- + "Coming soon").queue();
-
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/WarnCommand.java b/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/WarnCommand.java
deleted file mode 100644
index 1da296d3..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/moderation/WarnCommand.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.commands.staff.moderation.WarnCommand : 31/01/2021, 01:26
- *
- * 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 io.paradaux.friendlybot.commands.staff.moderation;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.FriendlyBot;
-import io.paradaux.friendlybot.managers.AuditManager;
-import io.paradaux.friendlybot.managers.DiscordBotManager;
-import io.paradaux.friendlybot.managers.MongoManager;
-import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.WarningEntry;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.MessageEmbed;
-import net.dv8tion.jda.api.entities.User;
-import org.slf4j.Logger;
-
-import java.util.Date;
-
-/**
- * This is a command which warns the specified user.
- *
- * @author RÃan Errity
- * @version Last modified for 0.1.0-SNAPSHOT
- * @since 4/11/2020 DD/MM/YY
- * @see FriendlyBot
- * */
-
-public class WarnCommand extends PrivilegedCommand {
-
- // Dependencies
-
- public WarnCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
- super(config, logger, permissionManager);
- this.name = "warn";
- this.aliases = new String[]{"w"};
- this.help = "Warns the specified user";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
-
- String[] args = getArgs(event.getArgs());
- String authorID = event.getAuthor().getId();
-
- if (!isStaff(authorID)) {
- respondNoPermission(message, "[Moderator, Administrator]");
- return;
- }
-
- if (args.length < 2) {
- respondSyntaxError(message, ";warn ");
- return;
- }
-
- User target = parseTarget(message, args[0]);
-
- if (target == null) {
- message.getChannel().sendMessage("You did not specify a (valid) target.").queue();
- return;
- }
-
- MongoManager mongo = MongoManager.getInstance();
-
- String incidentID = mongo.getNextIncidentID();
- String reason = parseSentance(1, args);
-
- WarningEntry entry = new WarningEntry()
- .setIncidentID(incidentID)
- .setReason(reason)
- .setStaffID(authorID)
- .setStaffTag(event.getAuthor().getAsTag())
- .setUserID(target.getId())
- .setUserTag(target.getAsTag())
- .setTimestamp(new Date());
-
- mongo.addWarnEntry(entry);
-
- AuditManager.getInstance().log(ModerationAction.WARN, target,
- event.getAuthor(), reason, incidentID);
-
- MessageEmbed publicAudit = new EmbedBuilder()
- .setColor(0x33cccc)
- .setTitle(target.getAsTag() + " has been warned.")
- .setDescription("**Reason**: " + reason + "\n**N.B**: Receiving a second warning is an automatic temporary ban.")
- .setFooter("Incident ID: " + incidentID + ". For more information, reach out to the moderation team via mod-mail.")
- .setTimestamp(new Date().toInstant())
- .build();
-
- DiscordBotManager.getInstance().getChannel(getConfig().getPublicAuditLogChannelId()).sendMessage(publicAudit).queue();
- message.getChannel().sendMessage(publicAudit).queue();
-
- target.openPrivateChannel().queue((channel) -> {
- MessageEmbed warnNotification = new EmbedBuilder()
- .setColor(0x33cccc)
- .setTitle("You have been warned.")
- .setDescription("**Reason**: " + reason + "\n**N.B**: Receiving a second warning is an automatic temporary ban.")
- .setFooter("Incident ID: " + incidentID + ". For more information, reach out to the moderation team via mod-mail.")
- .setTimestamp(new Date().toInstant())
- .build();
-
- channel.sendMessage(warnNotification).queue();
- });
-
- }
-}
\ No newline at end of file
diff --git a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/PermissionsCommand.java b/src/main/java/io/paradaux/friendlybot/commands/staff/technician/PermissionsCommand.java
deleted file mode 100644
index cf2a5020..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/staff/technician/PermissionsCommand.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.commands.staff.technician.PermissionsCommand : 31/01/2021, 01:26
- *
- * 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 io.paradaux.friendlybot.commands.staff.technician;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.listeners.InsultListener;
-import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
-import net.dv8tion.jda.api.entities.Member;
-import net.dv8tion.jda.api.entities.Message;
-import org.slf4j.Logger;
-
-public class PermissionsCommand extends PrivilegedCommand {
-
- public PermissionsCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
- super(config, logger, permissionManager);
- this.name = "permissions";
- this.aliases = new String[]{"perms", "perm"};
- this.help = "Modifies user permissions";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
-
- String[] args = getArgs(event.getArgs());
- String authorID = event.getAuthor().getId();
-
- PermissionManager manager = PermissionManager.getInstance();
-
- if (!manager.isTechnician(authorID)) {
- respondNoPermission(message, "[Technician]");
- return;
- }
-
- if (args.length < 3) {
- respondSyntaxError(message, ";permissions <@mention/discordID>");
- return;
- }
-
- Member target = retrieveMember(message.getGuild(), parseTarget(message, args[2]));
-
- if (target == null) {
- message.getChannel().sendMessage("Invalid target specified.").queue();
- return;
- }
-
- switch (args[0]) {
- case "give": {
-
- switch (args[1]) {
- case "mod": {
- manager.addMod(target.getId());
- break;
- }
-
- case "admin": {
- manager.addAdmin(target.getId());
- break;
- }
-
- case "technician": {
- manager.addTechnician(target.getId());
- break;
- }
-
- default: {
- respondSyntaxError(message, ";permissions <@mention/discordID>");
- return;
- }
- }
-
- String responseMessage = String.format("Given `%s` `%s` permissions.",
- target.getUser().getAsTag(), args[1]);
- message.getChannel().sendMessage(responseMessage).queue();
- break;
- }
-
- case "remove": {
-
- switch (args[1]) {
-
- case "mod": {
- manager.removeMod(authorID);
- break;
- }
-
- case "admin": {
- manager.removeAdmin(authorID);
- break;
- }
-
- case "technician": {
- manager.removeTechnician(authorID);
- break;
- }
-
- default: {
- respondSyntaxError(message, ";permissions <@mention/discordID>");
- return;
- }
- }
-
- String responseMessage = String.format("Taken `%s`'s `%s` permissions.",
- target.getUser().getAsTag(), args[1]);
- message.getChannel().sendMessage(responseMessage).queue();
- break;
- }
-
- case "insult": {
-
- switch (args[1]) {
-
- case "add": {
- InsultListener.addUser(args[2]);
- message.reply("Added: `" + args[2] + "` to the target list.").queue();
- break;
- }
-
- case "remove": {
- InsultListener.removeUser(args[2]);
- message.reply("Removed: `" + args[2] + "` from the target list.").queue();
- break;
- }
-
- case "view": {
- message.reply("```" + InsultListener.getTargetUsers() + "```").queue();
- break;
- }
- }
- break;
- }
-
- default: {
- respondSyntaxError(message, ";permissions <@mention/discordID>");
- break;
- }
- }
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/ClearColorCommand.java b/src/main/java/io/paradaux/friendlybot/commands/utility/ClearColorCommand.java
deleted file mode 100644
index 68aee3ac..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/ClearColorCommand.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package io.paradaux.friendlybot.commands.utility;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.managers.SettingsManager;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.UserSettingsEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Guild;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.Role;
-import org.slf4j.Logger;
-
-import java.util.List;
-
-public class ClearColorCommand extends BaseCommand {
-
- public ClearColorCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "clearcolor";
- this.aliases = new String[]{"clearcolour"};
- this.help = "Clear a custom-color role.";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- final Message message = event.getMessage();
- final Guild guild = event.getGuild();
-
- SettingsManager settings = SettingsManager.getInstance();
- UserSettingsEntry entry = settings.getProfileById(guild.getId(), event.getAuthor().getId());
-
- if (entry.getCustomColorRole() == null) {
- message.reply("You do not have a custom color.").queue();
- return;
- }
-
- List customRoles = guild.getRolesByName(entry.getCustomColorRole(), true);
-
- if (customRoles.size() == 0) {
- message.reply("An error occurred in that you appear to have an invalid custom color.").queue();
- return;
- }
-
- guild.removeRoleFromMember(event.getMember(), customRoles.get(0)).queue((success) -> {
- String customColor = entry.getCustomColorRole();
- entry.setCustomColorRole(null);
- settings.updateSettingsProfile(entry);
-
- if (settings.getProfileCountByColor(guild.getId(), customColor) == 0) {
- customRoles.get(0).delete().queue();
- }
-
- message.getChannel().sendMessage(new EmbedBuilder()
- .setColor(NumberUtils.randomColor())
- .setTitle("Your custom color role has been cleared.")
- .setDescription("This has not had any effect on your 3-day cooldown, you may not modify your color again until that has expired.")
- .build()).queue();
- });
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/GithubCommand.java b/src/main/java/io/paradaux/friendlybot/commands/utility/GithubCommand.java
deleted file mode 100644
index 7ef2293d..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/GithubCommand.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.commands.utility.GithubCommand : 31/01/2021, 01:26
- *
- * 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 io.paradaux.friendlybot.commands.utility;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.MessageEmbed;
-import net.dv8tion.jda.api.entities.TextChannel;
-import org.slf4j.Logger;
-
-public class GithubCommand extends BaseCommand {
-
- private static final String REPO_INFO_ENDPOINT = "https://api.github.com/repos/%s";
- private static final String REPO_ISSUES_ENDPOINT = "https://api.github.com/repos/%s/issues";
- private static final String CLOSED_ISSUES_ENDPOINT = "https://api.github.com/search/issues?q=repo:%s/+type:issue+state:closed";
- private static final String OPEN_ISSUES_ENDPOINT = "https://api.github.com/search/issues?q=repo:%s/+type:issue+state:open";
-
- public GithubCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "github";
- this.aliases = new String[]{"gh"};
- this.help = "Looks up the specified github repository.";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- String[] args = getArgs(event.getArgs());
- TextChannel channel = event.getTextChannel();
- Message message = event.getMessage();
-
- MessageEmbed embed;
-
- switch (args.length) {
-
- case 1: {
-// embed = makeInfoEmbed(args[0]);
- break;
- }
-
- // TODO implement issue searching
-// case 2: {
-// embed = makeIssueEmbed(args[0], Long.parseLong(args[1]));
-// break;
-// }
-
- default: {
- respondSyntaxError(message, ";github [issue #]");
- return;
- }
-
- }
-
-// channel.sendMessage(embed).queue();
- }
-
-// public MessageEmbed makeInfoEmbed(String repository) {
-// EmbedBuilder embed = new EmbedBuilder();
-// try {
-// String repoContent = WebApiUtil.getStringWithThrows(new URL(String.format(REPO_INFO_ENDPOINT, repository)), "GET",
-// WebSettings.WEB_TIMEOUT, WebSettings.WEB_USER_AGENT, WebSettings.getJsonWebHeaders());
-//
-// Gson gson = new GsonBuilder()
-// .registerTypeAdapter(Data.class, new CustomDeserilizer())
-// .create();
-//
-//
-// JSONDeserializer repoModelDeserializer = new JSONDeserializer<>();
-// repoModelDeserializer.use(Instant.class, new InstantTransformer());
-// GithubRepoModel repoModel = repoModelDeserializer.deserialize(repoContent, GithubRepoModel.class);
-// List issueModels = getIssues(repository);
-//
-// embed.setAuthor(repoModel.getName(), repoModel.getHtmlURL(), repoModel.getOwner().getAvatarURL());
-// embed.setColor(Color.YELLOW);
-// embed.setDescription(repoModel.getDescription());
-// embed.setThumbnail(repoModel.getOwner().getAvatarURL());
-//
-// embed.addInlineField("\uD83C\uDF1F Stars", String.format("```%s```", repoModel.getStargazers()));
-// embed.addInlineField("\u203C Issues", String.format("```%s```", repoModel.getOpenIssues()));
-//
-// StringBuilder issuenames = new StringBuilder();
-// if (!issueModels.isEmpty()) {
-// for (int i = 0; i < Math.min(issueModels.size(), 3); i++) {
-// issuenames.append("[#"+issueModels.get(i).getNumber()+"]").append("("+issueModels.get(i).getHtmlUrl()+") ")
-// .append("```" + issueModels.get(i).getTitle() + "```");
-// }
-// }
-//
-// embed.addField("Current issues", issuenames.toString().isEmpty() ? "None!" : issuenames.toString());
-//
-// embed.setTimestampToNow();
-//
-// return embed.build();
-// } catch (IOException ex) {
-// getLogger().error(ex.getMessage(), ex);
-// embed.setTitle("Unknown repo!").setColor(Color.RED);
-// }
-// return embed;
-// }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/GoogleCommand.java b/src/main/java/io/paradaux/friendlybot/commands/utility/GoogleCommand.java
deleted file mode 100644
index b74a58be..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/GoogleCommand.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.commands.utility.GoogleCommand : 06/02/2021, 11:08
- *
- * 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 io.paradaux.friendlybot.commands.utility;
-
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.StringUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import io.paradaux.http.HttpApi;
-import net.dv8tion.jda.api.entities.Message;
-import org.slf4j.Logger;
-
-import java.net.http.HttpRequest;
-import java.net.http.HttpResponse;
-
-public class GoogleCommand extends BaseCommand {
-
- private static final String QUERY_URL = "https://www.googleapis.com/customsearch/v1?key=%s&q=%s&safe=ACTIVE";
- private final String apiKey;
-
- public GoogleCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "google";
- this.aliases = new String[]{"googleit"};
- this.help = "Google via discord!";
- this.apiKey = "";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
- String query = event.getArgs();
-
- if (query.isEmpty()) {
- respondSyntaxError(message, ";google ");
- return;
- }
-
- HttpApi http = new HttpApi(getLogger());
- HttpRequest request = http.jsonRequest(String.format(QUERY_URL, apiKey, StringUtils.urlEncode(query.replace(' ','+'))));
-
- http.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenAccept((response -> {
- JsonObject json = JsonParser.parseString(response.body()).getAsJsonObject();
-
-
-
- })).join();
-
-
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/StrikeCommand.java b/src/main/java/io/paradaux/friendlybot/commands/utility/StrikeCommand.java
deleted file mode 100644
index 87823542..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/StrikeCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package io.paradaux.friendlybot.commands.utility;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.StringUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.MessageEmbed;
-import org.slf4j.Logger;
-
-public class StrikeCommand extends BaseCommand {
-
- public StrikeCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "strike";
- this.help = "Generate unicode strikethrough text.";
- }
-
- @Override
- protected void execute(CommandEvent event) {
-
- Message message = event.getMessage();
-
- if (event.getArgs().isEmpty()) {
- respondSyntaxError(message, ";strike ");
- return;
- }
-
- MessageEmbed embed = new EmbedBuilder()
- .setColor(NumberUtils.randomColor())
- .setTitle("~~Strikethrough Generator~~")
- .setDescription("Unicode: `" + StringUtils.toStrikeOut(event.getArgs()) + "`\n"
- + "Markdown: ~~" + event.getArgs() + "~~")
- .build();
-
- message.getChannel().sendMessage(embed).queue();
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/TagsCommand.java b/src/main/java/io/paradaux/friendlybot/commands/utility/TagsCommand.java
deleted file mode 100644
index 9b6b8114..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/TagsCommand.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package io.paradaux.friendlybot.commands.utility;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import net.dv8tion.jda.api.EmbedBuilder;
-import org.slf4j.Logger;
-
-public class TagsCommand extends BaseCommand {
-
- private static final String TAGS_URL = "https://paradaux.io/projects/friendlybot/tools/tag_viewer.html?serverid=%s";
-
- public TagsCommand(Logger logger) {
- super(logger);
- this.name = "tags";
- this.help = "Sends a link to the tag web viewer, so you can see all of the tags currently set in the given guild.";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- event.getChannel().sendMessage(new EmbedBuilder()
- .setColor(NumberUtils.randomColor()).setDescription("**You can view all tags for this guild here**: \n"
- + String.format(TAGS_URL, event.getGuild().getId())).build()).queue();
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/UserInfoCommand.java b/src/main/java/io/paradaux/friendlybot/commands/utility/UserInfoCommand.java
deleted file mode 100644
index d9b0fd51..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/UserInfoCommand.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.commands.utility.UserInfoCommand : 31/01/2021, 01:26
- *
- * 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 io.paradaux.friendlybot.commands.utility;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.StringUtils;
-import io.paradaux.friendlybot.utils.TimeUtils;
-import io.paradaux.friendlybot.utils.embeds.command.UserInfoEmbed;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.PrivilegedCommand;
-import net.dv8tion.jda.api.entities.Member;
-import net.dv8tion.jda.api.entities.Role;
-import org.slf4j.Logger;
-
-import java.util.List;
-
-public class UserInfoCommand extends PrivilegedCommand {
-
- public UserInfoCommand(ConfigurationEntry config, Logger logger, PermissionManager permissionManager) {
- super(config, logger, permissionManager);
- this.name = "userinfo";
- this.aliases = new String[]{"info", "ui"};
- this.help = "Shows information about yourself or the specified user.";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- Member member;
- String argument = event.getArgs();
- System.out.println(argument);
- if (!argument.isEmpty() && isStaff(event.getAuthor().getId())) {
- member = retrieveMember(event.getGuild(), parseTarget(event.getMessage(), getArgs(argument)[0]));
-
- if (member == null) {
- respondSyntaxError(event.getMessage(), ";userinfo ");
- return;
- }
- } else {
- member = event.getMember();
- }
-
- String tag = member.getUser().getAsTag();
- String avatarUrl = member.getUser().getAvatarUrl();
-
- String status = StringUtils.toTitleCase(member.getOnlineStatus().toString());
-
- String accountCreated = TimeUtils.formatTime(member.getUser().getTimeCreated());
- String joinedServer = TimeUtils.formatTime(member.getTimeJoined());
- String nickname = member.getNickname() != null ? member.getNickname() : "No Nickname.";
-
- List roles = member.getRoles();
- StringBuilder builder = new StringBuilder();
-
- builder.append("[ ");
- int i = 0;
- for (; i < member.getRoles().size()-1; i++) {
- builder.append(member.getRoles().get(i).getName()).append(", ");
- }
-
- builder.append(roles.get(i).getName()).append(" ]");
-
- UserInfoEmbed embed = new UserInfoEmbed(tag, avatarUrl, status, accountCreated, joinedServer, builder.toString(), nickname);
- embed.sendEmbed(event.getTextChannel());
-
- // TODO add a staff version which shows infractions.
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/commands/utility/WolframAlphaCommand.java b/src/main/java/io/paradaux/friendlybot/commands/utility/WolframAlphaCommand.java
deleted file mode 100644
index 53aa211c..00000000
--- a/src/main/java/io/paradaux/friendlybot/commands/utility/WolframAlphaCommand.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.commands.utility.WolframAlphaCommand : 31/01/2021, 01:26
- *
- * 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 io.paradaux.friendlybot.commands.utility;
-
-import com.jagrosh.jdautilities.command.CommandEvent;
-import io.paradaux.friendlybot.utils.NumberUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.BaseCommand;
-import io.paradaux.http.HttpApi;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Message;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-
-import java.net.http.HttpRequest;
-import java.net.http.HttpResponse;
-
-public class WolframAlphaCommand extends BaseCommand {
-
- private static final String WOLFRAM_API = "https://api.wolframalpha.com/v1/result?i=%s&appid=%s&";
- private static final String WOLFRAM_USER_LINK = "https://www.wolframalpha.com/input/?i=%s";
- private static final String IMGUR_API = "https://api.imgur.com/3/upload/";
- private static final String WOLFRAM_ICON = "https://www.wolframalpha.com/_next/static/images/share_3G6HuGr6.png";
-
- public WolframAlphaCommand(ConfigurationEntry config, Logger logger) {
- super(config, logger);
- this.name = "wolframalpha";
- this.aliases = new String[]{"wa"};
- this.help = "Queries WolframAlpha's API.";
- }
-
- @Override
- protected void execute(CommandEvent event) {
- Message message = event.getMessage();
- String args = event.getArgs();
-
- if (args == null || args.isEmpty()) {
- respondSyntaxError(message, ";wa ");
- return;
- }
-
- HttpApi http = new HttpApi(getLogger());
-
- // Get's the image from WA
- HttpRequest request = http.plainRequest(String.format(WOLFRAM_API, args.replace(" ", "%20"), getConfig().getWolframAlphaApplicationId()));
- http.sendAsync(request, HttpResponse.BodyHandlers.ofByteArray()).thenAccept((response) -> {
- // Send that image to imgur
- String[] headers = {"Authorization", "Client-ID " + getConfig().getImgurClientId()};
- HttpRequest request2 = http.postBytes(IMGUR_API, response.body(), headers);
-
- HttpResponse response2 = http.sendSync(request2, HttpResponse.BodyHandlers.ofString());
- JSONObject imgurMeta = new JSONObject(response2.body());
-
- EmbedBuilder builder = new EmbedBuilder()
- .setAuthor("Wolfram Alpha Query.", String.format(WOLFRAM_USER_LINK, args.replace(" ", "%20")), WOLFRAM_ICON)
- .setColor(NumberUtils.randomColor())
- .setImage(imgurMeta.getJSONObject("data").getString("link"))
- .setFooter("Query: " + args);
-
- message.getChannel().sendMessage(builder.build()).queue();
- }).join();
-
- }
-
-}
diff --git a/src/main/java/io/paradaux/friendlybot/core/data/cache/GuildCache.java b/src/main/java/io/paradaux/friendlybot/core/data/cache/GuildCache.java
new file mode 100644
index 00000000..1d33f785
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/data/cache/GuildCache.java
@@ -0,0 +1,87 @@
+package io.paradaux.friendlybot.core.data.cache;
+
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.data.database.models.query.QFGuild;
+import net.dv8tion.jda.api.JDA;
+import net.dv8tion.jda.api.entities.Guild;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class GuildCache {
+
+ private static GuildCache instance;
+
+ public static GuildCache getInstance() {
+ return instance;
+ }
+
+ /**
+ * Map of Guild IDs (Snowflake) to FGuild objects.
+ * */
+ private final Map guilds = new HashMap<>();
+ private final JDA client;
+
+ public GuildCache(JDA client) {
+ this.client = client;
+ GuildCache.instance = this;
+ }
+
+ public boolean isCached(String id) {
+ return guilds.containsKey(id);
+ }
+
+ /**
+ * Loads guilds into the cache
+ * */
+ public void load() {
+ for (Guild g : client.getGuilds()) {
+ resetGuild(g.getId());
+ }
+ }
+
+ /**
+ * Returns an FGuild, directly from the cache if available, otherwise it's grabbed from the database/client.
+ * */
+ @NotNull
+ public FGuild getGuild(String id) {
+ // If the guild is cached
+ if (isCached(id)) {
+ return guilds.get(id);
+ }
+
+ return resetGuild(id);
+ }
+
+ /**
+ * Returns an FGuild, skipping the cache.
+ * */
+ @NotNull
+ public FGuild retrieveGuild(String id) {
+ Guild guild = client.getGuildById(id);
+ if (guild == null) {
+ throw new IllegalArgumentException("The provided guild does not exist.");
+ }
+
+ FGuild fGuild = new QFGuild().guildId.equalTo(id).findOne();
+ if (fGuild == null) {
+ // TODO Create new guild profile.
+ throw new IllegalStateException();
+ }
+
+ fGuild.setGuild(guild);
+
+ //return new FGuild(guild, entry);
+ return fGuild; // TODO
+ }
+
+ /**
+ * Resets the version in the cache.
+ * */
+ public FGuild resetGuild(String id) {
+ FGuild guild = retrieveGuild(id);
+ guilds.put(id, guild);
+ return guild;
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/core/data/config/FConfiguration.java b/src/main/java/io/paradaux/friendlybot/core/data/config/FConfiguration.java
new file mode 100644
index 00000000..e614ea07
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/data/config/FConfiguration.java
@@ -0,0 +1,150 @@
+package io.paradaux.friendlybot.core.data.config;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.spongepowered.configurate.objectmapping.ConfigSerializable;
+import org.spongepowered.configurate.objectmapping.meta.Comment;
+
+@ConfigSerializable
+public class FConfiguration {
+
+ @Comment("Your Discord Bot Token")
+ private @Nullable String botToken = "BOT-TOKEN";
+ @Comment("What symbol to begin commands with.")
+ private @Nullable String commandPrefix = ";";
+
+ @Comment("Mailgun is used to send verification emails. Enter your API key and URL here.")
+ private @Nullable String mailgunApplicationKey = "MAILGUN-TOKEN";
+ private @Nullable String mailgunBaseUrl = "MAILGUN-URL";
+
+ @Comment("Imgflip is used for meme generation. Enter your login details here.")
+ private @Nullable String imgflipUsername = "IMGFLIP-USERNAME";
+ private @Nullable String imgflipPassword = "IMGFLIP-PASSWORD";
+
+ @Comment("Other random services.")
+ private @Nullable String wolframAlphaApiKey = "WOLFRAM-API";
+ private @Nullable String imgurClientId = "IMGUR-CLIENT";
+ private @Nullable String bytebinInstanceUrl = "BYTEBIN-URL";
+ private @Nullable String openWeatherMapApiKey = "OPENWEATHER-API";
+
+ @Comment("Database connection")
+ private @Nullable String jdbcUrl = "DATABASE-URL";
+ private @Nullable String jdbcUsername = "DATABASE-USER";
+ private @Nullable String jdbcPassword = "DATABASE-PASS";
+
+ @Nullable
+ public String getBotToken() {
+ return botToken;
+ }
+
+ @Nullable
+ public String getCommandPrefix() {
+ return commandPrefix;
+ }
+
+ @Nullable
+ public String getMailgunApplicationKey() {
+ return mailgunApplicationKey;
+ }
+
+ @Nullable
+ public String getMailgunBaseUrl() {
+ return mailgunBaseUrl;
+ }
+
+ @Nullable
+ public String getImgflipUsername() {
+ return imgflipUsername;
+ }
+
+ @Nullable
+ public String getImgflipPassword() {
+ return imgflipPassword;
+ }
+
+ @Nullable
+ public String getWolframAlphaApiKey() {
+ return wolframAlphaApiKey;
+ }
+
+ @Nullable
+ public String getImgurClientId() {
+ return imgurClientId;
+ }
+
+ @Nullable
+ public String getBytebinInstanceUrl() {
+ return bytebinInstanceUrl;
+ }
+
+ @Nullable
+ public String getOpenWeatherMapApiKey() {
+ return openWeatherMapApiKey;
+ }
+
+ @Nullable
+ public String getJdbcUrl() {
+ return jdbcUrl;
+ }
+
+ @Nullable
+ public String getJdbcUsername() {
+ return jdbcUsername;
+ }
+
+ @Nullable
+ public String getJdbcPassword() {
+ return jdbcPassword;
+ }
+
+ public void setBotToken(@Nullable String botToken) {
+ this.botToken = botToken;
+ }
+
+ public void setCommandPrefix(@Nullable String commandPrefix) {
+ this.commandPrefix = commandPrefix;
+ }
+
+ public void setMailgunApplicationKey(@Nullable String mailgunApplicationKey) {
+ this.mailgunApplicationKey = mailgunApplicationKey;
+ }
+
+ public void setMailgunBaseUrl(@Nullable String mailgunBaseUrl) {
+ this.mailgunBaseUrl = mailgunBaseUrl;
+ }
+
+ public void setImgflipUsername(@Nullable String imgflipUsername) {
+ this.imgflipUsername = imgflipUsername;
+ }
+
+ public void setImgflipPassword(@Nullable String imgflipPassword) {
+ this.imgflipPassword = imgflipPassword;
+ }
+
+ public void setWolframAlphaApiKey(@Nullable String wolframAlphaApiKey) {
+ this.wolframAlphaApiKey = wolframAlphaApiKey;
+ }
+
+ public void setImgurClientId(@Nullable String imgurClientId) {
+ this.imgurClientId = imgurClientId;
+ }
+
+ public void setBytebinInstanceUrl(@Nullable String bytebinInstanceUrl) {
+ this.bytebinInstanceUrl = bytebinInstanceUrl;
+ }
+
+ public void setOpenWeatherMapApiKey(@Nullable String openWeatherMapApiKey) {
+ this.openWeatherMapApiKey = openWeatherMapApiKey;
+ }
+
+ public void setJdbcUrl(@Nullable String jdbcUrl) {
+ this.jdbcUrl = jdbcUrl;
+ }
+
+ public void setJdbcUsername(@Nullable String jdbcUsername) {
+ this.jdbcUsername = jdbcUsername;
+ }
+
+ public void setJdbcPassword(@Nullable String jdbcPassword) {
+ this.jdbcPassword = jdbcPassword;
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/core/data/config/FConfigurationLoader.java b/src/main/java/io/paradaux/friendlybot/core/data/config/FConfigurationLoader.java
new file mode 100644
index 00000000..6641f5f1
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/data/config/FConfigurationLoader.java
@@ -0,0 +1,56 @@
+package io.paradaux.friendlybot.core.data.config;
+
+import io.paradaux.friendlybot.core.utils.IOUtils;
+import org.spongepowered.configurate.CommentedConfigurationNode;
+import org.spongepowered.configurate.ConfigurateException;
+import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
+import org.spongepowered.configurate.serialize.SerializationException;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+
+public class FConfigurationLoader {
+
+ private static HoconConfigurationLoader loader;
+ private static FConfiguration config;
+ private static CommentedConfigurationNode root;
+
+ public static HoconConfigurationLoader getLoader() {
+ return loader;
+ }
+
+ public static FConfiguration loadConfig() throws SerializationException {
+ deployConfig();
+
+ loader = HoconConfigurationLoader.builder()
+ .path(Path.of("friendlybot.conf"))
+ .build();
+
+ try {
+ root = loader.load();
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ config = root.get(FConfiguration.class);
+
+ if (config == null) {
+ throw new IllegalStateException("Configuration is null");
+ }
+
+ return config;
+ }
+
+ public static void saveConfig() throws ConfigurateException {
+ root.set(FConfiguration.class, config);
+ loader.save(root);
+ }
+
+ private static void deployConfig() {
+ if (!new File("friendlybot.conf").exists()) {
+ IOUtils.exportResource("/friendlybot.conf",System.getProperty("user.dir") + "/friendlybot.conf");
+ }
+ }
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/core/data/database/EBeanConnection.java b/src/main/java/io/paradaux/friendlybot/core/data/database/EBeanConnection.java
new file mode 100644
index 00000000..9fa9b7ce
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/data/database/EBeanConnection.java
@@ -0,0 +1,28 @@
+package io.paradaux.friendlybot.core.data.database;
+
+import io.ebean.Database;
+import io.ebean.DatabaseFactory;
+import io.ebean.config.DatabaseConfig;
+import io.ebean.datasource.DataSourceConfig;
+import io.paradaux.friendlybot.core.data.config.FConfiguration;
+
+public class EBeanConnection {
+
+ private final DatabaseConfig dbConfig = new DatabaseConfig();
+ private final Database database;
+
+ public EBeanConnection(FConfiguration config) {
+
+ DataSourceConfig dataSourceConfig = new DataSourceConfig();
+ dataSourceConfig.addProperty("ebean.db.ddl.generate", "true");
+ dataSourceConfig.addProperty("ebean.db.ddl.run", "true");
+ dataSourceConfig.setUsername(config.getJdbcUsername());
+ dataSourceConfig.setPassword(config.getJdbcPassword());
+ dataSourceConfig.setUrl(config.getJdbcUrl());
+
+ dbConfig.setDataSourceConfig(dataSourceConfig);
+ database = DatabaseFactory.create(dbConfig);
+
+ }
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/core/data/database/models/FGuild.java b/src/main/java/io/paradaux/friendlybot/core/data/database/models/FGuild.java
new file mode 100644
index 00000000..5fe905da
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/data/database/models/FGuild.java
@@ -0,0 +1,187 @@
+package io.paradaux.friendlybot.core.data.database.models;
+
+import io.ebean.Model;
+import io.ebean.annotation.DbJsonB;
+import net.dv8tion.jda.api.entities.Guild;
+
+import javax.annotation.Nullable;
+import javax.persistence.*;
+import java.util.List;
+
+@Entity
+@Table(name = "guilds")
+public class FGuild extends Model {
+
+ @Id
+ private long id;
+
+ @Transient
+ @Nullable
+ private Guild guild;
+
+ private String guildId;
+ private String commandPrefix;
+
+ private String verificationRoleId;
+ private String verificationInputId;
+
+ private String auditLogId;
+ private String modAuditLogId;
+
+ private String modMailInId;
+ private String modMailOutId;
+
+ private String messageLogId;
+
+ @DbJsonB
+ private List moderators;
+
+ @DbJsonB
+ private List administrators;
+
+ @OneToMany(mappedBy="guild", cascade=CascadeType.ALL)
+ private List users;
+
+ private Integer lastIncidentId;
+ private Integer lastTicketId;
+
+ public FGuild() {
+
+ }
+
+ public FGuild(@Nullable Guild guild) {
+ this.guild = guild;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ @Nullable
+ public Guild getGuild() {
+ if (guild == null) {
+ //guild = GuildCache.getInstance().getGuild(guildId);
+ }
+ return guild;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public void setGuild(@Nullable Guild guild) {
+ this.guild = guild;
+ }
+
+ public String getGuildId() {
+ return guildId;
+ }
+
+ public void setGuildId(String guildId) {
+ this.guildId = guildId;
+ }
+
+ public String getCommandPrefix() {
+ return commandPrefix;
+ }
+
+ public void setCommandPrefix(String commandPrefix) {
+ this.commandPrefix = commandPrefix;
+ }
+
+ public String getVerificationRoleId() {
+ return verificationRoleId;
+ }
+
+ public void setVerificationRoleId(String verificationRoleId) {
+ this.verificationRoleId = verificationRoleId;
+ }
+
+ public String getVerificationInputId() {
+ return verificationInputId;
+ }
+
+ public void setVerificationInputId(String verificationInputId) {
+ this.verificationInputId = verificationInputId;
+ }
+
+ public String getAuditLogId() {
+ return auditLogId;
+ }
+
+ public void setAuditLogId(String auditLogId) {
+ this.auditLogId = auditLogId;
+ }
+
+ public String getModAuditLogId() {
+ return modAuditLogId;
+ }
+
+ public void setModAuditLogId(String modAuditLogId) {
+ this.modAuditLogId = modAuditLogId;
+ }
+
+ public String getModMailInId() {
+ return modMailInId;
+ }
+
+ public void setModMailInId(String modMailInId) {
+ this.modMailInId = modMailInId;
+ }
+
+ public String getModMailOutId() {
+ return modMailOutId;
+ }
+
+ public void setModMailOutId(String modMailOutId) {
+ this.modMailOutId = modMailOutId;
+ }
+
+ public String getMessageLogId() {
+ return messageLogId;
+ }
+
+ public void setMessageLogId(String messageLogId) {
+ this.messageLogId = messageLogId;
+ }
+
+ public List getModerators() {
+ return moderators;
+ }
+
+ public void setModerators(List moderators) {
+ this.moderators = moderators;
+ }
+
+ public List getAdministrators() {
+ return administrators;
+ }
+
+ public void setAdministrators(List administrators) {
+ this.administrators = administrators;
+ }
+
+ public List getUsers() {
+ return users;
+ }
+
+ public void setUsers(List users) {
+ this.users = users;
+ }
+
+ public Integer getLastIncidentId() {
+ return lastIncidentId;
+ }
+
+ public void setLastIncidentId(Integer lastIncidentId) {
+ this.lastIncidentId = lastIncidentId;
+ }
+
+ public Integer getLastTicketId() {
+ return lastTicketId;
+ }
+
+ public void setLastTicketId(Integer lastTicketId) {
+ this.lastTicketId = lastTicketId;
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/core/data/database/models/FUser.java b/src/main/java/io/paradaux/friendlybot/core/data/database/models/FUser.java
new file mode 100644
index 00000000..d4e141d8
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/data/database/models/FUser.java
@@ -0,0 +1,81 @@
+package io.paradaux.friendlybot.core.data.database.models;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import java.util.Date;
+
+@Entity
+@Table(name = "users")
+public class FUser {
+
+ @Id
+ private long id;
+
+ @ManyToOne(optional = false)
+ private FGuild guild;
+
+ private String guildId;
+ private String userId;
+
+ private String customColorRole;
+ private String discordTag;
+ private Date lastChangedColor;
+
+ public long getId() {
+ return id;
+ }
+
+ public FGuild getGuild() {
+ return guild;
+ }
+
+ public String getGuildId() {
+ return guildId;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public String getCustomColorRole() {
+ return customColorRole;
+ }
+
+ public String getDiscordTag() {
+ return discordTag;
+ }
+
+ public Date getLastChangedColor() {
+ return lastChangedColor;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public void setGuild(FGuild guild) {
+ this.guild = guild;
+ }
+
+ public void setGuildId(String guildId) {
+ this.guildId = guildId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public void setCustomColorRole(String customColorRole) {
+ this.customColorRole = customColorRole;
+ }
+
+ public void setDiscordTag(String discordTag) {
+ this.discordTag = discordTag;
+ }
+
+ public void setLastChangedColor(Date lastChangedColor) {
+ this.lastChangedColor = lastChangedColor;
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/core/data/database/models/GuildSettings.java b/src/main/java/io/paradaux/friendlybot/core/data/database/models/GuildSettings.java
new file mode 100644
index 00000000..3c770075
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/data/database/models/GuildSettings.java
@@ -0,0 +1,34 @@
+package io.paradaux.friendlybot.core.data.database.models;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class GuildSettings {
+
+ @Id
+ String guildId;
+
+ String guildName;
+
+ public String getGuildId() {
+ return guildId;
+ }
+
+ public String getGuildName() {
+ return guildName;
+ }
+
+ public void setGuildId(String guildId) {
+ this.guildId = guildId;
+ }
+
+ public void setGuildName(String guildName) {
+ this.guildName = guildName;
+ }
+
+ @Override
+ public String toString() {
+ return "GuildSettings{" + "guildId='" + guildId + '\'' + ", guildName='" + guildName + '\'' + '}';
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/core/locale/LocaleLogger.java b/src/main/java/io/paradaux/friendlybot/core/locale/LocaleLogger.java
new file mode 100644
index 00000000..634c919c
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/locale/LocaleLogger.java
@@ -0,0 +1,40 @@
+package io.paradaux.friendlybot.core.locale;
+
+import org.slf4j.Logger;
+
+/**
+ * A wrapper on top of SLF4J which allows for the logging of system messages using locale entries to provide easier internationalisation.
+ * @author RÃan Errity
+ * */
+public class LocaleLogger {
+
+ private static Logger logger;
+ private static boolean debug;
+
+ public LocaleLogger(Logger logger, boolean debug) {
+ LocaleLogger.logger = logger;
+ LocaleLogger.debug = debug;
+ }
+
+ public static void toggleDebug() {
+ debug = !debug;
+ }
+
+ public static void info(String str, String... args) {
+ logger.info(LocaleManager.get(str), (Object[]) args);
+ }
+
+ public static void warn(String str, String... args) {
+ logger.warn(LocaleManager.get(str), (Object[]) args);
+ }
+
+ public static void debug(String str, String... args) {
+ if (debug) {
+ logger.debug(LocaleManager.get(str), (Object[]) args);
+ }
+ }
+
+ public static void error(String str, String... args) {
+ logger.error(str, (Object[]) args);
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/core/locale/LocaleManager.java b/src/main/java/io/paradaux/friendlybot/core/locale/LocaleManager.java
new file mode 100644
index 00000000..84777c4e
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/locale/LocaleManager.java
@@ -0,0 +1,42 @@
+package io.paradaux.friendlybot.core.locale;
+
+import io.paradaux.friendlybot.core.utils.IOUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+
+/**
+ * Utility to loading and holding singleton instances of the ResourceBundle which serves as the locale/internationalisation system for the
+ * plugin.
+ * @author RÃan Errity
+ * */
+public class LocaleManager {
+
+ private static final File locale = new File("friendlybot-locale.properties");
+
+ private static ResourceBundle bundle;
+
+ public LocaleManager() {
+ if (!locale.exists()) {
+ IOUtils.exportResource("/friendlybot-locale.properties", System.getProperty("user.dir") + "/friendlybot-locale.properties");
+ } else {
+ try (FileInputStream fis = new FileInputStream(locale)) {
+ bundle = new PropertyResourceBundle(fis);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static String get(String key) {
+// if (!bundle.containsKey(key)) {
+// return key;
+// }
+//
+// return bundle.getString(key);
+ return "test";
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/io/paradaux/friendlybot/utils/API.java b/src/main/java/io/paradaux/friendlybot/core/utils/API.java
similarity index 97%
rename from src/main/java/io/paradaux/friendlybot/utils/API.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/API.java
index 32aab7d0..ba01d753 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/API.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/API.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils;
+package io.paradaux.friendlybot.core.utils;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
import io.paradaux.friendlybot.managers.*;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
import org.slf4j.Logger;
public class API {
diff --git a/src/main/java/io/paradaux/friendlybot/utils/HttpUtils.java b/src/main/java/io/paradaux/friendlybot/core/utils/HttpUtils.java
similarity index 97%
rename from src/main/java/io/paradaux/friendlybot/utils/HttpUtils.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/HttpUtils.java
index d3d018a7..173d8995 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/HttpUtils.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/HttpUtils.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils;
+package io.paradaux.friendlybot.core.utils;
import okhttp3.OkHttpClient;
import okhttp3.Request;
diff --git a/src/main/java/io/paradaux/friendlybot/core/utils/IOUtils.java b/src/main/java/io/paradaux/friendlybot/core/utils/IOUtils.java
new file mode 100644
index 00000000..6941dc60
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/IOUtils.java
@@ -0,0 +1,41 @@
+package io.paradaux.friendlybot.core.utils;
+
+import io.paradaux.friendlybot.core.utils.models.exceptions.NoSuchResourceException;
+import io.paradaux.friendlybot.managers.IOManager;
+
+import javax.annotation.Nullable;
+import java.io.*;
+
+public class IOUtils {
+
+ /**
+ * Export a resource embedded into a Jar file to the local file path.
+ *
+ * @param inputPath ie.: "/configuration.yml" N.B / is a directory down in the "jar tree" been the jar the root of the tree
+ * @throws NoSuchResourceException a generic exception to signal something went wrong
+ */
+ public static void exportResource(String inputPath, @Nullable String outputPath) throws NoSuchResourceException {
+
+ OutputStream resourceOutputStream;
+
+ try (InputStream resourceStream = IOManager.class.getResourceAsStream(inputPath)) {
+ resourceOutputStream = new FileOutputStream(outputPath);
+
+ if (resourceStream == null) {
+ throw new FileNotFoundException("Cannot get resource \"" + inputPath + "\" from Jar file.");
+ }
+
+ int readBytes;
+ byte[] buffer = new byte[4096];
+
+ while ((readBytes = resourceStream.read(buffer)) > 0) {
+ resourceOutputStream.write(buffer, 0, readBytes);
+ }
+
+ resourceOutputStream.close();
+ } catch (IOException exception) {
+ throw new NoSuchResourceException("Failed to deploy resource : " + exception.getMessage());
+ }
+ }
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/ImageUtils.java b/src/main/java/io/paradaux/friendlybot/core/utils/ImageUtils.java
similarity index 94%
rename from src/main/java/io/paradaux/friendlybot/utils/ImageUtils.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/ImageUtils.java
index fe92ddfc..b408b669 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/ImageUtils.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/ImageUtils.java
@@ -1,4 +1,4 @@
-package io.paradaux.friendlybot.utils;
+package io.paradaux.friendlybot.core.utils;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/NumberUtils.java b/src/main/java/io/paradaux/friendlybot/core/utils/NumberUtils.java
similarity index 97%
rename from src/main/java/io/paradaux/friendlybot/utils/NumberUtils.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/NumberUtils.java
index c411d078..55a2de1a 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/NumberUtils.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/NumberUtils.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils;
+package io.paradaux.friendlybot.core.utils;
import javax.annotation.CheckReturnValue;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/RandomUtils.java b/src/main/java/io/paradaux/friendlybot/core/utils/RandomUtils.java
similarity index 98%
rename from src/main/java/io/paradaux/friendlybot/utils/RandomUtils.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/RandomUtils.java
index bcdfb7a7..5f315305 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/RandomUtils.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/RandomUtils.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils;
+package io.paradaux.friendlybot.core.utils;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/StringUtils.java b/src/main/java/io/paradaux/friendlybot/core/utils/StringUtils.java
similarity index 83%
rename from src/main/java/io/paradaux/friendlybot/utils/StringUtils.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/StringUtils.java
index e6b41347..e858aaf4 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/StringUtils.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/StringUtils.java
@@ -23,30 +23,29 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils;
+package io.paradaux.friendlybot.core.utils;
import javax.annotation.Nullable;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
import java.util.Base64;
import java.util.Random;
import java.util.regex.Pattern;
public class StringUtils {
- private static final Pattern VALID_EMAIL = Pattern.compile("(?:[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+(?:\\"
- + ".[a-z0-9!#$%&'*+\\/=?^_`{|}~-]+)*|\""
+ private static final Pattern VALID_EMAIL = Pattern.compile("(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\"
+ + ".[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\""
+ "(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01"
+ "-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)"
+ "+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:"
+ "(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}"
+ "(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:"
+ "(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09"
- + "\\x0b\\x0c\\x0e-\\x7f])+)\\])");
+ + "\\x0b\\x0c\\x0e-\\x7f])+)])");
- private static final char STRIKE_CONTROL_CHARACTER = '\u0336';
-
- private static final String SHORTHAND_CARDINAL_DIRECTIONS[] = {"N", "NE", "E", "SE", "S", "SW", "W", "NW", "N"};
+ private static final String[] SHORTHAND_CARDINAL_DIRECTIONS = {"N", "NE", "E", "SE", "S", "SW", "W", "NW", "N"};
/**
* Converts the specified string to Title Case
@@ -137,20 +136,32 @@ public static String removeLetters(String str) {
}
/**
- * Creates strikethrough unicode text by applying the strike control character after each individual character in the provided string
+ * Converts a heading in degrees to a shorthand cardinal direction.
+ * */
+ public static String headingToShortCardinalDirection(double heading) {
+ return SHORTHAND_CARDINAL_DIRECTIONS[(int) Math.round(((heading % 360)/45))];
+ }
+
+ /**
+ * Parses a boolean from human input, whether that be "yes" or "no" or "true" and "false."
* */
- public static String toStrikeOut(String str) {
- final StringBuilder builder = new StringBuilder();
- for (char c : str.toCharArray()) {
- builder.append(c).append(STRIKE_CONTROL_CHARACTER);
+ public static boolean parseBoolean(String str) {
+ str = str.toLowerCase();
+ if (str.contains("yes") || str.contains("true")) {
+ return true;
}
- return builder.toString();
+
+ if (str.contains("no") || str.contains("false")) {
+ return false;
+ }
+
+ throw new IllegalArgumentException("Argument did not contain boolean value.");
}
/**
- * Converts a heading in degrees to a shorthand cardinal direction.
+ * Parses a sentence from the specified arguments, beginning at the specified array index.
* */
- public static String headingToShortCardinalDirection(double heading) {
- return SHORTHAND_CARDINAL_DIRECTIONS[(int) Math.round(((heading % 360)/45))];
+ public static String parseSentence(int startElement, String[] args) {
+ return String.join(" ", Arrays.copyOfRange(args, startElement, args.length));
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/TimeUtils.java b/src/main/java/io/paradaux/friendlybot/core/utils/TimeUtils.java
similarity index 99%
rename from src/main/java/io/paradaux/friendlybot/utils/TimeUtils.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/TimeUtils.java
index 6aeff770..e6ed4490 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/TimeUtils.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/TimeUtils.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils;
+package io.paradaux.friendlybot.core.utils;
import java.time.*;
import java.time.format.DateTimeFormatter;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/AuditLogEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/AuditLogEmbed.java
similarity index 92%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/AuditLogEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/AuditLogEmbed.java
index 574e3cf2..90f6869f 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/AuditLogEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/AuditLogEmbed.java
@@ -23,11 +23,11 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds;
+package io.paradaux.friendlybot.core.utils.embeds;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.types.ModerationAction;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/PoliticsRulesEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/PoliticsRulesEmbed.java
similarity index 95%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/PoliticsRulesEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/PoliticsRulesEmbed.java
index 34692076..df1ca7c9 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/PoliticsRulesEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/PoliticsRulesEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds;
+package io.paradaux.friendlybot.core.utils.embeds;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/RulesEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/RulesEmbed.java
similarity index 96%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/RulesEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/RulesEmbed.java
index b1a3b508..8d92731d 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/RulesEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/RulesEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds;
+package io.paradaux.friendlybot.core.utils.embeds;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/command/UserInfoEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/command/UserInfoEmbed.java
similarity index 92%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/command/UserInfoEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/command/UserInfoEmbed.java
index 777a5f4f..0e915f18 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/command/UserInfoEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/command/UserInfoEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.command;
+package io.paradaux.friendlybot.core.utils.embeds.command;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/BannedEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/BannedEmbed.java
similarity index 92%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/BannedEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/BannedEmbed.java
index cdb312d0..44c47ced 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/BannedEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/BannedEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.moderation;
+package io.paradaux.friendlybot.core.utils.embeds.moderation;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/ChatFilterTriggeredEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/ChatFilterTriggeredEmbed.java
similarity index 90%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/ChatFilterTriggeredEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/ChatFilterTriggeredEmbed.java
index f4cab77d..2fd9c1e9 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/ChatFilterTriggeredEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/ChatFilterTriggeredEmbed.java
@@ -23,11 +23,11 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.moderation;
+package io.paradaux.friendlybot.core.utils.embeds.moderation;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.types.ModerationAction;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/CiteRuleEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/CiteRuleEmbed.java
similarity index 96%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/CiteRuleEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/CiteRuleEmbed.java
index f1ce9ee0..0a70b0ea 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/CiteRuleEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/CiteRuleEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.moderation;
+package io.paradaux.friendlybot.core.utils.embeds.moderation;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/KickedEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/KickedEmbed.java
similarity index 92%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/KickedEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/KickedEmbed.java
index b7b72730..a85ec65f 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/KickedEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/KickedEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.moderation;
+package io.paradaux.friendlybot.core.utils.embeds.moderation;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/TimedOutEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/TimedOutEmbed.java
similarity index 93%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/TimedOutEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/TimedOutEmbed.java
index 45856bbb..dd649bfa 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/TimedOutEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/TimedOutEmbed.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.moderation;
+package io.paradaux.friendlybot.core.utils.embeds.moderation;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/WarningEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/WarningEmbed.java
similarity index 94%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/WarningEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/WarningEmbed.java
index 282e175f..d2fd5525 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/moderation/WarningEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/moderation/WarningEmbed.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.moderation;
+package io.paradaux.friendlybot.core.utils.embeds.moderation;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/modmail/ModMailReceivedEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/modmail/ModMailReceivedEmbed.java
similarity index 93%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/modmail/ModMailReceivedEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/modmail/ModMailReceivedEmbed.java
index daf9fac2..ebdf4066 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/modmail/ModMailReceivedEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/modmail/ModMailReceivedEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.modmail;
+package io.paradaux.friendlybot.core.utils.embeds.modmail;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/modmail/ModMailSentEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/modmail/ModMailSentEmbed.java
similarity index 92%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/modmail/ModMailSentEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/modmail/ModMailSentEmbed.java
index 8dfb654c..804a6a2e 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/modmail/ModMailSentEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/modmail/ModMailSentEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.modmail;
+package io.paradaux.friendlybot.core.utils.embeds.modmail;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/ModMailNoticeEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/ModMailNoticeEmbed.java
similarity index 92%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/notices/ModMailNoticeEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/ModMailNoticeEmbed.java
index 7e6ae10a..cbb82174 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/ModMailNoticeEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/ModMailNoticeEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.notices;
+package io.paradaux.friendlybot.core.utils.embeds.notices;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/NoPermissionEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/NoPermissionEmbed.java
similarity index 91%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/notices/NoPermissionEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/NoPermissionEmbed.java
index 2b474efb..a9474fa7 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/NoPermissionEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/NoPermissionEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.notices;
+package io.paradaux.friendlybot.core.utils.embeds.notices;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/RulesAcceptanceNoticeEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/RulesAcceptanceNoticeEmbed.java
similarity index 90%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/notices/RulesAcceptanceNoticeEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/RulesAcceptanceNoticeEmbed.java
index 42cc9c9f..a1f10ff7 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/RulesAcceptanceNoticeEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/RulesAcceptanceNoticeEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.notices;
+package io.paradaux.friendlybot.core.utils.embeds.notices;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/SyntaxErrorEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/SyntaxErrorEmbed.java
similarity index 91%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/notices/SyntaxErrorEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/SyntaxErrorEmbed.java
index 6ffbfd9e..5b4a6c3b 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/SyntaxErrorEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/SyntaxErrorEmbed.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.notices;
+package io.paradaux.friendlybot.core.utils.embeds.notices;
-import io.paradaux.friendlybot.utils.models.enums.EmbedColour;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.enums.EmbedColour;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/VerificationNoticeEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/VerificationNoticeEmbed.java
similarity index 95%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/notices/VerificationNoticeEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/VerificationNoticeEmbed.java
index 72a3fee4..fcaeed7a 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/notices/VerificationNoticeEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/notices/VerificationNoticeEmbed.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.notices;
+package io.paradaux.friendlybot.core.utils.embeds.notices;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/ClassEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/ClassEmbed.java
similarity index 93%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/ClassEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/ClassEmbed.java
index 8fd74f85..09a23766 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/ClassEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/ClassEmbed.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.roleselection;
+package io.paradaux.friendlybot.core.utils.embeds.roleselection;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/CourseEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/CourseEmbed.java
similarity index 93%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/CourseEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/CourseEmbed.java
index 3f3f1c7e..93dfde71 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/CourseEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/CourseEmbed.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.roleselection;
+package io.paradaux.friendlybot.core.utils.embeds.roleselection;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/InterestsEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/InterestsEmbed.java
similarity index 94%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/InterestsEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/InterestsEmbed.java
index c9668ed2..2c26b1e4 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/InterestsEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/InterestsEmbed.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.roleselection;
+package io.paradaux.friendlybot.core.utils.embeds.roleselection;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/PoliticsOptionEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/PoliticsOptionEmbed.java
similarity index 93%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/PoliticsOptionEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/PoliticsOptionEmbed.java
index 88126e4c..6f8988a0 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/PoliticsOptionEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/PoliticsOptionEmbed.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.roleselection;
+package io.paradaux.friendlybot.core.utils.embeds.roleselection;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/PronounEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/PronounEmbed.java
similarity index 94%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/PronounEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/PronounEmbed.java
index 3fdd9a6d..f63d4aea 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/PronounEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/PronounEmbed.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.roleselection;
+package io.paradaux.friendlybot.core.utils.embeds.roleselection;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/YearEmbed.java b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/YearEmbed.java
similarity index 93%
rename from src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/YearEmbed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/YearEmbed.java
index b47c7e6b..8203405a 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/embeds/roleselection/YearEmbed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/embeds/roleselection/YearEmbed.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.embeds.roleselection;
+package io.paradaux.friendlybot.core.utils.embeds.roleselection;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/configuration/ConfigurationEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/configuration/ConfigurationEntry.java
similarity index 99%
rename from src/main/java/io/paradaux/friendlybot/utils/models/configuration/ConfigurationEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/configuration/ConfigurationEntry.java
index e39df207..2f29b4f3 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/configuration/ConfigurationEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/configuration/ConfigurationEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.configuration;
+package io.paradaux.friendlybot.core.utils.models.configuration;
import com.google.gson.annotations.SerializedName;
import io.paradaux.friendlybot.managers.ConfigManager;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/configuration/PermissionEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/configuration/PermissionEntry.java
similarity index 97%
rename from src/main/java/io/paradaux/friendlybot/utils/models/configuration/PermissionEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/configuration/PermissionEntry.java
index e09afbbb..1748c32c 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/configuration/PermissionEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/configuration/PermissionEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.configuration;
+package io.paradaux.friendlybot.core.utils.models.configuration;
import com.google.gson.annotations.SerializedName;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/AuditLogEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/AuditLogEntry.java
similarity index 78%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/AuditLogEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/AuditLogEntry.java
index c38ab423..7be75860 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/AuditLogEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/AuditLogEntry.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
+import io.paradaux.friendlybot.core.utils.models.types.ModerationAction;
import org.bson.codecs.pojo.annotations.BsonProperty;
import java.io.Serializable;
@@ -35,6 +35,9 @@ public class AuditLogEntry implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value="guild_id")
+ private String guildId;
+
@BsonProperty(value = "action")
private ModerationAction action;
@@ -63,19 +66,9 @@ public AuditLogEntry() {
}
- public AuditLogEntry(ModerationAction action, String incidentID, String userTag,
- String userID, String reason, Date timestamp) {
- this.action = action;
- this.incidentID = incidentID;
- this.userTag = userTag;
- this.userID = userID;
- this.reason = reason;
- this.timestamp = timestamp;
- }
-
- public AuditLogEntry(ModerationAction action, String incidentID, String userTag,
- String userID, String staffTag, String staffID, String reason,
- Date timestamp) {
+ public AuditLogEntry(String guildId, ModerationAction action, String incidentID, String userTag, String userID, String staffTag,
+ String staffID, String reason, Date timestamp) {
+ this.guildId = guildId;
this.action = action;
this.incidentID = incidentID;
this.userTag = userTag;
@@ -86,14 +79,9 @@ public AuditLogEntry(ModerationAction action, String incidentID, String userTag,
this.timestamp = timestamp;
}
- public AuditLogEntry(ModerationAction action, String incidentID, String userTag,
- String userID, String reason) {
- this.action = action;
- this.incidentID = incidentID;
- this.userTag = userTag;
- this.userID = userID;
- this.reason = reason;
- this.timestamp = new Date();
+ public AuditLogEntry setGuildId(String guildId) {
+ this.guildId = guildId;
+ return this;
}
public AuditLogEntry setAction(ModerationAction action) {
@@ -136,6 +124,10 @@ public AuditLogEntry setStaffID(String staffID) {
return this;
}
+ public String getGuildId() {
+ return guildId;
+ }
+
public String getUserTag() {
return userTag;
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/BanEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/BanEntry.java
similarity index 86%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/BanEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/BanEntry.java
index aa305ed4..a2184b76 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/BanEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/BanEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
@@ -34,6 +34,9 @@ public class BanEntry implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value="guild_id")
+ private String guildId;
+
@BsonProperty(value = "incident_id")
private String incidentID;
@@ -59,7 +62,9 @@ public BanEntry() {
}
- public BanEntry(String incidentID, String userTag, String userID, String staffTag, String staffID, String reason, Date timestamp) {
+ public BanEntry(String guildId, String incidentID, String userTag, String userID, String staffTag, String staffID, String reason,
+ Date timestamp) {
+ this.guildId = guildId;
this.incidentID = incidentID;
this.userTag = userTag;
this.userID = userID;
@@ -69,6 +74,10 @@ public BanEntry(String incidentID, String userTag, String userID, String staffTa
this.timestamp = timestamp;
}
+ public String getGuildId() {
+ return guildId;
+ }
+
public String getUserTag() {
return userTag;
}
@@ -97,6 +106,11 @@ public Date getTimestamp() {
return timestamp;
}
+ public BanEntry setGuildId(String guildId) {
+ this.guildId = guildId;
+ return this;
+ }
+
public BanEntry setIncidentID(String incidentID) {
this.incidentID = incidentID;
return this;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/BotStats.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/BotStats.java
similarity index 95%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/BotStats.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/BotStats.java
index be98f786..acf36422 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/BotStats.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/BotStats.java
@@ -1,4 +1,4 @@
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/GuildSettingsEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/GuildSettingsEntry.java
similarity index 55%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/GuildSettingsEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/GuildSettingsEntry.java
index 8f151943..d6fd29ff 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/GuildSettingsEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/GuildSettingsEntry.java
@@ -1,27 +1,59 @@
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
+
+import io.paradaux.friendlybot.managers.GuildSettingsManager;
+import org.bson.codecs.pojo.annotations.BsonProperty;
import java.io.Serializable;
+import java.util.HashMap;
public class GuildSettingsEntry implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value = "guild_id")
private String guildId;
+
+ @BsonProperty(value = "verification_role_id")
private String verificationRoleId;
+
+ @BsonProperty(value = "verification_input_channel")
private String verificationInputChannel;
+
+ @BsonProperty(value = "mod_audit_log_channel")
private String privateAuditLogChannel;
+
+ @BsonProperty(value = "audit_log_channel")
private String publicAuditLogChannel;
+
+ @BsonProperty(value = "modmail_input_channel")
private String modmailInputChannel;
+
+ @BsonProperty(value = "modmail_output_channel")
private String modmailOutputChannel;
+
+ @BsonProperty(value = "message_log_channel")
private String messageLogChannel;
+ @BsonProperty(value = "moderators")
+ private HashMap moderators;
+
+ @BsonProperty(value = "administrators")
+ private HashMap administrators;
+
+ @BsonProperty(value = "last_incident_id")
+ private Integer lastIncidentId;
+
+ @BsonProperty(value = "last_ticket_id")
+ private Integer lastTicketId;
+
public GuildSettingsEntry() {
}
public GuildSettingsEntry(String guildId, String verificationRoleId, String verificationInputChannel, String privateAuditLogChannel,
String publicAuditLogChannel, String modmailInputChannel, String modmailOutputChannel,
- String messageLogChannel) {
+ String messageLogChannel, HashMap moderators, HashMap administrators,
+ Integer lastIncidentId, Integer lastTicketId) {
this.guildId = guildId;
this.verificationRoleId = verificationRoleId;
this.verificationInputChannel = verificationInputChannel;
@@ -30,8 +62,24 @@ public GuildSettingsEntry(String guildId, String verificationRoleId, String veri
this.modmailInputChannel = modmailInputChannel;
this.modmailOutputChannel = modmailOutputChannel;
this.messageLogChannel = messageLogChannel;
+ this.moderators = moderators;
+ this.administrators = administrators;
+ this.lastIncidentId = lastIncidentId;
+ this.lastTicketId = lastTicketId;
}
+ public Integer getTicketId() {
+ GuildSettingsManager.getInstance().incrementTicketNumber(this.guildId);
+ return this.lastTicketId++;
+ }
+
+ public Integer getIncidentId() {
+ GuildSettingsManager.getInstance().incrementIncidentId(this.guildId);
+ return this.lastIncidentId++;
+ }
+
+ // Dumb Getters and Setters
+
public GuildSettingsEntry setGuildId(String guildId) {
this.guildId = guildId;
return this;
@@ -72,6 +120,26 @@ public GuildSettingsEntry setMessageLogChannel(String messageLogChannel) {
return this;
}
+ public GuildSettingsEntry setModerators(HashMap moderators) {
+ this.moderators = moderators;
+ return this;
+ }
+
+ public GuildSettingsEntry setAdministrators(HashMap administrators) {
+ this.administrators = administrators;
+ return this;
+ }
+
+ public GuildSettingsEntry setLastIncidentId(Integer lastIncidentId) {
+ this.lastIncidentId = lastIncidentId;
+ return this;
+ }
+
+ public GuildSettingsEntry setLastTicketId(Integer lastTicketId) {
+ this.lastTicketId = lastTicketId;
+ return this;
+ }
+
public static long getSerialVersionUID() {
return serialVersionUID;
}
@@ -107,4 +175,20 @@ public String getModmailOutputChannel() {
public String getMessageLogChannel() {
return messageLogChannel;
}
+
+ public HashMap getModerators() {
+ return moderators;
+ }
+
+ public HashMap getAdministrators() {
+ return administrators;
+ }
+
+ public Integer getLastIncidentId() {
+ return lastIncidentId;
+ }
+
+ public Integer getLastTicketId() {
+ return lastTicketId;
+ }
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/KickEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/KickEntry.java
similarity index 87%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/KickEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/KickEntry.java
index dcb06643..e9792dde 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/KickEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/KickEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
@@ -34,6 +34,9 @@ public class KickEntry implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value="guild_id")
+ private String guildId;
+
@BsonProperty(value = "incident_id")
private String incidentID;
@@ -59,8 +62,9 @@ public KickEntry() {
}
- public KickEntry(String incidentID, String userTag, String userID, String staffTag,
- String staffID, String reason, Date timestamp) {
+ public KickEntry(String guildId, String incidentID, String userTag, String userID, String staffTag, String staffID, String reason,
+ Date timestamp) {
+ this.guildId = guildId;
this.incidentID = incidentID;
this.userTag = userTag;
this.userID = userID;
@@ -70,6 +74,10 @@ public KickEntry(String incidentID, String userTag, String userID, String staffT
this.timestamp = timestamp;
}
+ public String getGuildId() {
+ return guildId;
+ }
+
public String getIncidentID() {
return incidentID;
}
@@ -133,4 +141,8 @@ public KickEntry setTimestamp(Date timestamp) {
return this;
}
+ public KickEntry setGuildId(String guildId) {
+ this.guildId = guildId;
+ return this;
+ }
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/MessageEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/MessageEntry.java
similarity index 82%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/MessageEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/MessageEntry.java
index 62b0d400..a54253d9 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/MessageEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/MessageEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
@@ -34,6 +34,9 @@ public class MessageEntry implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value="guild_id")
+ private String guildId;
+
@BsonProperty(value = "author_id")
private String authorId;
@@ -56,6 +59,16 @@ public MessageEntry() {
}
+ public MessageEntry(String guildId, String authorId, String messageId, String content, String channel, String newContent, Date date) {
+ this.guildId = guildId;
+ this.authorId = authorId;
+ this.messageId = messageId;
+ this.content = content;
+ this.channel = channel;
+ this.newContent = newContent;
+ this.date = date;
+ }
+
public MessageEntry(String authorId, String messageId, String content, String channel, String newContent, Date date) {
this.authorId = authorId;
this.messageId = messageId;
@@ -65,6 +78,11 @@ public MessageEntry(String authorId, String messageId, String content, String ch
this.date = date;
}
+ public MessageEntry setGuildId(String guildId) {
+ this.guildId = guildId;
+ return this;
+ }
+
public MessageEntry setAuthorId(String authorId) {
this.authorId = authorId;
return this;
@@ -95,6 +113,10 @@ public MessageEntry setNewContent(String newContent) {
return this;
}
+ public String getGuildId() {
+ return guildId;
+ }
+
public String getAuthorId() {
return authorId;
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/ModMailEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/ModMailEntry.java
similarity index 86%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/ModMailEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/ModMailEntry.java
index 9a901633..aa8de16b 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/ModMailEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/ModMailEntry.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
-import io.paradaux.friendlybot.utils.models.enums.TicketStatus;
+import io.paradaux.friendlybot.core.utils.models.enums.TicketStatus;
import org.bson.codecs.pojo.annotations.BsonProperty;
import java.io.Serializable;
@@ -36,6 +36,9 @@ public class ModMailEntry implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value="guild_id")
+ private String guildId;
+
@BsonProperty(value = "ticket_number")
private String ticketNumber;
@@ -67,8 +70,9 @@ public ModMailEntry() {
}
- public ModMailEntry(String ticketNumber, TicketStatus status, String userTag, String userID, String modmailMethod, String issue,
- Date timeOpened, Date lastResponded, List responses) {
+ public ModMailEntry(String guildId, String ticketNumber, TicketStatus status, String userTag, String userID, String modmailMethod,
+ String issue, Date timeOpened, Date lastResponded, List responses) {
+ this.guildId = guildId;
this.ticketNumber = ticketNumber;
this.status = status;
this.userTag = userTag;
@@ -80,6 +84,10 @@ public ModMailEntry(String ticketNumber, TicketStatus status, String userTag, St
this.responses = responses;
}
+ public String getGuildId() {
+ return guildId;
+ }
+
public String getTicketNumber() {
return ticketNumber;
}
@@ -116,6 +124,11 @@ public List getResponses() {
return responses;
}
+ public ModMailEntry setGuildId(String guildId) {
+ this.guildId = guildId;
+ return this;
+ }
+
public ModMailEntry setTicketNumber(String ticketNumber) {
this.ticketNumber = ticketNumber;
return this;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/ModMailResponse.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/ModMailResponse.java
similarity index 77%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/ModMailResponse.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/ModMailResponse.java
index 7d3d63a2..66a58fd1 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/ModMailResponse.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/ModMailResponse.java
@@ -23,7 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
+
+import org.bson.codecs.pojo.annotations.BsonProperty;
import java.io.Serializable;
@@ -31,10 +33,17 @@ public class ModMailResponse implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value="guild_id")
+ private String guildId;
+
+ @BsonProperty(value="author_id")
private String authorId;
+
+ @BsonProperty(value="message")
private String message;
-
- public ModMailResponse(String authorId, String message) {
+
+ public ModMailResponse(String guildId, String authorId, String message) {
+ this.guildId = guildId;
this.authorId = authorId;
this.message = message;
}
@@ -43,6 +52,10 @@ public ModMailResponse() {
}
+ public String getGuildId() {
+ return guildId;
+ }
+
public String getAuthorId() {
return authorId;
}
@@ -51,6 +64,11 @@ public String getMessage() {
return message;
}
+ public ModMailResponse setGuildId(String guildId) {
+ this.guildId = guildId;
+ return this;
+ }
+
public ModMailResponse setAuthorId(String authorId) {
this.authorId = authorId;
return this;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/PendingVerificationEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/PendingVerificationEntry.java
similarity index 90%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/PendingVerificationEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/PendingVerificationEntry.java
index 5777ca52..3abf7511 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/PendingVerificationEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/PendingVerificationEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
@@ -33,12 +33,12 @@ public class PendingVerificationEntry implements Serializable {
protected static final long serialVersionUID = 1L;
- @BsonProperty(value = "discord_id")
- private String discordID;
-
@BsonProperty(value = "guild_id")
private String guildID;
+ @BsonProperty(value = "discord_id")
+ private String discordID;
+
@BsonProperty(value = "verification_id")
private String verificationCode;
@@ -46,12 +46,16 @@ public PendingVerificationEntry() {
}
- public PendingVerificationEntry(String discordID, String guildID, String verificationCode) {
- this.discordID = discordID;
+ public PendingVerificationEntry(String guildID, String discordID, String verificationCode) {
this.guildID = guildID;
+ this.discordID = discordID;
this.verificationCode = verificationCode;
}
+ public static long getSerialVersionUID() {
+ return serialVersionUID;
+ }
+
public String getDiscordID() {
return discordID;
}
@@ -78,4 +82,5 @@ public PendingVerificationEntry setVerificationCode(String verificationCode) {
this.verificationCode = verificationCode;
return this;
}
+
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/RescindmentEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/RescindmentEntry.java
similarity index 83%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/RescindmentEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/RescindmentEntry.java
index 7f861593..445b7334 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/RescindmentEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/RescindmentEntry.java
@@ -1,6 +1,6 @@
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
+import io.paradaux.friendlybot.core.utils.models.types.ModerationAction;
import org.bson.codecs.pojo.annotations.BsonProperty;
import java.io.Serializable;
@@ -10,6 +10,9 @@ public class RescindmentEntry implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value = "guild_id")
+ private String guildID;
+
@BsonProperty(value = "action")
private ModerationAction action;
@@ -44,8 +47,9 @@ public RescindmentEntry() {
}
- public RescindmentEntry(ModerationAction action, String incidentId, String incidentIdOfPunishment, String userTag, String userId,
- String staffTag, String staffId, String reason, Date timeOfPunishment, Date timeOfRescindment) {
+ public RescindmentEntry(String guildID, ModerationAction action, String incidentId, String incidentIdOfPunishment, String userTag,
+ String userId, String staffTag, String staffId, String reason, Date timeOfPunishment, Date timeOfRescindment) {
+ this.guildID = guildID;
this.action = action;
this.incidentId = incidentId;
this.incidentIdOfPunishment = incidentIdOfPunishment;
@@ -58,6 +62,10 @@ public RescindmentEntry(ModerationAction action, String incidentId, String incid
this.timeOfRescindment = timeOfRescindment;
}
+ public String getGuildID() {
+ return guildID;
+ }
+
public ModerationAction getAction() {
return action;
}
@@ -147,4 +155,9 @@ public RescindmentEntry setTimeOfRescindment(Date timeOfRescindment) {
this.timeOfRescindment = timeOfRescindment;
return this;
}
+
+ public RescindmentEntry setGuildID(String guildID) {
+ this.guildID = guildID;
+ return this;
+ }
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/TagEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/TagEntry.java
similarity index 88%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/TagEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/TagEntry.java
index 75c464f6..85991a95 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/TagEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/TagEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
@@ -35,7 +35,7 @@ public class TagEntry implements Serializable {
protected static final long serialVersionUID = 2L;
@BsonProperty(value = "guild_id")
- private String guild;
+ private String guildId;
@BsonProperty(value = "discord_id")
private String discordId;
@@ -56,8 +56,8 @@ public TagEntry() {
}
- public TagEntry(String guild, String discordId, String id, String content, Date timeCreated, boolean isDotCommand) {
- this.guild = guild;
+ public TagEntry(String guildId, String discordId, String id, String content, Date timeCreated, boolean isDotCommand) {
+ this.guildId = guildId;
this.discordId = discordId;
this.id = id;
this.content = content;
@@ -65,8 +65,8 @@ public TagEntry(String guild, String discordId, String id, String content, Date
this.isDotCommand = isDotCommand;
}
- public String getGuild() {
- return guild;
+ public String getGuildId() {
+ return guildId;
}
public String getDiscordId() {
@@ -89,8 +89,8 @@ public boolean isDotCommand() {
return isDotCommand;
}
- public TagEntry setGuild(String guild) {
- this.guild = guild;
+ public TagEntry setGuildId(String guildId) {
+ this.guildId = guildId;
return this;
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/TempBanEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/TempBanEntry.java
similarity index 87%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/TempBanEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/TempBanEntry.java
index 9dc37687..54868807 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/TempBanEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/TempBanEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
@@ -34,6 +34,9 @@ public class TempBanEntry implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value = "guild_id")
+ private String guildID;
+
@BsonProperty(value = "incident_id")
private String incidentId;
@@ -62,8 +65,9 @@ public TempBanEntry() {
}
- public TempBanEntry(String incidentId, String userTag, String userId, String staffTag, String staffId, String reason, Date timestamp,
- Date expiry) {
+ public TempBanEntry(String guildID, String incidentId, String userTag, String userId, String staffTag, String staffId, String reason,
+ Date timestamp, Date expiry) {
+ this.guildID = guildID;
this.incidentId = incidentId;
this.userTag = userTag;
this.userId = userId;
@@ -74,6 +78,10 @@ public TempBanEntry(String incidentId, String userTag, String userId, String sta
this.expiry = expiry;
}
+ public String getGuildID() {
+ return guildID;
+ }
+
public String getIncidentId() {
return incidentId;
}
@@ -145,4 +153,10 @@ public TempBanEntry setExpiry(Date expiry) {
this.expiry = expiry;
return this;
}
+
+ public TempBanEntry setGuildID(String guildID) {
+ this.guildID = guildID;
+ return this;
+ }
+
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/UserSettingsEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/UserSettingsEntry.java
similarity index 98%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/UserSettingsEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/UserSettingsEntry.java
index 1b5355fa..ea0ab01d 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/UserSettingsEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/UserSettingsEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/VerificationEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/VerificationEntry.java
similarity index 97%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/VerificationEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/VerificationEntry.java
index cce19aec..fa807b49 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/VerificationEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/VerificationEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
@@ -34,12 +34,12 @@ public class VerificationEntry implements Serializable {
protected static final long serialVersionUID = 1L;
- @BsonProperty(value = "discord_id")
- private String discordID;
-
@BsonProperty(value = "guild_id")
private String guildID;
+ @BsonProperty(value = "discord_id")
+ private String discordID;
+
@BsonProperty(value = "date_verified")
private Date dateVerified;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/WarningEntry.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/WarningEntry.java
similarity index 86%
rename from src/main/java/io/paradaux/friendlybot/utils/models/database/WarningEntry.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/database/WarningEntry.java
index 076759cf..ae3b468f 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/WarningEntry.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/database/WarningEntry.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.database;
+package io.paradaux.friendlybot.core.utils.models.database;
import org.bson.codecs.pojo.annotations.BsonProperty;
@@ -34,6 +34,9 @@ public class WarningEntry implements Serializable {
protected static final long serialVersionUID = 1L;
+ @BsonProperty(value = "guild_id")
+ private String guildID;
+
@BsonProperty(value = "incident_id")
private String incidentID;
@@ -59,8 +62,9 @@ public WarningEntry() {
}
- public WarningEntry(String incidentID, String userTag, String userID, String staffTag,
- String staffID, String reason, Date timestamp) {
+ public WarningEntry(String guildID, String incidentID, String userTag, String userID, String staffTag, String staffID, String reason,
+ Date timestamp) {
+ this.guildID = guildID;
this.incidentID = incidentID;
this.userTag = userTag;
this.userID = userID;
@@ -70,6 +74,10 @@ public WarningEntry(String incidentID, String userTag, String userID, String sta
this.timestamp = timestamp;
}
+ public String getGuildID() {
+ return guildID;
+ }
+
public String getIncidentID() {
return incidentID;
}
@@ -98,6 +106,11 @@ public Date getTimestamp() {
return timestamp;
}
+ public WarningEntry setGuildID(String guildID) {
+ this.guildID = guildID;
+ return this;
+ }
+
public WarningEntry setIncidentID(String incidentID) {
this.incidentID = incidentID;
return this;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/enums/EmbedColour.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/enums/EmbedColour.java
similarity index 97%
rename from src/main/java/io/paradaux/friendlybot/utils/models/enums/EmbedColour.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/enums/EmbedColour.java
index c4506d70..99aa2fd8 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/enums/EmbedColour.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/enums/EmbedColour.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.enums;
+package io.paradaux.friendlybot.core.utils.models.enums;
import javax.annotation.Nullable;
diff --git a/src/main/java/io/paradaux/friendlybot/core/utils/models/enums/TicketStatus.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/enums/TicketStatus.java
new file mode 100644
index 00000000..83de3e8a
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/enums/TicketStatus.java
@@ -0,0 +1,5 @@
+package io.paradaux.friendlybot.core.utils.models.enums;
+
+public enum TicketStatus {
+ OPEN, CLOSED
+}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/exceptions/ManagerNotReadyException.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/ManagerNotReadyException.java
similarity index 96%
rename from src/main/java/io/paradaux/friendlybot/utils/models/exceptions/ManagerNotReadyException.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/ManagerNotReadyException.java
index f80a0bc3..5697faec 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/exceptions/ManagerNotReadyException.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/ManagerNotReadyException.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.exceptions;
+package io.paradaux.friendlybot.core.utils.models.exceptions;
public class ManagerNotReadyException extends RuntimeException {
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/exceptions/NoSuchResourceException.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/NoSuchResourceException.java
similarity index 96%
rename from src/main/java/io/paradaux/friendlybot/utils/models/exceptions/NoSuchResourceException.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/NoSuchResourceException.java
index 479d47d7..c50b9c5c 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/exceptions/NoSuchResourceException.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/NoSuchResourceException.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.exceptions;
+package io.paradaux.friendlybot.core.utils.models.exceptions;
public class NoSuchResourceException extends RuntimeException {
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/exceptions/NoSuchUserException.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/NoSuchUserException.java
similarity index 96%
rename from src/main/java/io/paradaux/friendlybot/utils/models/exceptions/NoSuchUserException.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/NoSuchUserException.java
index 0d23d0fa..c713554e 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/exceptions/NoSuchUserException.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/NoSuchUserException.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.exceptions;
+package io.paradaux.friendlybot.core.utils.models.exceptions;
public class NoSuchUserException extends RuntimeException {
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/exceptions/VerificationException.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/VerificationException.java
similarity index 96%
rename from src/main/java/io/paradaux/friendlybot/utils/models/exceptions/VerificationException.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/VerificationException.java
index 97e78005..6eec8ee9 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/exceptions/VerificationException.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/exceptions/VerificationException.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.exceptions;
+package io.paradaux.friendlybot.core.utils.models.exceptions;
public class VerificationException extends RuntimeException {
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/interfaces/Embed.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/interfaces/Embed.java
similarity index 95%
rename from src/main/java/io/paradaux/friendlybot/utils/models/interfaces/Embed.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/interfaces/Embed.java
index 7c68ee79..9468e9d0 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/interfaces/Embed.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/interfaces/Embed.java
@@ -23,7 +23,7 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.interfaces;
+package io.paradaux.friendlybot.core.utils.models.interfaces;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/types/BaseCommand.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/types/BaseCommand.java
similarity index 94%
rename from src/main/java/io/paradaux/friendlybot/utils/models/types/BaseCommand.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/types/BaseCommand.java
index 301213df..d707b9db 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/types/BaseCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/types/BaseCommand.java
@@ -23,13 +23,13 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.types;
+package io.paradaux.friendlybot.core.utils.models.types;
import com.jagrosh.jdautilities.command.Command;
+import io.paradaux.friendlybot.core.utils.embeds.notices.SyntaxErrorEmbed;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.NoSuchUserException;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.embeds.notices.SyntaxErrorEmbed;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.NoSuchUserException;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
@@ -95,7 +95,7 @@ public String parseSentance(int startElement, String[] args) {
* Responds with a canned syntax error embed.
* */
public void respondSyntaxError(Message message, String correctSyntax) {
- message.addReaction("\uD83D\uDEAB").queue();
+ message.addReaction("🚫").queue();
new SyntaxErrorEmbed(message.getAuthor(), this.name, correctSyntax)
.sendEmbed(message.getTextChannel());
}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/types/DiscordEventListener.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/types/DiscordEventListener.java
similarity index 92%
rename from src/main/java/io/paradaux/friendlybot/utils/models/types/DiscordEventListener.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/types/DiscordEventListener.java
index 89a27be2..f3726c9c 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/types/DiscordEventListener.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/types/DiscordEventListener.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.types;
+package io.paradaux.friendlybot.core.utils.models.types;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.slf4j.Logger;
diff --git a/src/main/java/io/paradaux/friendlybot/core/utils/models/types/ModerationAction.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/types/ModerationAction.java
new file mode 100644
index 00000000..5cae4014
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/types/ModerationAction.java
@@ -0,0 +1,7 @@
+package io.paradaux.friendlybot.core.utils.models.types;
+
+public enum ModerationAction {
+
+ WARN, KICK, BAN, TEMP_BAN, RESCINDMENT
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/types/PrivilegedCommand.java b/src/main/java/io/paradaux/friendlybot/core/utils/models/types/PrivilegedCommand.java
similarity index 76%
rename from src/main/java/io/paradaux/friendlybot/utils/models/types/PrivilegedCommand.java
rename to src/main/java/io/paradaux/friendlybot/core/utils/models/types/PrivilegedCommand.java
index e1e697d9..a6e3b83b 100644
--- a/src/main/java/io/paradaux/friendlybot/utils/models/types/PrivilegedCommand.java
+++ b/src/main/java/io/paradaux/friendlybot/core/utils/models/types/PrivilegedCommand.java
@@ -23,11 +23,14 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models.types;
+package io.paradaux.friendlybot.core.utils.models.types;
+import io.paradaux.friendlybot.core.utils.embeds.notices.NoPermissionEmbed;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
import io.paradaux.friendlybot.managers.PermissionManager;
-import io.paradaux.friendlybot.utils.embeds.notices.NoPermissionEmbed;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
+import net.dv8tion.jda.api.Permission;
+import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import org.slf4j.Logger;
@@ -52,7 +55,7 @@ public PrivilegedCommand(Logger logger, PermissionManager permissionManager) {
/**
* Returns true if the provided user is a member of staff.
* */
- public boolean isStaff(String discordID) {
+ public boolean isStaff(Guild guild, String discordID) {
PermissionManager permissionManager = getPermissionManager();
if (permissionManager == null) {
@@ -61,14 +64,25 @@ public boolean isStaff(String discordID) {
return getPermissionManager().isAdmin(discordID)
|| permissionManager.isMod(discordID)
- || permissionManager.isTechnician(discordID);
+ || permissionManager.isTechnician(discordID)
+ || isAdmin(guild, discordID);
+ }
+
+ public boolean isAdmin(Guild guild, String discordId) {
+ Member member = retrieveMember(guild, discordId);
+
+ if (member == null) {
+ return false;
+ }
+
+ return member.getPermissions().contains(Permission.ADMINISTRATOR);
}
/**
* Fills in the canned no permission embed.
* */
public void respondNoPermission(Message message, String requiredRole) {
- message.addReaction("\uD83D\uDEAB").queue();
+ message.addReaction("🚫").queue();
new NoPermissionEmbed(message.getAuthor(), this.name, requiredRole)
.sendEmbed(message.getTextChannel());
}
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/AlotListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/AlotListener.java
similarity index 88%
rename from src/main/java/io/paradaux/friendlybot/listeners/AlotListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/AlotListener.java
index 090feb16..fec811dd 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/AlotListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/AlotListener.java
@@ -1,7 +1,7 @@
-package io.paradaux.friendlybot.listeners;
+package io.paradaux.friendlybot.discord.listeners;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.api.entities.Message;
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/DotCommandsListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/DotCommandsListener.java
similarity index 90%
rename from src/main/java/io/paradaux/friendlybot/listeners/DotCommandsListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/DotCommandsListener.java
index 7abfe8cc..512c082f 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/DotCommandsListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/DotCommandsListener.java
@@ -1,4 +1,4 @@
-package io.paradaux.friendlybot.listeners;
+package io.paradaux.friendlybot.discord.listeners;
/*
* MIT License
@@ -25,10 +25,10 @@
* SOFTWARE.
*/
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.TagEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.TagManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.TagEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/InsultListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/InsultListener.java
similarity index 89%
rename from src/main/java/io/paradaux/friendlybot/listeners/InsultListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/InsultListener.java
index c63961a8..5864ed40 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/InsultListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/InsultListener.java
@@ -1,7 +1,7 @@
-package io.paradaux.friendlybot.listeners;
+package io.paradaux.friendlybot.discord.listeners;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message;
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/ReadyListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/ReadyListener.java
similarity index 94%
rename from src/main/java/io/paradaux/friendlybot/listeners/ReadyListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/ReadyListener.java
index 72a5d0c9..b2f5f341 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/ReadyListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/ReadyListener.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners;
+package io.paradaux.friendlybot.discord.listeners;
import io.paradaux.friendlybot.FriendlyBot;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.events.ReadyEvent;
import org.slf4j.Logger;
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/TagListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/TagListener.java
similarity index 90%
rename from src/main/java/io/paradaux/friendlybot/listeners/TagListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/TagListener.java
index 6f8bc16b..57f2dab3 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/TagListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/TagListener.java
@@ -23,12 +23,12 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners;
+package io.paradaux.friendlybot.discord.listeners;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.TagEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.TagManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.TagEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message;
@@ -37,8 +37,6 @@
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
-import java.util.Arrays;
-
public class TagListener extends DiscordEventListener {
private static final String TAG_PREFIX = "!";
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/VotePinListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/VotePinListener.java
similarity index 86%
rename from src/main/java/io/paradaux/friendlybot/listeners/VotePinListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/VotePinListener.java
index d9591fc4..ffd53431 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/VotePinListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/VotePinListener.java
@@ -1,6 +1,6 @@
-package io.paradaux.friendlybot.listeners;
+package io.paradaux.friendlybot.discord.listeners;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.entities.MessageReaction;
import net.dv8tion.jda.api.events.message.guild.react.GuildMessageReactionAddEvent;
import org.jetbrains.annotations.NotNull;
@@ -9,7 +9,7 @@
public class VotePinListener extends DiscordEventListener {
private static final int PIN_THRESHOLD = 4;
- private static final String PIN_EMOJI = "\uD83D\uDCCC";
+ private static final String PIN_EMOJI = "📌";
private final Logger logger;
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/logging/MessageDeleteLog.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/MessageDeleteLog.java
similarity index 78%
rename from src/main/java/io/paradaux/friendlybot/listeners/logging/MessageDeleteLog.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/logging/MessageDeleteLog.java
index 2e11d1e0..e8876157 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/logging/MessageDeleteLog.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/MessageDeleteLog.java
@@ -23,13 +23,15 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners.logging;
+package io.paradaux.friendlybot.discord.listeners.logging;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.GuildSettingsEntry;
+import io.paradaux.friendlybot.core.utils.models.database.MessageEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.DiscordBotManager;
+import io.paradaux.friendlybot.managers.GuildSettingsManager;
import io.paradaux.friendlybot.managers.MongoManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.MessageEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
@@ -40,16 +42,24 @@
public class MessageDeleteLog extends DiscordEventListener {
private final MongoManager mongo;
+ private final GuildSettingsManager guilds;
- public MessageDeleteLog(ConfigurationEntry config, Logger logger, MongoManager mongo) {
+ public MessageDeleteLog(ConfigurationEntry config, Logger logger, MongoManager mongo, GuildSettingsManager guilds) {
super(config, logger);
this.mongo = mongo;
+ this.guilds = guilds;
}
@Override
public void onGuildMessageDelete(@NotNull GuildMessageDeleteEvent event) {
- TextChannel messageLogChannel = DiscordBotManager.getInstance().getChannel(getConfig().getMessageLogChannel());
+ GuildSettingsEntry guild = guilds.getGuild(event.getGuild().getId());
+
+ if (guild.getMessageLogChannel() == null || guild.getMessageLogChannel().isEmpty()) {
+ return;
+ }
+
+ TextChannel messageLogChannel = DiscordBotManager.getInstance().getChannel(guild.getMessageLogChannel());
MessageEntry entry = mongo.getLoggedMessage(event.getMessageId());
if (entry == null) {
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/logging/MessageLog.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/MessageLog.java
similarity index 75%
rename from src/main/java/io/paradaux/friendlybot/listeners/logging/MessageLog.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/logging/MessageLog.java
index 0432ed1c..0ad46b68 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/logging/MessageLog.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/MessageLog.java
@@ -23,13 +23,15 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners.logging;
+package io.paradaux.friendlybot.discord.listeners.logging;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.GuildSettingsEntry;
+import io.paradaux.friendlybot.core.utils.models.database.MessageEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.DiscordBotManager;
+import io.paradaux.friendlybot.managers.GuildSettingsManager;
import io.paradaux.friendlybot.managers.MongoManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.MessageEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@@ -41,10 +43,12 @@
public class MessageLog extends DiscordEventListener {
private final MongoManager mongo;
+ private final GuildSettingsManager guilds;
- public MessageLog(ConfigurationEntry config, Logger logger, MongoManager mongo) {
+ public MessageLog(ConfigurationEntry config, Logger logger, MongoManager mongo, GuildSettingsManager guilds) {
super(config, logger);
this.mongo = mongo;
+ this.guilds = guilds;
}
@Override
@@ -53,8 +57,17 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
return;
}
- TextChannel messageLogChannel = DiscordBotManager.getInstance().getChannel(getConfig().getMessageLogChannel());
+ if (event.getMessage().getContentRaw().startsWith(";")) {
+ return;
+ }
+
+ GuildSettingsEntry guild = guilds.getGuild(event.getGuild().getId());
+
+ if (guild.getMessageLogChannel() == null || guild.getMessageLogChannel().isEmpty()) {
+ return;
+ }
+ TextChannel messageLogChannel = DiscordBotManager.getInstance().getChannel(guild.getMessageLogChannel());
MessageEntry entry = new MessageEntry()
.setAuthorId(event.getAuthor().getId())
.setMessageId(event.getMessageId())
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/logging/UpdatedMessageLog.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/UpdatedMessageLog.java
similarity index 78%
rename from src/main/java/io/paradaux/friendlybot/listeners/logging/UpdatedMessageLog.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/logging/UpdatedMessageLog.java
index 86888618..5b26b660 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/logging/UpdatedMessageLog.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/UpdatedMessageLog.java
@@ -23,13 +23,15 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners.logging;
+package io.paradaux.friendlybot.discord.listeners.logging;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.GuildSettingsEntry;
+import io.paradaux.friendlybot.core.utils.models.database.MessageEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.DiscordBotManager;
+import io.paradaux.friendlybot.managers.GuildSettingsManager;
import io.paradaux.friendlybot.managers.MongoManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.MessageEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
@@ -40,10 +42,12 @@
public class UpdatedMessageLog extends DiscordEventListener {
private final MongoManager mongo;
+ private final GuildSettingsManager guilds;
- public UpdatedMessageLog(ConfigurationEntry config, Logger logger, MongoManager mongo) {
+ public UpdatedMessageLog(ConfigurationEntry config, Logger logger, MongoManager mongo, GuildSettingsManager guilds) {
super(config, logger);
this.mongo = mongo;
+ this.guilds = guilds;
}
@Override
@@ -52,7 +56,13 @@ public void onGuildMessageUpdate(@NotNull GuildMessageUpdateEvent event) {
return;
}
- TextChannel messageLogChannel = DiscordBotManager.getInstance().getChannel(getConfig().getMessageLogChannel());
+ GuildSettingsEntry guild = guilds.getGuild(event.getGuild().getId());
+
+ if (guild.getMessageLogChannel() == null || guild.getMessageLogChannel().isEmpty()) {
+ return;
+ }
+
+ TextChannel messageLogChannel = DiscordBotManager.getInstance().getChannel(guild.getMessageLogChannel());
MessageEntry entry = mongo.getLoggedMessage(event.getMessageId());
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/logging/audit/GuildJoinLog.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/audit/GuildJoinLog.java
similarity index 70%
rename from src/main/java/io/paradaux/friendlybot/listeners/logging/audit/GuildJoinLog.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/logging/audit/GuildJoinLog.java
index 2427b8b4..ec3826e4 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/logging/audit/GuildJoinLog.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/audit/GuildJoinLog.java
@@ -23,11 +23,13 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners.logging.audit;
+package io.paradaux.friendlybot.discord.listeners.logging.audit;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.GuildSettingsEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.DiscordBotManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
+import io.paradaux.friendlybot.managers.GuildSettingsManager;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
import org.jetbrains.annotations.NotNull;
@@ -35,19 +37,27 @@
public class GuildJoinLog extends DiscordEventListener {
- public GuildJoinLog(ConfigurationEntry config, Logger logger) {
+ private final GuildSettingsManager guilds;
+ public GuildJoinLog(ConfigurationEntry config, Logger logger, GuildSettingsManager guilds) {
super(config, logger);
+ this.guilds = guilds;
}
@Override
public void onGuildMemberJoin(@NotNull GuildMemberJoinEvent event) {
+ GuildSettingsEntry guild = guilds.getGuild(event.getGuild().getId());
+
+ if (guild.getPublicAuditLogChannel() == null || guild.getPublicAuditLogChannel().isEmpty()) {
+ return;
+ }
+
var user = event.getUser();
var embed = new EmbedBuilder()
.setTitle(user.getAsTag() + " has joined the guild.")
.setColor(0x00cc99)
.build();
- DiscordBotManager.getInstance().getChannel(getConfig().getPublicAuditLogChannelId()).sendMessage(embed).queue();
+ DiscordBotManager.getInstance().getChannel(guild.getPublicAuditLogChannel()).sendMessage(embed).queue();
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/logging/audit/GuildLeaveLog.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/audit/GuildLeaveLog.java
similarity index 70%
rename from src/main/java/io/paradaux/friendlybot/listeners/logging/audit/GuildLeaveLog.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/logging/audit/GuildLeaveLog.java
index 9a7030ff..a85ff81b 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/logging/audit/GuildLeaveLog.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/logging/audit/GuildLeaveLog.java
@@ -23,11 +23,13 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners.logging.audit;
+package io.paradaux.friendlybot.discord.listeners.logging.audit;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.GuildSettingsEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.DiscordBotManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
+import io.paradaux.friendlybot.managers.GuildSettingsManager;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
import org.jetbrains.annotations.NotNull;
@@ -35,20 +37,28 @@
public class GuildLeaveLog extends DiscordEventListener {
- public GuildLeaveLog(ConfigurationEntry config, Logger logger) {
+ private final GuildSettingsManager guilds;
+ public GuildLeaveLog(ConfigurationEntry config, Logger logger, GuildSettingsManager guilds) {
super(config, logger);
+ this.guilds = guilds;
}
@Override
public void onGuildMemberRemove(@NotNull GuildMemberRemoveEvent event) {
+ GuildSettingsEntry guild = guilds.getGuild(event.getGuild().getId());
+
+ if (guild.getPublicAuditLogChannel() == null || guild.getPublicAuditLogChannel().isEmpty()) {
+ return;
+ }
+
var user = event.getUser();
var embed = new EmbedBuilder()
.setTitle(user.getAsTag() + " has left the guild.")
.setColor(0xff5050)
.build();
- DiscordBotManager.getInstance().getChannel(getConfig().getPublicAuditLogChannelId()).sendMessage(embed).queue();
+ DiscordBotManager.getInstance().getChannel(guild.getPublicAuditLogChannel()).sendMessage(embed).queue();
}
}
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/modmail/ModMailChannelListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/modmail/ModMailChannelListener.java
similarity index 72%
rename from src/main/java/io/paradaux/friendlybot/listeners/modmail/ModMailChannelListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/modmail/ModMailChannelListener.java
index 1d893046..0f1aa4af 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/modmail/ModMailChannelListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/modmail/ModMailChannelListener.java
@@ -23,18 +23,19 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners.modmail;
-
+package io.paradaux.friendlybot.discord.listeners.modmail;
+
+import io.paradaux.friendlybot.core.utils.embeds.modmail.ModMailReceivedEmbed;
+import io.paradaux.friendlybot.core.utils.embeds.modmail.ModMailSentEmbed;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.GuildSettingsEntry;
+import io.paradaux.friendlybot.core.utils.models.database.ModMailEntry;
+import io.paradaux.friendlybot.core.utils.models.enums.TicketStatus;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.DiscordBotManager;
+import io.paradaux.friendlybot.managers.GuildSettingsManager;
import io.paradaux.friendlybot.managers.MongoManager;
-import io.paradaux.friendlybot.utils.embeds.modmail.ModMailReceivedEmbed;
-import io.paradaux.friendlybot.utils.embeds.modmail.ModMailSentEmbed;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.ModMailEntry;
-import io.paradaux.friendlybot.utils.models.enums.TicketStatus;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
-import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import org.jetbrains.annotations.NotNull;
@@ -55,11 +56,13 @@ public ModMailChannelListener(ConfigurationEntry config, Logger logger) {
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
Message message = event.getMessage();
- if (message.getChannelType() == ChannelType.PRIVATE) {
+ GuildSettingsEntry guild = GuildSettingsManager.getInstance().getGuild(event.getGuild().getId());
+
+ if (guild.getMessageLogChannel() == null || guild.getMessageLogChannel().isEmpty()) {
return;
}
- if (!message.getChannel().getId().equals(getConfig().getModMailInputChannel())) {
+ if (!message.getChannel().getId().equals(guild.getModmailInputChannel())) {
return;
}
@@ -68,8 +71,8 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
String userId = event.getAuthor().getId();
String userTag = event.getAuthor().getAsTag();
String issue = message.getContentRaw();
- String ticketNumber = mongo.getNextTicketNumber();
- String incidentID = mongo.getNextIncidentID();
+ String ticketNumber = String.valueOf(guild.getTicketId());
+ String incidentID = String.valueOf(guild.getIncidentId());
ModMailEntry entry = new ModMailEntry()
.setIssue(issue)
@@ -85,13 +88,11 @@ public void onMessageReceived(@NotNull MessageReceivedEvent event) {
issue, ticketNumber, incidentID);
ModMailSentEmbed sentEmbed = new ModMailSentEmbed(ticketNumber, issue);
- receivedEmbed.sendEmbed(DiscordBotManager.getInstance().getChannel(getConfig().getModMailOutputChannel()));
+ receivedEmbed.sendEmbed(DiscordBotManager.getInstance().getChannel(guild.getModmailOutputChannel()));
event.getAuthor().openPrivateChannel().queue((privateChannel) -> privateChannel
.sendMessage(sentEmbed.getEmbed()).queue());
mongo.addModMailEntry(entry);
-
- // TODO tidy
}
diff --git a/src/main/java/io/paradaux/friendlybot/discord/listeners/rooms/RoomJoinListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/rooms/RoomJoinListener.java
new file mode 100644
index 00000000..72b94800
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/rooms/RoomJoinListener.java
@@ -0,0 +1,42 @@
+package io.paradaux.friendlybot.discord.listeners.rooms;
+
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
+import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.VoiceChannel;
+import net.dv8tion.jda.api.events.guild.voice.GuildVoiceJoinEvent;
+import org.slf4j.Logger;
+
+public class RoomJoinListener extends DiscordEventListener {
+
+ public RoomJoinListener(ConfigurationEntry config, Logger logger) {
+ super(config, logger);
+ }
+
+ public void onGuildVoiceJoinEvent(GuildVoiceJoinEvent event) {
+ if (!event.getChannelJoined().getName().startsWith("Room")) {
+ return;
+ }
+
+ if (event.getChannelJoined().getMembers().size() == 1) {
+ Guild guild = event.getGuild();
+ guild.createVoiceChannel("Room " + getLastRoomNumber(guild), event.getChannelJoined().getParent()).queue();
+ // Create a new room
+ }
+
+ }
+
+ public int getLastRoomNumber(Guild guild) {
+ int i = 0;
+ int lastFound = 0;
+ for (VoiceChannel channel : guild.getVoiceChannels()) {
+ if (channel.getName().contains("Room " + i)) {
+ lastFound = i;
+ }
+ i++;
+ }
+
+ return lastFound;
+ }
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/discord/listeners/rooms/RoomLeaveListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/rooms/RoomLeaveListener.java
new file mode 100644
index 00000000..6eb03ed4
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/rooms/RoomLeaveListener.java
@@ -0,0 +1,25 @@
+package io.paradaux.friendlybot.discord.listeners.rooms;
+
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
+import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
+import org.slf4j.Logger;
+
+public class RoomLeaveListener extends DiscordEventListener {
+
+ public RoomLeaveListener(ConfigurationEntry config, Logger logger) {
+ super(config, logger);
+ }
+
+ public void onGuildVoiceLeaveEvent(GuildVoiceLeaveEvent event) {
+ if (!event.getChannelLeft().getName().startsWith("Room")) {
+ return;
+ }
+
+ if (event.getChannelLeft().getMembers().size() == 0 && !event.getChannelLeft().getName().equals("Room 1")) {
+ // Delete the room
+ }
+
+ }
+
+}
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/utility/LongMessageListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/utility/LongMessageListener.java
similarity index 95%
rename from src/main/java/io/paradaux/friendlybot/listeners/utility/LongMessageListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/utility/LongMessageListener.java
index 77dc4a79..2083c28d 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/utility/LongMessageListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/utility/LongMessageListener.java
@@ -23,10 +23,10 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners.utility;
+package io.paradaux.friendlybot.discord.listeners.utility;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/verification/VerificationCodeReceivedListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/verification/VerificationCodeReceivedListener.java
similarity index 93%
rename from src/main/java/io/paradaux/friendlybot/listeners/verification/VerificationCodeReceivedListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/verification/VerificationCodeReceivedListener.java
index db2d1365..e34ff0a7 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/verification/VerificationCodeReceivedListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/verification/VerificationCodeReceivedListener.java
@@ -23,14 +23,14 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners.verification;
+package io.paradaux.friendlybot.discord.listeners.verification;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.VerificationException;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.DiscordBotManager;
import io.paradaux.friendlybot.managers.MongoManager;
import io.paradaux.friendlybot.managers.VerificationManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.VerificationException;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message;
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/verification/VerificationEmailReceivedListener.java b/src/main/java/io/paradaux/friendlybot/discord/listeners/verification/VerificationEmailReceivedListener.java
similarity index 94%
rename from src/main/java/io/paradaux/friendlybot/listeners/verification/VerificationEmailReceivedListener.java
rename to src/main/java/io/paradaux/friendlybot/discord/listeners/verification/VerificationEmailReceivedListener.java
index ff8de13e..f86221a2 100644
--- a/src/main/java/io/paradaux/friendlybot/listeners/verification/VerificationEmailReceivedListener.java
+++ b/src/main/java/io/paradaux/friendlybot/discord/listeners/verification/VerificationEmailReceivedListener.java
@@ -23,15 +23,15 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.listeners.verification;
+package io.paradaux.friendlybot.discord.listeners.verification;
+import io.paradaux.friendlybot.core.utils.StringUtils;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.VerificationException;
+import io.paradaux.friendlybot.core.utils.models.types.DiscordEventListener;
import io.paradaux.friendlybot.managers.DiscordBotManager;
import io.paradaux.friendlybot.managers.MongoManager;
import io.paradaux.friendlybot.managers.VerificationManager;
-import io.paradaux.friendlybot.utils.StringUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.VerificationException;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message;
diff --git a/src/main/java/io/paradaux/friendlybot/listeners/modmail/ModMailPrivateMessageListener.java b/src/main/java/io/paradaux/friendlybot/listeners/modmail/ModMailPrivateMessageListener.java
deleted file mode 100644
index 0e55fd43..00000000
--- a/src/main/java/io/paradaux/friendlybot/listeners/modmail/ModMailPrivateMessageListener.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.listeners.modmail.ModMailPrivateMessageListener : 31/01/2021, 01:26
- *
- * 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 io.paradaux.friendlybot.listeners.modmail;
-
-import io.paradaux.friendlybot.FriendlyBot;
-import io.paradaux.friendlybot.utils.models.types.DiscordEventListener;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
-import org.jetbrains.annotations.NotNull;
-import org.slf4j.Logger;
-
-/**
- * PrivateMessageReceivedListener listens to the VerificationCodes sent to the bot privately,
- * parses them and sets the user as verified if approrpriate.
- *
- * @author RÃan Errity
- * @version Last Modified for 0.1.0-SNAPSHOT
- * @since 1/11/2020 DD/MM/YY
- * @see FriendlyBot
- * */
-
-
-public class ModMailPrivateMessageListener extends DiscordEventListener {
-
- public ModMailPrivateMessageListener(Logger logger) {
- super(logger);
- }
-
- @Override
- public void onPrivateMessageReceived(@NotNull PrivateMessageReceivedEvent event) {
- Message message = event.getMessage();
- // TODO implement
- }
-
-}
diff --git a/src/main/java/io/paradaux/friendlybot/managers/AuditManager.java b/src/main/java/io/paradaux/friendlybot/managers/AuditManager.java
index 043a6680..af13efb6 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/AuditManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/AuditManager.java
@@ -25,11 +25,11 @@
package io.paradaux.friendlybot.managers;
-import io.paradaux.friendlybot.utils.embeds.AuditLogEmbed;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.AuditLogEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
-import io.paradaux.friendlybot.utils.models.types.ModerationAction;
+import io.paradaux.friendlybot.core.utils.embeds.AuditLogEmbed;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.AuditLogEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.models.types.ModerationAction;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
import org.slf4j.Logger;
@@ -38,8 +38,6 @@
public class AuditManager {
- // TODO tidy
-
private static AuditManager instance = null;
private final ConfigurationEntry config;
private final Logger logger;
diff --git a/src/main/java/io/paradaux/friendlybot/managers/ConfigManager.java b/src/main/java/io/paradaux/friendlybot/managers/ConfigManager.java
index bab50d40..b370c6b4 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/ConfigManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/ConfigManager.java
@@ -25,8 +25,8 @@
package io.paradaux.friendlybot.managers;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
import org.slf4j.Logger;
import java.io.FileNotFoundException;
diff --git a/src/main/java/io/paradaux/friendlybot/managers/DiscordBotManager.java b/src/main/java/io/paradaux/friendlybot/managers/DiscordBotManager.java
index 636a4b4b..9c2b5c07 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/DiscordBotManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/DiscordBotManager.java
@@ -25,29 +25,25 @@
package io.paradaux.friendlybot.managers;
-import com.jagrosh.jdautilities.command.CommandClient;
-import com.jagrosh.jdautilities.command.CommandClientBuilder;
import com.jagrosh.jdautilities.commons.waiter.EventWaiter;
-import io.paradaux.friendlybot.commands.fun.*;
-import io.paradaux.friendlybot.commands.staff.moderation.*;
-import io.paradaux.friendlybot.commands.staff.technician.*;
-import io.paradaux.friendlybot.commands.utility.*;
-import io.paradaux.friendlybot.listeners.*;
-import io.paradaux.friendlybot.listeners.logging.MessageDeleteLog;
-import io.paradaux.friendlybot.listeners.logging.MessageLog;
-import io.paradaux.friendlybot.listeners.logging.UpdatedMessageLog;
-import io.paradaux.friendlybot.listeners.logging.audit.GuildJoinLog;
-import io.paradaux.friendlybot.listeners.logging.audit.GuildLeaveLog;
-import io.paradaux.friendlybot.listeners.modmail.ModMailChannelListener;
-import io.paradaux.friendlybot.listeners.modmail.ModMailPrivateMessageListener;
-import io.paradaux.friendlybot.listeners.utility.LongMessageListener;
-import io.paradaux.friendlybot.listeners.verification.VerificationCodeReceivedListener;
-import io.paradaux.friendlybot.listeners.verification.VerificationEmailReceivedListener;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.discord.listeners.*;
+import io.paradaux.friendlybot.discord.listeners.logging.MessageDeleteLog;
+import io.paradaux.friendlybot.discord.listeners.logging.MessageLog;
+import io.paradaux.friendlybot.discord.listeners.logging.UpdatedMessageLog;
+import io.paradaux.friendlybot.discord.listeners.logging.audit.GuildJoinLog;
+import io.paradaux.friendlybot.discord.listeners.logging.audit.GuildLeaveLog;
+import io.paradaux.friendlybot.discord.listeners.modmail.ModMailChannelListener;
+import io.paradaux.friendlybot.discord.listeners.utility.LongMessageListener;
+import io.paradaux.friendlybot.discord.listeners.verification.VerificationCodeReceivedListener;
+import io.paradaux.friendlybot.discord.listeners.verification.VerificationEmailReceivedListener;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
-import net.dv8tion.jda.api.entities.*;
+import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.Role;
+import net.dv8tion.jda.api.entities.TextChannel;
+import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.requests.GatewayIntent;
import net.dv8tion.jda.api.utils.MemberCachePolicy;
import org.slf4j.Logger;
@@ -62,6 +58,7 @@ public class DiscordBotManager {
// Singleton Instance
private static DiscordBotManager instance = null;
+
private final ConfigurationEntry config;
private final Logger logger;
private final PermissionManager permissionManager;
@@ -69,14 +66,17 @@ public class DiscordBotManager {
private final JDA client;
private final EventWaiter eventWaiter;
private final RoleManager roles;
+ private final GuildSettingsManager guilds;
- public DiscordBotManager(ConfigurationEntry config, Logger logger, PermissionManager permissionManager, MongoManager mongo, RoleManager roles) {
+ public DiscordBotManager(ConfigurationEntry config, Logger logger, PermissionManager permissionManager, MongoManager mongo,
+ RoleManager roles, GuildSettingsManager guilds) {
this.config = config;
this.logger = logger;
this.permissionManager = permissionManager;
this.mongo = mongo;
this.eventWaiter = new EventWaiter();
this.roles = roles;
+ this.guilds = guilds;
logger.info("Initialising: Discord Bot Manager");
logger.info("Attempting to login");
@@ -100,70 +100,6 @@ public static DiscordBotManager getInstance() {
return instance;
}
- private CommandClient createCommandClient() {
- logger.info("Initialising: CommandController");
-
- CommandClientBuilder builder = new CommandClientBuilder()
- .setPrefix(config.getCommandPrefix())
- .setOwnerId("150993042558418944")
- .setActivity(Activity.listening("modmail queries.."))
- .addCommands(
- // Fun Commands
- new CatCommand(config, logger),
- new CoinFlipCommand(config, logger),
- new DogCommand(config, logger),
- new EightBallCommand(config, logger),
- new InspireCommand(config, logger),
- new LmgtfyCommand(config, logger),
- new MemeCommand(config, logger),
- new MonkeCommand(config, logger),
- new MonkeyCommand(config, logger),
- new XKCDCommand(config, logger),
- new YodaifyCommand(config, logger),
-
- // Moderation Commands
- new AnnouncementCommand(config, logger, permissionManager, eventWaiter),
- new BanCommand(config, logger, permissionManager),
- new CiteCommand(config, logger, permissionManager),
- new KickCommand(config, logger, permissionManager),
- new LookupCommand(config, logger, permissionManager),
- new PruneCommand(config, logger, permissionManager),
- new PunishmentCommand(config, logger, permissionManager, mongo),
- new RespondCommand(config, logger, permissionManager, mongo),
- new TempBanCommand(config, logger, permissionManager, mongo),
- new TicketCommand(config, logger, permissionManager),
- new TimeOutCommand(config, logger, permissionManager),
- new WarnCommand(config, logger, permissionManager),
-
- // Technician Commands.
- new DmCommand(config, logger, permissionManager),
- new PermissionsCommand(config, logger, permissionManager),
- new SayCommand(config, logger, permissionManager),
- new SendEmbedCommand(config, logger, permissionManager),
- new VerificationCommand(config, logger, permissionManager),
-
- // Utility Commands
- new ClearColorCommand(config, logger),
- new CommandsCommand(config, logger),
- new GithubCommand(config, logger),
- new GoogleCommand(config, logger),
- new InviteCommand(logger),
- new MemeImagesCommand(config, logger),
- new PingCommand(logger),
- new RandomColorCommand(config, logger),
- new ServerInfoCommand(config, logger),
- new SetColorCommand(config, logger, roles),
- new StrikeCommand(config, logger),
- new TagCommand(config, logger, mongo),
- new TagsCommand(logger),
- new UserInfoCommand(config, logger, permissionManager),
- new WeatherCommand(config, logger),
- new WolframAlphaCommand(config, logger)
- );
-
- return builder.build();
- }
-
/**
* Creates an Instance of JDA from the provided token.
* @param token The Discord Token taken from the configuration file.
@@ -172,26 +108,25 @@ private CommandClient createCommandClient() {
* */
public JDA login(String token) throws LoginException {
- CommandClient commandClient = createCommandClient();
+
JDABuilder builder = JDABuilder.createDefault(token, GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_MESSAGE_REACTIONS)
.setMemberCachePolicy(MemberCachePolicy.ALL)
.enableIntents(GatewayIntent.GUILD_MEMBERS)
.setBulkDeleteSplittingEnabled(false)
- .addEventListeners(eventWaiter, commandClient,
+ .addEventListeners(eventWaiter,
new AlotListener(config, logger),
new DotCommandsListener(config, logger),
new InsultListener(config, logger),
- new GuildJoinLog(config, logger),
- new GuildLeaveLog(config, logger),
+ new GuildJoinLog(config, logger, guilds),
+ new GuildLeaveLog(config, logger, guilds),
new ModMailChannelListener(config, logger),
- new ModMailPrivateMessageListener(logger),
new VerificationCodeReceivedListener(config, logger),
new VerificationEmailReceivedListener(config, logger),
new ReadyListener(logger),
- new MessageDeleteLog(config, logger, mongo),
- new MessageLog(config, logger, mongo),
- new UpdatedMessageLog(config, logger, mongo),
+ new MessageDeleteLog(config, logger, mongo, guilds),
+ new MessageLog(config, logger, mongo, guilds),
+ new UpdatedMessageLog(config, logger, mongo, guilds),
new LongMessageListener(config, logger),
new TagListener(config, logger),
new VotePinListener(logger)
@@ -253,8 +188,6 @@ public List getRolesByName(String guildId, String roleName) {
return getGuild(guildId).getRolesByName(roleName, true);
}
-
-
@Nonnull
@CheckReturnValue
public User getUser(String userId) {
diff --git a/src/main/java/io/paradaux/friendlybot/managers/GuildManager.java b/src/main/java/io/paradaux/friendlybot/managers/GuildManager.java
index b8f4dca7..94e5f844 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/GuildManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/GuildManager.java
@@ -1,6 +1,6 @@
package io.paradaux.friendlybot.managers;
-import io.paradaux.friendlybot.utils.models.database.GuildSettingsEntry;
+import io.paradaux.friendlybot.core.utils.models.database.GuildSettingsEntry;
import org.slf4j.Logger;
import java.util.HashMap;
diff --git a/src/main/java/io/paradaux/friendlybot/managers/GuildSettingsManager.java b/src/main/java/io/paradaux/friendlybot/managers/GuildSettingsManager.java
new file mode 100644
index 00000000..cbe9a112
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/managers/GuildSettingsManager.java
@@ -0,0 +1,119 @@
+package io.paradaux.friendlybot.managers;
+
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.FindOneAndUpdateOptions;
+import io.paradaux.friendlybot.core.utils.models.database.GuildSettingsEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
+import org.bson.Document;
+import org.slf4j.Logger;
+
+import java.util.HashMap;
+
+public class GuildSettingsManager {
+
+ private static final FindOneAndUpdateOptions INCREMENT_OPTIONS = new FindOneAndUpdateOptions().upsert(true);
+
+ private static final HashMap cachedGuilds = new HashMap<>();
+ private static GuildSettingsManager instance;
+
+ private final MongoCollection guilds;
+ private final Logger logger;
+
+ public GuildSettingsManager(Logger logger, MongoManager mongo) {
+ logger.info("Initialising: Guild Settings Manager");
+ this.logger = logger;
+ this.guilds = mongo.getGuildSettings();
+ instance = this;
+ }
+
+ public static GuildSettingsManager getInstance() {
+ if (instance == null) {
+ throw new ManagerNotReadyException();
+ }
+ instance.logger.info("Getting an instance of GuildSettingsManager...");
+
+ return instance;
+ }
+
+ public GuildSettingsEntry getGuild(String guildId) {
+ // Check if it's cached
+ GuildSettingsEntry guild = cachedGuilds.get(guildId);
+
+ if (guild != null) {
+ return guild;
+ }
+
+ // If it's not cached try to pull it from the database
+ logger.info("Guild did not exist in the cache");
+ guild = guilds.find(Filters.eq("guild_id", guildId)).first();
+
+ // if it's not in the database create a new profile.
+ if (guild == null) {
+ guild = createNewProfile(guildId);
+ }
+
+ // Load the guild into the cache
+ cachedGuilds.put(guildId, guild);
+
+ // Return the guild after it has been loaded into the cache
+ return guild;
+ }
+
+ public GuildSettingsEntry createNewProfile(String guildId) {
+ logger.info("Creating a guild profile for {}", guildId);
+
+ // Create an empty guild with just the ID
+ GuildSettingsEntry entry = new GuildSettingsEntry()
+ .setGuildId(guildId);
+
+ // Insert the newly created guild back into the database.
+ guilds.insertOne(entry);
+ return entry;
+ }
+
+ public void updateProfile(GuildSettingsEntry entry) {
+ // Updates it in the cache
+ cachedGuilds.put(entry.getGuildId(), entry);
+
+ // Updates it in the database
+ if (!guildExists(entry.getGuildId())) {
+ guilds.insertOne(entry);
+ } else {
+ guilds.findOneAndReplace(Filters.eq("guild_id", entry.getGuildId()), entry);
+ }
+ }
+
+ public boolean guildExists(String guildId) {
+ // Checks first to see if it's in the cache
+ GuildSettingsEntry entry = cachedGuilds.get(guildId);
+
+ // If it isn't, check the database
+ if (entry == null) {
+ entry = guilds.find(Filters.eq("guild_id", guildId)).first();
+ }
+
+ // Return whether or not we found it.
+ return entry != null;
+ }
+
+ public void removeProfile(String guildId) {
+ // Removes a guild from the cache
+ cachedGuilds.remove(guildId);
+
+ // Removes a guild from the database
+ guilds.findOneAndDelete(Filters.eq("guild_id", guildId));
+ }
+
+ public void incrementIncidentId(String guildId) {
+ incrementField(guildId, "last_incident_id");
+ }
+
+ public void incrementTicketNumber(String guildId) {
+ incrementField(guildId, "last_ticket_number");
+ }
+
+ private void incrementField(String guildId, String field) {
+ guilds.findOneAndUpdate(new Document("guild_id", guildId), new Document("$inc", new Document(field, 1L)), INCREMENT_OPTIONS);
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/managers/IOManager.java b/src/main/java/io/paradaux/friendlybot/managers/IOManager.java
index 2bf8384c..2c878dc3 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/IOManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/IOManager.java
@@ -27,16 +27,17 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.configuration.PermissionEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
-import io.paradaux.friendlybot.utils.models.exceptions.NoSuchResourceException;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.configuration.PermissionEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
import org.slf4j.Logger;
import javax.annotation.Nullable;
import java.io.*;
import java.util.Scanner;
+import static io.paradaux.friendlybot.core.utils.IOUtils.exportResource;
+
public class IOManager {
public static IOManager instance = null;
@@ -56,35 +57,7 @@ public static IOManager getInstance() {
return instance;
}
- /**
- * Export a resource embedded into a Jar file to the local file path.
- *
- * @param inputPath ie.: "/configuration.yml" N.B / is a directory down in the "jar tree" been the jar the root of the tree
- * @throws NoSuchResourceException a generic exception to signal something went wrong
- */
- public static void exportResource(String inputPath, @Nullable String outputPath) throws NoSuchResourceException {
-
- OutputStream resourceOutputStream;
-
- try (InputStream resourceStream = IOManager.class.getResourceAsStream(inputPath)) {
- resourceOutputStream = new FileOutputStream(outputPath);
-
- if (resourceStream == null) {
- throw new FileNotFoundException("Cannot get resource \"" + inputPath + "\" from Jar file.");
- }
-
- int readBytes;
- byte[] buffer = new byte[4096];
-
- while ((readBytes = resourceStream.read(buffer)) > 0) {
- resourceOutputStream.write(buffer, 0, readBytes);
- }
- resourceOutputStream.close();
- } catch (IOException exception) {
- throw new NoSuchResourceException("Failed to deploy resource : " + exception.getMessage());
- }
- }
/**
* Reads the configuration file and maps it to the ConfigurationEntry object.
diff --git a/src/main/java/io/paradaux/friendlybot/managers/MailGunManager.java b/src/main/java/io/paradaux/friendlybot/managers/MailGunManager.java
index 7d0c71d2..53cff2aa 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/MailGunManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/MailGunManager.java
@@ -25,20 +25,16 @@
package io.paradaux.friendlybot.managers;
-import io.paradaux.friendlybot.utils.HttpUtils;
-import io.paradaux.friendlybot.utils.StringUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
-import io.paradaux.friendlybot.utils.models.exceptions.VerificationException;
+import io.paradaux.friendlybot.core.utils.HttpUtils;
+import io.paradaux.friendlybot.core.utils.StringUtils;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.slf4j.Logger;
-import java.io.IOException;
-import java.io.Reader;
-
public class MailGunManager {
private static MailGunManager instance;
@@ -79,28 +75,8 @@ public void sendEmail(String recipient, String tag, String code) {
.addHeader("Authorization", "Basic " + StringUtils.basicAuth("api", config.getMailGunApplicationKey()))
.build();
- HttpUtils.sendAsync(client, request).thenAccept((response) -> {
-
- if (response.body() == null) {
- throw new VerificationException("No response received.");
- }
-
- try (Reader reader = response.body().charStream()) {
- int charInt;
- StringBuilder strBuilder = new StringBuilder();
- while ((charInt = reader.read()) != -1) {
- strBuilder.append((char) charInt);
- }
-
- System.out.println(strBuilder.toString());
- } catch (IOException ok) {
- logger.error("Error occurred whilst interacting with mailgun.");
- throw new VerificationException();
- }
-
- }).join();
+ HttpUtils.sendAsync(client, request).thenAccept((response) -> logger.info("Sending a verification email for " + tag)).join();
}
-
}
\ No newline at end of file
diff --git a/src/main/java/io/paradaux/friendlybot/managers/MongoManager.java b/src/main/java/io/paradaux/friendlybot/managers/MongoManager.java
index 0e2f0b7e..e37b47c6 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/MongoManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/MongoManager.java
@@ -29,21 +29,21 @@
import com.mongodb.MongoClientSettings;
import com.mongodb.client.*;
import com.mongodb.client.model.Filters;
-import com.mongodb.client.model.FindOneAndUpdateOptions;
-import com.mongodb.client.model.ReturnDocument;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.*;
-import io.paradaux.friendlybot.utils.models.enums.TicketStatus;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
+import com.mongodb.client.model.IndexOptions;
+import com.mongodb.client.model.Indexes;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.*;
+import io.paradaux.friendlybot.core.utils.models.enums.TicketStatus;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
import org.bson.Document;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.codecs.pojo.PojoCodecProvider;
-import org.bson.types.ObjectId;
import org.slf4j.Logger;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import java.util.Date;
+import java.util.concurrent.TimeUnit;
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
import static org.bson.codecs.configuration.CodecRegistries.fromRegistries;
@@ -60,7 +60,6 @@ public class MongoManager {
private final MongoCollection pendingVerification;
private final MongoCollection verification;
- private final MongoCollection counterCollection;
private final MongoCollection auditLog;
private final MongoCollection warnings;
private final MongoCollection modmail;
@@ -106,7 +105,6 @@ public MongoManager(ConfigurationEntry config, Logger logger) {
pendingVerification = dataBase.getCollection("pendingVerification", PendingVerificationEntry.class);
verification = dataBase.getCollection("verification", VerificationEntry.class);
- counterCollection = dataBase.getCollection("counter", CounterEntry.class);
auditLog = dataBase.getCollection("auditlog", AuditLogEntry.class);
warnings = dataBase.getCollection("warnings", WarningEntry.class);
modmail = dataBase.getCollection("modmail", ModMailEntry.class);
@@ -121,6 +119,12 @@ public MongoManager(ConfigurationEntry config, Logger logger) {
guilds = dataBase.getCollection("guildsettings", GuildSettingsEntry.class);
stats = dataBase.getCollection("stats", BotStats.class);
+ loggedMessages.createIndex(Indexes.ascending("date_sent"),
+ new IndexOptions().expireAfter(1L, TimeUnit.DAYS));
+
+ logger.info("Ensuring we're not storing any messages that should have expired.");
+ loggedMessages.countDocuments();
+
instance = this;
}
@@ -148,39 +152,6 @@ public MongoCollection getTags() {
return tags;
}
- public String getNextIncidentID() {
- CounterEntry result = incrementCounter("last_incident_id");
- return Long.toString(result.getLastIncidentID() + 1);
- }
-
- public String getNextTicketNumber() {
- CounterEntry result = incrementCounter("last_ticket_number");
- return Long.toString(result.getLastIncidentID() + 1);
- }
-
- @CheckReturnValue
- @Nullable
- public CounterEntry incrementCounter(String field) {
- Document query = new Document("_id", new ObjectId("5fb6895ba9dc2abc3eec8c4a"));
-
- Document increment = new Document(field, 1L);
- Document update = new Document("$inc", increment);
-
- FindOneAndUpdateOptions options = new FindOneAndUpdateOptions()
- .returnDocument(ReturnDocument.AFTER)
- .upsert(true);
-
- CounterEntry result = counterCollection.findOneAndUpdate(query, update, options);
-
- if (result == null) {
- result = new CounterEntry()
- .setLastIncidentID(0L)
- .setLastTickerNumber(0L);
- }
-
- return result;
- }
-
public void addPendingVerificationUser(String discordID, String guildID,
String verificationCode) {
PendingVerificationEntry pendingVerificationEntry = new PendingVerificationEntry()
@@ -334,7 +305,6 @@ public void addRescindment(RescindmentEntry entry) {
}
public void updateStats(int userCount, int guildCount) {
- System.out.printf("userCOunt: " + userCount + " guildCount" + guildCount);
stats.findOneAndUpdate(new Document(), new Document()
.append("user_count", userCount)
.append("guild_count", guildCount));
diff --git a/src/main/java/io/paradaux/friendlybot/managers/PermissionManager.java b/src/main/java/io/paradaux/friendlybot/managers/PermissionManager.java
index 554a4f15..c1f45b97 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/PermissionManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/PermissionManager.java
@@ -25,8 +25,8 @@
package io.paradaux.friendlybot.managers;
-import io.paradaux.friendlybot.utils.models.configuration.PermissionEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.models.configuration.PermissionEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
import org.slf4j.Logger;
import java.io.FileNotFoundException;
@@ -41,8 +41,11 @@ public class PermissionManager {
private PermissionEntry permissions;
private final Logger logger;
- public PermissionManager(Logger logger) {
+ private final GuildSettingsManager guilds;
+
+ public PermissionManager(Logger logger, GuildSettingsManager guilds) {
this.logger = logger;
+ this.guilds = guilds;
logger.info("Initialising: Permission Manager");
diff --git a/src/main/java/io/paradaux/friendlybot/managers/PunishmentManager.java b/src/main/java/io/paradaux/friendlybot/managers/PunishmentManager.java
new file mode 100644
index 00000000..4991539b
--- /dev/null
+++ b/src/main/java/io/paradaux/friendlybot/managers/PunishmentManager.java
@@ -0,0 +1,216 @@
+package io.paradaux.friendlybot.managers;
+
+import io.paradaux.friendlybot.core.utils.TimeUtils;
+import io.paradaux.friendlybot.core.utils.embeds.moderation.BannedEmbed;
+import io.paradaux.friendlybot.core.utils.models.database.*;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.models.types.ModerationAction;
+import net.dv8tion.jda.api.EmbedBuilder;
+import net.dv8tion.jda.api.entities.*;
+
+import java.util.Date;
+
+public class PunishmentManager {
+
+ private static PunishmentManager instance;
+ private final GuildSettingsManager guilds;
+ private final MongoManager mongo;
+
+ public PunishmentManager() {
+ this.guilds = GuildSettingsManager.getInstance();
+ this.mongo = MongoManager.getInstance();
+ instance = this;
+ }
+
+ public static PunishmentManager getInstance() {
+ if (instance == null) {
+ throw new ManagerNotReadyException();
+ }
+
+ return instance;
+ }
+
+ public void tempBanUser(Guild guild, Member target, Member staff, TextChannel channel, String time, String reason) {
+ GuildSettingsEntry settings = guilds.getGuild(guild.getId());
+
+ long period = TimeUtils.getTime(time);
+ Date expiry = new Date(System.currentTimeMillis() + period);
+
+ TempBanEntry entry = new TempBanEntry()
+ .setIncidentId(String.valueOf(settings.getIncidentId()))
+ .setUserTag(target.getUser().getAsTag())
+ .setUserId(target.getId())
+ .setStaffTag(staff.getUser().getAsTag())
+ .setStaffId(staff.getId())
+ .setReason(reason)
+ .setTimestamp(new Date())
+ .setExpiry(expiry);
+
+ mongo.addTempBanEntry(entry);
+
+ TextChannel publicAuditLog = DiscordBotManager.getInstance().getChannel(settings.getPublicAuditLogChannel());
+ AuditManager.getInstance().log(ModerationAction.TEMP_BAN, target.getUser(), staff.getUser(), entry.getReason(), entry.getIncidentId());
+
+ target.getUser().openPrivateChannel().queue((privateChannel) -> {
+ MessageEmbed banNotification = new EmbedBuilder()
+ .setColor(0xeb5132)
+ .setTitle("You have been temporarily banned.")
+ .setDescription("**Reason**: " + entry.getReason() + "\n**Period**: " + TimeUtils.millisecondsToDisplay(period))
+ .setFooter("Incident ID: " + entry.getIncidentId() + ". For more information, reach out to a member of the moderation team.")
+ .setTimestamp(new Date().toInstant())
+ .build();
+
+ privateChannel.sendMessage(banNotification).queue((message2) -> {
+ guild.ban(target, 0).queue();
+ });
+
+ });
+ }
+
+ public void banUser(Guild guild, Member target, Member staff, TextChannel channel, String reason) {
+ GuildSettingsEntry settings = guilds.getGuild(guild.getId());
+
+ String incidentID = String.valueOf(settings.getIncidentId());
+
+ BanEntry entry = new BanEntry()
+ .setIncidentID(incidentID)
+ .setReason(reason)
+ .setStaffID(staff.getId())
+ .setStaffTag(staff.getUser().getAsTag())
+ .setUserID(target.getId())
+ .setUserTag(target.getUser().getAsTag());
+
+ mongo.addBanEntry(entry);
+ AuditManager.getInstance().log(ModerationAction.BAN, target.getUser(), staff.getUser(), reason, incidentID);
+
+ BannedEmbed embed = new BannedEmbed(reason, incidentID);
+ target.getUser().openPrivateChannel().queue((privateChannel) -> privateChannel.sendMessage(embed.getEmbed()).queue());
+
+ guild.ban(target, 0).queue();
+ }
+
+ public void kickUser(Guild guild, Member target, Member staff, TextChannel channel, String reason) {
+ GuildSettingsEntry settings = guilds.getGuild(guild.getId());
+
+ MongoManager mongo = MongoManager.getInstance();
+
+ String incidentID = String.valueOf(settings.getIncidentId());
+
+ KickEntry entry = new KickEntry()
+ .setIncidentID(incidentID)
+ .setReason(reason)
+ .setStaffID(staff.getId())
+ .setStaffTag(staff.getUser().getAsTag())
+ .setUserID(target.getId())
+ .setUserTag(target.getUser().getAsTag());
+
+ mongo.addKickEntry(entry);
+
+ AuditManager.getInstance().log(ModerationAction.KICK, target.getUser(), staff.getUser(), reason, incidentID);
+
+
+ target.getUser().openPrivateChannel().queue((privateChannel ) -> {
+ MessageEmbed kickNotification = new EmbedBuilder()
+ .setColor(0xffff99)
+ .setTitle("You have been kicked.")
+ .setDescription("**Reason**: " + reason)
+ .setFooter("Incident ID: " + incidentID + ". For more information, reach out to the moderation team via mod-mail.")
+ .setTimestamp(new Date().toInstant())
+ .build();
+
+ privateChannel.sendMessage(kickNotification).queue();
+
+ target.kick(reason).queue();
+ });
+ }
+
+ public void warnUser(Guild guild, Member target, Member staff, TextChannel channel, String reason) {
+ GuildSettingsEntry settings = guilds.getGuild(guild.getId());
+
+ MongoManager mongo = MongoManager.getInstance();
+
+ String incidentID = String.valueOf(settings.getIncidentId());
+
+ WarningEntry entry = new WarningEntry()
+ .setIncidentID(incidentID)
+ .setReason(reason)
+ .setStaffID(staff.getId())
+ .setStaffTag(staff.getUser().getAsTag())
+ .setUserID(target.getId())
+ .setUserTag(target.getUser().getAsTag())
+ .setTimestamp(new Date());
+
+ mongo.addWarnEntry(entry);
+
+ AuditManager.getInstance().log(ModerationAction.WARN, target.getUser(), staff.getUser(), reason, incidentID);
+
+
+ target.getUser().openPrivateChannel().queue((privateChannel) -> {
+ MessageEmbed warnNotification = new EmbedBuilder()
+ .setColor(0x33cccc)
+ .setTitle("You have been warned.")
+ .setDescription("**Reason**: " + reason + "\n**N.B**: Receiving a second warning is an automatic temporary ban.")
+ .setFooter("Incident ID: " + incidentID + ". For more information, reach out to the moderation team via mod-mail.")
+ .setTimestamp(new Date().toInstant())
+ .build();
+
+ channel.sendMessage(warnNotification).queue();
+ });
+ }
+
+ private MessageEmbed sameChannelPunishmentEmbed() {
+ return null;
+ }
+
+ private MessageEmbed privateAuditPunishmentEmbed() {
+ return null;
+ }
+
+ public void deleteWarning(Guild guild, Member staff, String warningId, String reason) {
+ GuildSettingsEntry settings = guilds.getGuild(guild.getId());
+
+ WarningEntry entry = mongo.getWarningEntry(warningId);
+ mongo.deleteWarning(warningId);
+ String incidentId = String.valueOf(settings.getIncidentId());
+
+ RescindmentEntry rescindment = new RescindmentEntry()
+ .setAction(ModerationAction.WARN)
+ .setIncidentId(incidentId)
+ .setIncidentIdOfPunishment(entry.getIncidentID())
+ .setUserTag(entry.getUserTag())
+ .setUserId(entry.getUserID())
+ .setStaffTag(staff.getUser().getAsTag())
+ .setStaffId(staff.getId())
+ .setReason(reason)
+ .setTimeOfPunishment(entry.getTimestamp())
+ .setTimeOfRescindment(new Date());
+
+ mongo.addRescindment(rescindment);
+
+ String s;
+
+ MessageEmbed publicAudit = new EmbedBuilder()
+ .setColor(0x34eb9b)
+ .setTitle("Punishment Rescinded. | Warning of " + entry.getUserTag())
+ .setDescription(rescindment.getReason())
+ .setFooter("Punishment ID: " + entry.getIncidentID() + " Incident ID: " + incidentId)
+ .setTimestamp(new Date().toInstant())
+ .build();
+
+ DiscordBotManager.getInstance().getChannel(settings.getPublicAuditLogChannel()).sendMessage(publicAudit).queue();
+
+ User target = DiscordBotManager.getInstance().getUser(entry.getUserID());
+
+ target.openPrivateChannel().queue((channel) -> {
+ MessageEmbed rescindmentNotification = new EmbedBuilder()
+ .setColor(0x33cccc)
+ .setTitle("A warning levied against you has been taken back..")
+ .setDescription("** Original Reason**: " + entry.getReason() + "\n" + rescindment.getReason())
+ .setFooter("Punishment ID: " + entry.getIncidentID() + " Incident ID: " + incidentId)
+ .setTimestamp(new Date().toInstant())
+ .build();
+
+ channel.sendMessage(rescindmentNotification).queue();
+ });
+ }
+}
diff --git a/src/main/java/io/paradaux/friendlybot/managers/RoleManager.java b/src/main/java/io/paradaux/friendlybot/managers/RoleManager.java
index b3f55f66..6302735d 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/RoleManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/RoleManager.java
@@ -1,10 +1,15 @@
package io.paradaux.friendlybot.managers;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
import net.dv8tion.jda.api.entities.Guild;
+import net.dv8tion.jda.api.entities.Member;
+import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.requests.restaction.RoleAction;
import org.slf4j.Logger;
+import javax.annotation.Nullable;
+import java.util.List;
+
public class RoleManager {
private static RoleManager instance;
@@ -27,6 +32,11 @@ public static RoleManager getInstance() {
return instance;
}
+ public void setupColorRolePivot(Guild guild) {
+ Role highestRole = getHighestFrom(guild.getSelfMember());
+ guild.createRole().setName("Color Roles Begin Here").queue((role -> guild.modifyRolePositions().selectPosition(role).moveTo(role.getPosition() - 1).queue()));
+ }
+
public boolean checkForConflicts(Guild guild, String name) {
return DiscordBotManager.getInstance().getRolesByName(guild.getId(), name).size() != 0;
}
@@ -40,7 +50,29 @@ public RoleAction createRole(Guild guild, String color) {
.setColor(Integer.parseInt(color, 16))
.setMentionable(false)
.setName(color);
-
}
+ /**
+ * Determines the highest role (i.e the role displayed when the user speaks) of the member provided.
+ * */
+ @Nullable
+ public Role getHighestFrom(Member member) {
+ if (member == null) {
+ return null;
+ }
+
+ List roles = member.getRoles();
+
+ if (roles.isEmpty()) {
+ return null;
+ }
+
+ return roles.stream().min((first, second) -> {
+ if (first.getPosition() == second.getPosition()) {
+ return 0;
+ }
+
+ return first.getPosition() > second.getPosition() ? -1 : 1;
+ }).get();
+ }
}
diff --git a/src/main/java/io/paradaux/friendlybot/managers/TagManager.java b/src/main/java/io/paradaux/friendlybot/managers/TagManager.java
index de13f959..6bebff78 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/TagManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/TagManager.java
@@ -3,9 +3,9 @@
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.Filters;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.TagEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.TagEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
import org.bson.Document;
import org.slf4j.Logger;
@@ -39,7 +39,7 @@ public void addTag(TagEntry entry) {
}
public void removeTag(TagEntry entry) {
- tags.findOneAndDelete(getTagSearchQueryById(entry.getGuild(), entry.getId()));
+ tags.findOneAndDelete(getTagSearchQueryById(entry.getGuildId(), entry.getId()));
}
public TagEntry getTagById(String guildId, String tagName) {
@@ -55,7 +55,7 @@ public FindIterable getTags(String guildId) {
}
public void updateTag(TagEntry entry) {
- tags.findOneAndReplace(getTagSearchQueryById(entry.getGuild(), entry.getId()), entry);
+ tags.findOneAndReplace(getTagSearchQueryById(entry.getGuildId(), entry.getId()), entry);
}
private Document getTagSearchQueryById(String guildId, String tagName) {
diff --git a/src/main/java/io/paradaux/friendlybot/managers/TaskManager.java b/src/main/java/io/paradaux/friendlybot/managers/TaskManager.java
index 06e64581..f5a40b2e 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/TaskManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/TaskManager.java
@@ -1,12 +1,11 @@
package io.paradaux.friendlybot.managers;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
import net.dv8tion.jda.api.entities.Guild;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-import java.util.logging.LogManager;
import java.util.logging.Logger;
public class TaskManager {
diff --git a/src/main/java/io/paradaux/friendlybot/managers/SettingsManager.java b/src/main/java/io/paradaux/friendlybot/managers/UserSettingsManager.java
similarity index 83%
rename from src/main/java/io/paradaux/friendlybot/managers/SettingsManager.java
rename to src/main/java/io/paradaux/friendlybot/managers/UserSettingsManager.java
index 222a8b96..1c4d41ef 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/SettingsManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/UserSettingsManager.java
@@ -1,9 +1,9 @@
package io.paradaux.friendlybot.managers;
import com.mongodb.client.MongoCollection;
-import io.paradaux.friendlybot.utils.TimeUtils;
-import io.paradaux.friendlybot.utils.models.database.UserSettingsEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.TimeUtils;
+import io.paradaux.friendlybot.core.utils.models.database.UserSettingsEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
import net.dv8tion.jda.api.entities.User;
import org.bson.Document;
import org.slf4j.Logger;
@@ -12,24 +12,24 @@
import java.util.Date;
import java.util.List;
-public class SettingsManager {
+public class UserSettingsManager {
private static final short COOLDOWN = 3;
- private static SettingsManager instance;
+ private static UserSettingsManager instance;
private final Logger logger;
private final MongoCollection settings;
- public SettingsManager(Logger logger, MongoManager mongo) {
+ public UserSettingsManager(Logger logger, MongoManager mongo) {
this.logger = logger;
instance = this;
- logger.info("Initialising: Settings Manager");
+ logger.info("Initialising: User Settings Manager");
settings = mongo.getUserSettings();
}
- public static SettingsManager getInstance() {
+ public static UserSettingsManager getInstance() {
if (instance == null) {
throw new ManagerNotReadyException();
}
diff --git a/src/main/java/io/paradaux/friendlybot/managers/VerificationManager.java b/src/main/java/io/paradaux/friendlybot/managers/VerificationManager.java
index 3266bfeb..0af4e283 100644
--- a/src/main/java/io/paradaux/friendlybot/managers/VerificationManager.java
+++ b/src/main/java/io/paradaux/friendlybot/managers/VerificationManager.java
@@ -26,11 +26,11 @@
package io.paradaux.friendlybot.managers;
import com.mongodb.client.FindIterable;
-import io.paradaux.friendlybot.utils.StringUtils;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.PendingVerificationEntry;
-import io.paradaux.friendlybot.utils.models.exceptions.ManagerNotReadyException;
-import io.paradaux.friendlybot.utils.models.exceptions.VerificationException;
+import io.paradaux.friendlybot.core.utils.StringUtils;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.PendingVerificationEntry;
+import io.paradaux.friendlybot.core.utils.models.exceptions.ManagerNotReadyException;
+import io.paradaux.friendlybot.core.utils.models.exceptions.VerificationException;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/database/CounterEntry.java b/src/main/java/io/paradaux/friendlybot/utils/models/database/CounterEntry.java
deleted file mode 100644
index 0b694fa1..00000000
--- a/src/main/java/io/paradaux/friendlybot/utils/models/database/CounterEntry.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * MIT License
- *
- * Copyright (c) 2021 RÃan Errity
- * io.paradaux.friendlybot.utils.models.database.CounterEntry : 31/01/2021, 01:26
- *
- * 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 io.paradaux.friendlybot.utils.models.database;
-
-import org.bson.codecs.pojo.annotations.BsonProperty;
-
-import java.io.Serializable;
-
-public class CounterEntry implements Serializable {
-
- protected static final long serialVersionUID = 1L;
-
- @BsonProperty(value = "last_incident_id")
- private long lastIncidentID;
-
- @BsonProperty(value = "last_ticket_number")
- private long lastTickerNumber;
-
- public CounterEntry(Long lastIncidentID, Long lastTickerNumber) {
- this.lastIncidentID = lastIncidentID;
- this.lastTickerNumber = lastTickerNumber;
- }
-
- public CounterEntry() {
-
- }
-
- public Long getLastIncidentID() {
- return lastIncidentID;
- }
-
- public Long getLastTickerNumber() {
- return lastTickerNumber;
- }
-
- public CounterEntry setLastIncidentID(Long lastIncidentID) {
- this.lastIncidentID = lastIncidentID;
- return this;
- }
-
- public CounterEntry setLastTickerNumber(Long lastTickerNumber) {
- this.lastTickerNumber = lastTickerNumber;
- return this;
- }
-}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/enums/TicketStatus.java b/src/main/java/io/paradaux/friendlybot/utils/models/enums/TicketStatus.java
deleted file mode 100644
index 5fa3ef91..00000000
--- a/src/main/java/io/paradaux/friendlybot/utils/models/enums/TicketStatus.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package io.paradaux.friendlybot.utils.models.enums;
-
-public enum TicketStatus {
- OPEN, CLOSED
-}
diff --git a/src/main/java/io/paradaux/friendlybot/utils/models/types/ModerationAction.java b/src/main/java/io/paradaux/friendlybot/utils/models/types/ModerationAction.java
deleted file mode 100644
index 84624b45..00000000
--- a/src/main/java/io/paradaux/friendlybot/utils/models/types/ModerationAction.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package io.paradaux.friendlybot.utils.models.types;
-
-public enum ModerationAction {
-
- WARN, KICK, BAN, TEMP_BAN, RESCINDMENT;
-
-}
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index 1c58f63e..9b0789bf 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -1,6 +1,6 @@
# MIT License
#
-# Copyright (c) 2021 Rían Errity
+# Copyright (c) 2021 Rian Errity
# D:/Workspace/Java/FriendlyBot/src/main/resources/log4j.properties : 31/01/2021, 01:26
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -30,7 +30,7 @@ log4j.appender.thirdPartyLibAppender=org.apache.log4j.FileAppender
log4j.appender.thirdPartyLibAppender.append=true
log4j.appender.thirdPartyLibAppender.file=/tmp/FriendlyBot.log
log4j.appender.thirdPartyLibAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.thirdPartyLibAppender.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss} FriendlyBot: %p] %c:%m%n
+log4j.appender.thirdPartyLibAppender.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss} FriendlyBot: %p] %m%n
log4j.appender.FriendlyBotAppender=org.apache.log4j.ConsoleAppender
log4j.appender.FriendlyBotAppender.layout=org.apache.log4j.PatternLayout
@@ -42,4 +42,4 @@ log4j.logger.org.mongodb.driver=INFO
#log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss} FriendlyBot: %p] %c:%m%n
\ No newline at end of file
+log4j.appender.A1.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss} FriendlyBot: %p] %m%n
\ No newline at end of file
diff --git a/src/sql/guilds.sql b/src/sql/guilds.sql
new file mode 100644
index 00000000..60cf5c80
--- /dev/null
+++ b/src/sql/guilds.sql
@@ -0,0 +1,21 @@
+create table guilds(
+ id bigserial
+ constraint guilds_pk
+ primary key,
+ guild_id varchar(20),
+ command_prefix varchar(1),
+ verification_role_id varchar(20),
+ verification_input_id varchar(20),
+ audit_log_id varchar(20),
+ mod_audit_log_id varchar(20),
+ mod_mail_in_id varchar(20),
+ mod_mail_out_id varchar(20),
+ message_log_id varchar(20),
+ last_incident_id bigint,
+ last_ticket_id bigint,
+ administrators jsonb,
+ moderators jsonb
+);
+
+alter table guilds
+ owner to friendlybot;
diff --git a/src/sql/user.sql b/src/sql/user.sql
new file mode 100644
index 00000000..1a8d0a90
--- /dev/null
+++ b/src/sql/user.sql
@@ -0,0 +1,14 @@
+create table users
+(
+ id serial
+ constraint users_pk
+ primary key,
+ guild_id varchar(20),
+ user_id varchar(20),
+ custom_color_role varchar(7),
+ discord_tag varchar(40),
+ last_changed_color timestamp
+);
+
+alter table users
+ owner to postgres;
\ No newline at end of file
diff --git a/src/test/java/io/paradaux/friendlybot/utils/EmbedParserTest.java b/src/test/java/io/paradaux/friendlybot/core/utils/EmbedParserTest.java
similarity index 93%
rename from src/test/java/io/paradaux/friendlybot/utils/EmbedParserTest.java
rename to src/test/java/io/paradaux/friendlybot/core/utils/EmbedParserTest.java
index 0762ecea..d39b5d7b 100644
--- a/src/test/java/io/paradaux/friendlybot/utils/EmbedParserTest.java
+++ b/src/test/java/io/paradaux/friendlybot/core/utils/EmbedParserTest.java
@@ -23,12 +23,12 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils;
+package io.paradaux.friendlybot.core.utils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import io.paradaux.friendlybot.utils.embeds.command.UserInfoEmbed;
-import io.paradaux.friendlybot.utils.models.interfaces.Embed;
+import io.paradaux.friendlybot.core.utils.embeds.command.UserInfoEmbed;
+import io.paradaux.friendlybot.core.utils.models.interfaces.Embed;
import net.dv8tion.jda.api.EmbedBuilder;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/io/paradaux/friendlybot/utils/TimeUtilsTest.java b/src/test/java/io/paradaux/friendlybot/core/utils/TimeUtilsTest.java
similarity index 86%
rename from src/test/java/io/paradaux/friendlybot/utils/TimeUtilsTest.java
rename to src/test/java/io/paradaux/friendlybot/core/utils/TimeUtilsTest.java
index 2b21ae9c..a98cc307 100644
--- a/src/test/java/io/paradaux/friendlybot/utils/TimeUtilsTest.java
+++ b/src/test/java/io/paradaux/friendlybot/core/utils/TimeUtilsTest.java
@@ -1,4 +1,4 @@
-package io.paradaux.friendlybot.utils;
+package io.paradaux.friendlybot.core.utils;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/io/paradaux/friendlybot/utils/models/StringUtilsTest.java b/src/test/java/io/paradaux/friendlybot/core/utils/models/StringUtilsTest.java
similarity index 97%
rename from src/test/java/io/paradaux/friendlybot/utils/models/StringUtilsTest.java
rename to src/test/java/io/paradaux/friendlybot/core/utils/models/StringUtilsTest.java
index 6401ab52..b30ad222 100644
--- a/src/test/java/io/paradaux/friendlybot/utils/models/StringUtilsTest.java
+++ b/src/test/java/io/paradaux/friendlybot/core/utils/models/StringUtilsTest.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.utils.models;
+package io.paradaux.friendlybot.core.utils.models;
-import io.paradaux.friendlybot.utils.StringUtils;
+import io.paradaux.friendlybot.core.utils.StringUtils;
import net.dv8tion.jda.api.OnlineStatus;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
diff --git a/src/test/java/io/paradaux/friendlybot/database/GuildSettingsTest.java b/src/test/java/io/paradaux/friendlybot/database/GuildSettingsTest.java
new file mode 100644
index 00000000..c58b1def
--- /dev/null
+++ b/src/test/java/io/paradaux/friendlybot/database/GuildSettingsTest.java
@@ -0,0 +1,57 @@
+package io.paradaux.friendlybot.database;
+
+import io.ebean.DB;
+import io.paradaux.friendlybot.core.data.database.models.FGuild;
+import io.paradaux.friendlybot.core.data.database.models.GuildSettings;
+import org.junit.jupiter.api.Test;
+
+import java.util.ArrayList;
+
+public class GuildSettingsTest {
+
+ @Test
+ public void insertFindDelete() {
+ GuildSettings settings = new GuildSettings();
+ settings.setGuildId("1");
+ settings.setGuildName("This is a test");
+
+ // insert the customer in the DB
+ DB.save(settings);
+
+ // Find by Id
+ GuildSettings foundHello = DB.find(GuildSettings.class, "1");
+ System.out.println(foundHello);
+
+ // delete the customer
+ DB.delete(settings);
+ }
+
+ @Test
+ public void fGuildTest() {
+ FGuild guild = new FGuild();
+ guild.setGuildId("778219443737329684");
+ guild.setCommandPrefix(";");
+
+ guild.setVerificationRoleId("781365795237527602");
+ guild.setVerificationInputId("886628377564430387");
+
+ guild.setAuditLogId("852334545750851624");
+ guild.setModAuditLogId("852334546627723294");
+
+ guild.setModMailInId("852334544316923905");
+ guild.setModMailOutId("852334545104928828");
+
+ guild.setMessageLogId("852334547105218591");
+
+ guild.setModerators(new ArrayList<>());
+ guild.setAdministrators(new ArrayList<>());
+
+
+ guild.setLastIncidentId(0);
+ guild.setLastTicketId(0);
+
+ DB.save(guild);
+
+
+ }
+}
diff --git a/src/test/java/io/paradaux/friendlybot/commands/utility/WolframAlphaCommandTest.java b/src/test/java/io/paradaux/friendlybot/discord/commands/utility/WolframAlphaCommandTest.java
similarity index 97%
rename from src/test/java/io/paradaux/friendlybot/commands/utility/WolframAlphaCommandTest.java
rename to src/test/java/io/paradaux/friendlybot/discord/commands/utility/WolframAlphaCommandTest.java
index fbb043c7..eab5d482 100644
--- a/src/test/java/io/paradaux/friendlybot/commands/utility/WolframAlphaCommandTest.java
+++ b/src/test/java/io/paradaux/friendlybot/discord/commands/utility/WolframAlphaCommandTest.java
@@ -23,9 +23,9 @@
* SOFTWARE.
*/
-package io.paradaux.friendlybot.commands.utility;
+package io.paradaux.friendlybot.discord.commands.utility;
-import io.paradaux.friendlybot.utils.NumberUtils;
+import io.paradaux.friendlybot.core.utils.NumberUtils;
import io.paradaux.http.HttpApi;
import net.dv8tion.jda.api.EmbedBuilder;
import org.json.JSONObject;
diff --git a/src/test/java/io/paradaux/friendlybot/managers/BotControllerTest.java b/src/test/java/io/paradaux/friendlybot/managers/BotControllerTest.java
index 87545825..cf7ef7e4 100644
--- a/src/test/java/io/paradaux/friendlybot/managers/BotControllerTest.java
+++ b/src/test/java/io/paradaux/friendlybot/managers/BotControllerTest.java
@@ -25,7 +25,7 @@
package io.paradaux.friendlybot.managers;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
import org.junit.jupiter.api.BeforeAll;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,7 +40,7 @@ static void setUp() {
ConfigManager configurationController;
ConfigurationEntry config = new ConfigurationEntry();
- DiscordBotManager controller = new DiscordBotManager(config, logger, null, null, null);
+ DiscordBotManager controller = new DiscordBotManager(config, logger, null, null, null, null);
}
}
\ No newline at end of file
diff --git a/src/test/java/io/paradaux/friendlybot/scripts/ModifyProdDb.java b/src/test/java/io/paradaux/friendlybot/scripts/ModifyProdDb.java
index 82099c02..978372dc 100644
--- a/src/test/java/io/paradaux/friendlybot/scripts/ModifyProdDb.java
+++ b/src/test/java/io/paradaux/friendlybot/scripts/ModifyProdDb.java
@@ -3,10 +3,9 @@
import com.mongodb.client.FindIterable;
import io.paradaux.friendlybot.managers.MongoManager;
import io.paradaux.friendlybot.managers.TagManager;
-import io.paradaux.friendlybot.utils.models.configuration.ConfigurationEntry;
-import io.paradaux.friendlybot.utils.models.database.TagEntry;
+import io.paradaux.friendlybot.core.utils.models.configuration.ConfigurationEntry;
+import io.paradaux.friendlybot.core.utils.models.database.TagEntry;
import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/test/resources/application-test.yaml b/src/test/resources/application-test.yaml
new file mode 100644
index 00000000..9d85a3f2
--- /dev/null
+++ b/src/test/resources/application-test.yaml
@@ -0,0 +1,8 @@
+ebean:
+ test:
+ useDocker: false ## DO NOT USE DOCKER
+ platform: h2 # h2, postgres, mysql, oracle, sqlserver
+ ddlMode: dropCreate # none | dropCreate | migrations | create
+ dbName: friendlybot
+ h2:
+ url: jdbc:h2:./friendlybot