fix(deps): update dependency net.dv8tion:jda to v5.4.0
This commit is contained in:
1 parent
0d735f3744
commit
8e4a6841cc
69 files changed
+338
-159
No files matched your search
@@ -48,6 +48,8 @@ test:
|
||||
reports:
|
||||
junit:
|
||||
- "**/target/*-reports/TEST-*.xml"
|
||||
codequality:
|
||||
- "target/gl-code-quality-report.json"
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == "main"'
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
<module name="Checker">
|
||||
<property name="severity" value="warning"/>
|
||||
|
||||
<!-- Allows tab characters -->
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="false"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<!-- Indentation with tabs -->
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="tabWidth" value="4"/>
|
||||
<property name="forceStrictCondition" value="false"/>
|
||||
</module>
|
||||
|
||||
<!-- Common useful checks -->
|
||||
<module name="EmptyBlock">
|
||||
<property name="option" value="text"/>
|
||||
</module>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="UnusedImports"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
|
||||
<!-- Relaxed Javadoc rules -->
|
||||
<module name="JavadocMethod">
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
@@ -75,6 +75,42 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>checkstyle</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<configLocation>checkstyle.xml</configLocation>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
<linkXRef>false</linkXRef>
|
||||
<outputFile>target/checkstyle-result.xml</outputFile>
|
||||
<outputFormat>xml</outputFormat>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>de.chkal.maven</groupId>
|
||||
<artifactId>gitlab-code-quality-plugin</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -100,7 +136,7 @@
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>5.3.2</version>
|
||||
<version>5.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>dev.arbjerg</groupId>
|
||||
|
||||
@@ -5,10 +5,10 @@ package me.bobert.netneutrality.command.admin;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.AdminCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.AdminCommand;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.db.entities.OBlacklist;
|
||||
import me.bobert.netneutrality.db.service.BlacklistService;
|
||||
|
||||
@@ -5,10 +5,10 @@ package me.bobert.netneutrality.command.admin;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.AdminCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.AdminCommand;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.core.tasks.TaskManager;
|
||||
import me.bobert.netneutrality.tasks.emoji.EmojiReactionRoleTask;
|
||||
|
||||
@@ -5,10 +5,13 @@ package me.bobert.netneutrality.command.basic;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.*;
|
||||
import me.bobert.netneutrality.core.command.CommandCategory;
|
||||
import me.bobert.netneutrality.core.command.CommandContainer;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandManager;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.AbstractCommand;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.core.tasks.BuiltInTask;
|
||||
import me.bobert.netneutrality.tasks.help.BotInfo;
|
||||
|
||||
@@ -5,10 +5,10 @@ package me.bobert.netneutrality.command.basic;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.AbstractCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandCategory;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.AbstractCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
|
||||
public class PingCommand extends AbstractCommand {
|
||||
|
||||
@@ -5,10 +5,10 @@ package me.bobert.netneutrality.command.bot;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.AdminCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.AdminCommand;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.db.GSettings;
|
||||
import me.bobert.netneutrality.db.service.GuildService;
|
||||
|
||||
@@ -6,11 +6,11 @@ package me.bobert.netneutrality.command.crypto;
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.LogHandler;
|
||||
import me.bobert.netneutrality.core.command.impl.AbstractCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandCategory;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.AbstractCommand;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.http.WebModule;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
@@ -5,10 +5,10 @@ package me.bobert.netneutrality.command.git;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.AbstractCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandCategory;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.AbstractCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.http.WebModule;
|
||||
import me.bobert.netneutrality.tasks.git.ReportIssueTask;
|
||||
|
||||
@@ -6,10 +6,10 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandCategory;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
|
||||
@@ -6,9 +6,9 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MessageFunction;
|
||||
|
||||
@@ -6,9 +6,9 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
|
||||
@@ -6,10 +6,10 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
@@ -5,10 +5,10 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MessageFunction;
|
||||
|
||||
@@ -4,9 +4,9 @@ package me.bobert.netneutrality.command.music;/*
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
|
||||
@@ -6,9 +6,9 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
|
||||
@@ -6,10 +6,10 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
|
||||
@@ -6,9 +6,9 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
|
||||
@@ -5,9 +5,9 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MessageFunction;
|
||||
|
||||
@@ -6,10 +6,10 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.options.CommandOption;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
|
||||
@@ -5,9 +5,9 @@ package me.bobert.netneutrality.command.music;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.CommandOptionsBuilder;
|
||||
import me.bobert.netneutrality.core.command.impl.MusicCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.music.MusicManager;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
|
||||
@@ -6,8 +6,8 @@ package me.bobert.netneutrality.command.react;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MessageMenuCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.impl.MessageMenuCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.core.tasks.TaskManager;
|
||||
import me.bobert.netneutrality.tasks.emoji.EmojiReactionRoleTask;
|
||||
|
||||
@@ -6,8 +6,8 @@ package me.bobert.netneutrality.command.react;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import me.bobert.netneutrality.core.command.impl.MessageMenuCommand;
|
||||
import me.bobert.netneutrality.core.command.CommandExecutionResult;
|
||||
import me.bobert.netneutrality.core.command.impl.MessageMenuCommand;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.core.tasks.TaskManager;
|
||||
import me.bobert.netneutrality.tasks.emoji.EmojiReactionRoleTask;
|
||||
|
||||
@@ -10,7 +10,10 @@ import me.bobert.netneutrality.core.command.options.MessageCommandOption;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.core.context.MessageContext;
|
||||
import me.bobert.netneutrality.utils.Settings;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Mentions;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@@ -8,11 +8,8 @@ package me.bobert.netneutrality.context.tasks;
|
||||
import me.bobert.netneutrality.context.AsyncContext;
|
||||
import me.bobert.netneutrality.core.context.NoMessageContext;
|
||||
import me.bobert.netneutrality.core.context.TaskContext;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||
import net.dv8tion.jda.api.interactions.InteractionHook;
|
||||
import net.dv8tion.jda.api.interactions.components.LayoutComponent;
|
||||
import net.dv8tion.jda.api.interactions.modals.Modal;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -130,7 +130,10 @@ public class CommandContainer {
|
||||
|
||||
for (OptionData option : options) {
|
||||
usage.append("\n");
|
||||
if (group) usage.append(" ");
|
||||
if (group) {
|
||||
usage.append(" ");
|
||||
}
|
||||
|
||||
usage.append(" - ");
|
||||
if (option.isRequired()) {
|
||||
usage.append("*");
|
||||
|
||||
@@ -9,7 +9,11 @@ import net.dv8tion.jda.api.interactions.DiscordLocale;
|
||||
import net.dv8tion.jda.api.interactions.IntegrationType;
|
||||
import net.dv8tion.jda.api.interactions.InteractionContextType;
|
||||
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.*;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData;
|
||||
import net.dv8tion.jda.api.interactions.commands.localization.LocalizationFunction;
|
||||
import net.dv8tion.jda.api.interactions.commands.localization.LocalizationMap;
|
||||
import net.dv8tion.jda.api.utils.data.DataObject;
|
||||
|
||||
@@ -27,7 +27,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.util.function.Predicate.not;
|
||||
import static me.bobert.netneutrality.core.command.CommandExecutionResult.Result.*;
|
||||
import static me.bobert.netneutrality.core.command.CommandExecutionResult.Result.ERROR;
|
||||
import static me.bobert.netneutrality.core.command.CommandExecutionResult.Result.NOACTION;
|
||||
import static me.bobert.netneutrality.core.command.CommandExecutionResult.Result.TASK;
|
||||
import static me.bobert.netneutrality.core.command.CommandExecutionResult.Result.WARN;
|
||||
|
||||
public class CommandProcessor {
|
||||
|
||||
|
||||
@@ -64,8 +64,9 @@ public abstract class MusicCommand extends AbstractCommand {
|
||||
@Override
|
||||
public boolean canBeExecutedFrom(MessageChannel channel) {
|
||||
if (channel instanceof GuildMessageChannel guildMessageChannel) {
|
||||
if (channel.getType() != ChannelType.TEXT)
|
||||
if (channel.getType() != ChannelType.TEXT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String channelDb = GuildService.get(guildMessageChannel.getGuild()).getGuildSettingService().getSetting(GSettings.MUSIC_CHANNEL);
|
||||
if (channelDb != null && !channelDb.isEmpty()) {
|
||||
|
||||
@@ -5,7 +5,11 @@ package me.bobert.netneutrality.core.command.options;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.IMentionable;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.unions.GuildChannelUnion;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
@@ -29,10 +33,8 @@ public interface CommandOption {
|
||||
* <br>This is represented as an {@link Message.Attachment#isEphemeral() ephemeral} attachment which will only be hosted for up to 2 weeks.
|
||||
* If you want a permanent reference, you must download it.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option {@link #getType() type} is not {@link OptionType#ATTACHMENT}
|
||||
*
|
||||
* @return {@link net.dv8tion.jda.api.entities.Message.Attachment Attachment}
|
||||
* @throws IllegalStateException If this option {@link #getType() type} is not {@link OptionType#ATTACHMENT}
|
||||
*/
|
||||
Message.Attachment getAsAttachment();
|
||||
|
||||
@@ -48,10 +50,8 @@ public interface CommandOption {
|
||||
/**
|
||||
* The boolean value.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option is not of type {@link OptionType#BOOLEAN BOOLEAN}
|
||||
*
|
||||
* @return The boolean value
|
||||
* @throws IllegalStateException If this option is not of type {@link OptionType#BOOLEAN BOOLEAN}
|
||||
*/
|
||||
boolean getAsBoolean();
|
||||
|
||||
@@ -59,12 +59,9 @@ public interface CommandOption {
|
||||
* The long value for this option.
|
||||
* <br>This will be the ID of any resolved entity such as {@link Role} or {@link Member}.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option {@link #getType() type} cannot be converted to a long
|
||||
* @throws NumberFormatException
|
||||
* If this option is of type {@link OptionType#STRING STRING} and could not be parsed to a valid long value
|
||||
*
|
||||
* @return The long value
|
||||
* @throws IllegalStateException If this option {@link #getType() type} cannot be converted to a long
|
||||
* @throws NumberFormatException If this option is of type {@link OptionType#STRING STRING} and could not be parsed to a valid long value
|
||||
*/
|
||||
long getAsLong();
|
||||
|
||||
@@ -74,36 +71,27 @@ public interface CommandOption {
|
||||
*
|
||||
* <p><b>It is highly recommended to assert int values by using {@link OptionData#setRequiredRange(long, long)}</b>
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option {@link #getType() type} cannot be converted to a long
|
||||
* @throws NumberFormatException
|
||||
* If this option is of type {@link OptionType#STRING STRING} and could not be parsed to a valid long value
|
||||
* @throws ArithmeticException
|
||||
* If the provided integer value cannot fit into a 32bit signed int
|
||||
*
|
||||
* @return The int value
|
||||
* @throws IllegalStateException If this option {@link #getType() type} cannot be converted to a long
|
||||
* @throws NumberFormatException If this option is of type {@link OptionType#STRING STRING} and could not be parsed to a valid long value
|
||||
* @throws ArithmeticException If the provided integer value cannot fit into a 32bit signed int
|
||||
*/
|
||||
int getAsInt();
|
||||
|
||||
/**
|
||||
* The double value for this option.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option {@link #getType() type} cannot be converted to a double
|
||||
* @throws NumberFormatException
|
||||
* If this option is of type {@link OptionType#STRING STRING} and could not be parsed to a valid double value
|
||||
*
|
||||
* @return The double value
|
||||
* @throws IllegalStateException If this option {@link #getType() type} cannot be converted to a double
|
||||
* @throws NumberFormatException If this option is of type {@link OptionType#STRING STRING} and could not be parsed to a valid double value
|
||||
*/
|
||||
double getAsDouble();
|
||||
|
||||
/**
|
||||
* The resolved {@link IMentionable} instance for this option value.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If the mentioned entity is not resolvable
|
||||
*
|
||||
* @return The resolved {@link IMentionable}
|
||||
* @throws IllegalStateException If the mentioned entity is not resolvable
|
||||
*/
|
||||
IMentionable getAsMentionable();
|
||||
|
||||
@@ -111,42 +99,34 @@ public interface CommandOption {
|
||||
* The resolved {@link Member} for this option value.
|
||||
* <br>Note that {@link OptionType#USER OptionType.USER} can also accept users that are not members of a guild, in which case this will be null!
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option is not of type {@link OptionType#USER USER} or {@link OptionType#MENTIONABLE MENTIONABLE}
|
||||
*
|
||||
* @return The resolved {@link Member}, or null
|
||||
* @throws IllegalStateException If this option is not of type {@link OptionType#USER USER} or {@link OptionType#MENTIONABLE MENTIONABLE}
|
||||
*/
|
||||
Member getAsMember();
|
||||
|
||||
/**
|
||||
* The resolved {@link User} for this option value.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option is not of type {@link OptionType#USER USER} or
|
||||
* {@link OptionType#MENTIONABLE MENTIONABLE} without a resolved user
|
||||
*
|
||||
* @return The resolved {@link User}
|
||||
* @throws IllegalStateException If this option is not of type {@link OptionType#USER USER} or
|
||||
* {@link OptionType#MENTIONABLE MENTIONABLE} without a resolved user
|
||||
*/
|
||||
User getAsUser();
|
||||
|
||||
/**
|
||||
* The resolved {@link Role} for this option value.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option is not of type {@link OptionType#ROLE ROLE} or
|
||||
* {@link OptionType#MENTIONABLE MENTIONABLE} without a resolved role
|
||||
*
|
||||
* @return The resolved {@link Role}
|
||||
* @throws IllegalStateException If this option is not of type {@link OptionType#ROLE ROLE} or
|
||||
* {@link OptionType#MENTIONABLE MENTIONABLE} without a resolved role
|
||||
*/
|
||||
Role getAsRole();
|
||||
|
||||
/**
|
||||
* The {@link ChannelType} for the resolved channel.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option is not of type {@link OptionType#CHANNEL CHANNEL}
|
||||
*
|
||||
* @return The {@link ChannelType}
|
||||
* @throws IllegalStateException If this option is not of type {@link OptionType#CHANNEL CHANNEL}
|
||||
*/
|
||||
ChannelType getChannelType();
|
||||
|
||||
@@ -154,11 +134,9 @@ public interface CommandOption {
|
||||
* The resolved {@link net.dv8tion.jda.api.entities.channel.middleman.GuildChannel} for this option value.
|
||||
* <br>Note that {@link OptionType#CHANNEL OptionType.CHANNEL} can accept channels of any type!
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* If this option is not of type {@link OptionType#CHANNEL CHANNEL}
|
||||
* or could not be resolved for unexpected reasons
|
||||
*
|
||||
* @return The resolved {@link net.dv8tion.jda.api.entities.channel.middleman.GuildChannel}
|
||||
* @throws IllegalStateException If this option is not of type {@link OptionType#CHANNEL CHANNEL}
|
||||
* or could not be resolved for unexpected reasons
|
||||
*/
|
||||
GuildChannelUnion getAsChannel();
|
||||
}
|
||||
+5
-1
@@ -5,7 +5,11 @@ package me.bobert.netneutrality.core.command.options;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.IMentionable;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.unions.GuildChannelUnion;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||
|
||||
@@ -5,7 +5,11 @@ package me.bobert.netneutrality.core.command.options;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.IMentionable;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.unions.GuildChannelUnion;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
|
||||
@@ -6,7 +6,6 @@ package me.bobert.netneutrality.core.context;
|
||||
*/
|
||||
|
||||
import io.sentry.Sentry;
|
||||
import me.bobert.netneutrality.context.command.SlashCommandContext;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
|
||||
@@ -17,7 +17,12 @@ import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -26,7 +31,7 @@ public abstract class CommandContext extends AbstractContext {
|
||||
private Command command;
|
||||
private SubcommandGroupData subcommandGroup;
|
||||
private SubcommandData subcommand;
|
||||
private final Map <OptionData, String> invalidOptions = new HashMap<>();
|
||||
private final Map<OptionData, String> invalidOptions = new HashMap<>();
|
||||
private final List<CommandOption> options;
|
||||
|
||||
public CommandContext(JDA jda, Guild guild, MessageChannel channel, Member member, User user) {
|
||||
@@ -70,16 +75,20 @@ public abstract class CommandContext extends AbstractContext {
|
||||
public <T> T getOption(String name, Supplier<? extends T> fallback, Function<? super CommandOption, ? extends T> resolver) {
|
||||
Objects.requireNonNull(resolver, "resolver cannot be null");
|
||||
CommandOption mapping = getOption(name);
|
||||
if (mapping != null)
|
||||
if (mapping != null) {
|
||||
return resolver.apply(mapping);
|
||||
}
|
||||
|
||||
return fallback == null ? null : fallback.get();
|
||||
}
|
||||
|
||||
public <T> T getOption(String name, T fallback, Function<? super CommandOption, ? extends T> resolver) {
|
||||
Objects.requireNonNull(resolver, "resolver cannot be null");
|
||||
CommandOption mapping = getOption(name);
|
||||
if (mapping != null)
|
||||
if (mapping != null) {
|
||||
return resolver.apply(mapping);
|
||||
}
|
||||
|
||||
return fallback;
|
||||
}
|
||||
|
||||
@@ -132,7 +141,4 @@ public abstract class CommandContext extends AbstractContext {
|
||||
public abstract String parseCommandName();
|
||||
|
||||
public abstract String getFullCommand();
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -8,7 +8,11 @@ package me.bobert.netneutrality.core.context;
|
||||
import me.bobert.netneutrality.context.AsyncContext;
|
||||
import me.bobert.netneutrality.utils.ContextUtils;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
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.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.events.Event;
|
||||
|
||||
@@ -29,8 +29,12 @@ public abstract class AbstractTask implements Task {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AbstractTask that = (AbstractTask) o;
|
||||
return Objects.equals(getId(), that.getId());
|
||||
|
||||
@@ -20,6 +20,7 @@ public interface Task {
|
||||
REMOVE_SELF,
|
||||
REMOVE_SELF_AND_CHILDREN
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should generate a unique ID to differentiate it from other tasks.
|
||||
* <p>
|
||||
@@ -44,6 +45,7 @@ public interface Task {
|
||||
|
||||
/**
|
||||
* This is only used for debugging purpose.
|
||||
*
|
||||
* @return Name of the task
|
||||
*/
|
||||
String getName();
|
||||
@@ -55,6 +57,7 @@ public interface Task {
|
||||
|
||||
/**
|
||||
* When this returns true, the task will get removed by the cleanup thread.
|
||||
*
|
||||
* @return If the task is expired
|
||||
*/
|
||||
boolean isExpired();
|
||||
@@ -71,6 +74,7 @@ public interface Task {
|
||||
|
||||
/**
|
||||
* Executes the task.
|
||||
*
|
||||
* @param context The context for this task.
|
||||
*/
|
||||
Lifecycle execute(TaskContext context);
|
||||
|
||||
@@ -25,7 +25,11 @@ import org.reflections.Reflections;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -6,7 +6,11 @@ package me.bobert.netneutrality.core.thread;
|
||||
*/
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ThreadManager {
|
||||
|
||||
@@ -38,11 +42,9 @@ public class ThreadManager {
|
||||
ex.shutdown();
|
||||
ex.awaitTermination(1, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
System.err.println("[Executor] Running tasks interrupted");
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
executors.forEach((name, ex) -> {
|
||||
if (!ex.isTerminated()) {
|
||||
System.err.println("[Executor: " + name + "] Forcing shutdown of running tasks..");
|
||||
|
||||
@@ -24,7 +24,7 @@ public interface Repository<O> {
|
||||
default void save(O entity) {
|
||||
Transaction transaction = null;
|
||||
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
transaction = session.beginTransaction();
|
||||
session.merge(entity);
|
||||
transaction.commit();
|
||||
|
||||
@@ -6,7 +6,15 @@ package me.bobert.netneutrality.db.entities;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "blacklist")
|
||||
|
||||
@@ -6,7 +6,11 @@ package me.bobert.netneutrality.db.entities;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -6,7 +6,18 @@ package me.bobert.netneutrality.db.entities;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.Lob;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.NamedQueries;
|
||||
import jakarta.persistence.NamedQuery;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "guild_settings")
|
||||
|
||||
@@ -6,7 +6,16 @@ package me.bobert.netneutrality.db.entities;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Convert;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
|
||||
@@ -6,7 +6,14 @@ package me.bobert.netneutrality.db.entities;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.EmbeddedId;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.MapsId;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "logging")
|
||||
|
||||
@@ -46,8 +46,12 @@ public class OLoggingId implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
|
||||
return false;
|
||||
}
|
||||
OLoggingId entity = (OLoggingId) o;
|
||||
return Objects.equals(this.guildId, entity.guildId) &&
|
||||
Objects.equals(this.channelId, entity.channelId);
|
||||
|
||||
@@ -5,7 +5,14 @@ package me.bobert.netneutrality.db.entities;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
|
||||
@Entity
|
||||
@Table(name = "tasks", uniqueConstraints = {@UniqueConstraint(columnNames = {"task_id"})})
|
||||
|
||||
@@ -6,7 +6,11 @@ package me.bobert.netneutrality.db.entities;
|
||||
* https://discord.gg/qUa6zNFZsd
|
||||
*/
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
import jakarta.persistence.Table;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
@@ -92,7 +92,7 @@ public class BlacklistRepository implements Repository<OBlacklist> {
|
||||
}
|
||||
|
||||
private OBlacklist getWordFromDb(String guildId, String word) {
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
Query<OBlacklist> query = session.createQuery("SELECT o FROM OBlacklist o WHERE upper(o.word) = upper(:word) AND o.guild.guildId = :guildId", OBlacklist.class);
|
||||
query.setParameter("guildId", guildId);
|
||||
query.setParameter("word", word);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GuildRepository implements Repository<OGuild> {
|
||||
|
||||
@Override
|
||||
public OGuild findById(String id) {
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
Query<OGuild> query = session.createQuery("SELECT o FROM OGuild o WHERE o.guildId = :guildId", OGuild.class);
|
||||
query.setParameter("guildId", id);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class GuildSettingRepository implements Repository<OGuildSetting> {
|
||||
|
||||
@Override
|
||||
public OGuildSetting findById(String id) {
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
Query<OGuildSetting> query = session.createQuery("SELECT o FROM OGuildSetting o WHERE o.id = :id", OGuildSetting.class);
|
||||
query.setParameter("id", id);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class MessageRepository implements Repository<OLogMessage> {
|
||||
|
||||
@Override
|
||||
public OLogMessage findById(String id) {
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
Query<OLogMessage> query = session.createQuery("SELECT o FROM OLogMessage o WHERE o.messageId = :messageId", OLogMessage.class);
|
||||
query.setParameter("messageId", id);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TaskRepository implements Repository<OTask> {
|
||||
|
||||
@Override
|
||||
public OTask findById(String id) {
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
Query<OTask> query = session.createQuery("SELECT o FROM OTask o WHERE o.taskId = :taskId", OTask.class);
|
||||
query.setParameter("taskId", id);
|
||||
|
||||
|
||||
@@ -53,8 +53,12 @@ public class EventsHandler implements EventListener {
|
||||
|
||||
static {
|
||||
addListener(MessageReceivedEvent.class, event -> {
|
||||
if (event.getAuthor().isBot()) return null;
|
||||
if (event.isWebhookMessage()) return null;
|
||||
if (event.getAuthor().isBot()) {
|
||||
return null;
|
||||
}
|
||||
if (event.isWebhookMessage()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Message message = event.getMessage();
|
||||
String rawMessage = message.getContentDisplay().trim();
|
||||
|
||||
@@ -10,14 +10,23 @@ import com.google.gson.Gson;
|
||||
import io.sentry.Breadcrumb;
|
||||
import io.sentry.Sentry;
|
||||
import me.bobert.netneutrality.utils.Settings;
|
||||
import okhttp3.*;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class WebModule {
|
||||
|
||||
@@ -13,7 +13,10 @@ import net.dv8tion.jda.api.entities.Member;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
|
||||
@@ -37,23 +37,29 @@ public class SourceFinder {
|
||||
Matcher udioMatcher = udioPattern.matcher(url);
|
||||
Matcher mp3Matcher = mp3Pattern.matcher(url);
|
||||
|
||||
if (youtubeMatcher.find())
|
||||
if (youtubeMatcher.find()) {
|
||||
return AudioSourceType.Youtube;
|
||||
}
|
||||
|
||||
if (youtubeMusicMatcher.find())
|
||||
if (youtubeMusicMatcher.find()) {
|
||||
return AudioSourceType.YTMusic;
|
||||
}
|
||||
|
||||
if (soundcloudMatcher.find())
|
||||
if (soundcloudMatcher.find()) {
|
||||
return AudioSourceType.Soundcloud;
|
||||
}
|
||||
|
||||
if (udioMatcher.find())
|
||||
if (udioMatcher.find()) {
|
||||
return AudioSourceType.Udio;
|
||||
}
|
||||
|
||||
if (mp3Matcher.find())
|
||||
if (mp3Matcher.find()) {
|
||||
return AudioSourceType.DirectLinkMp3;
|
||||
}
|
||||
|
||||
if (!(url.startsWith("http://") || url.startsWith("https://")))
|
||||
if (!(url.startsWith("http://") || url.startsWith("https://"))) {
|
||||
return AudioSourceType.YTSearch;
|
||||
}
|
||||
|
||||
return AudioSourceType.Nothing;
|
||||
}
|
||||
|
||||
@@ -50,8 +50,12 @@ public class TrackInfo {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TrackInfo trackInfo = (TrackInfo) o;
|
||||
return track.equals(trackInfo.track);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
import me.bobert.netneutrality.core.LogHandler;
|
||||
import me.bobert.netneutrality.core.context.CommandContext;
|
||||
import me.bobert.netneutrality.core.tasks.TaskManager;
|
||||
import me.bobert.netneutrality.tasks.music.LoadPlaylistTask;
|
||||
import me.bobert.netneutrality.utils.MessageFunction;
|
||||
import me.bobert.netneutrality.utils.MusicUtils;
|
||||
@@ -64,9 +63,10 @@ public class TrackLoadingHandler implements AudioLoadResultHandler {
|
||||
public void noMatches() {
|
||||
logger.debug("Guild {}: no matches for identifier {}", guild.getId(), identifier);
|
||||
|
||||
if (!silent)
|
||||
if (!silent) {
|
||||
context.reply("No matches found");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFailed(FriendlyException e) {
|
||||
@@ -76,7 +76,8 @@ public class TrackLoadingHandler implements AudioLoadResultHandler {
|
||||
RuntimeException exception = new RuntimeException("Failed to load track: " + e.getMessage(), e);
|
||||
LogHandler.log(exception);
|
||||
|
||||
if (!silent)
|
||||
if (!silent) {
|
||||
context.reply(MessageFunction.buildSentryErrorMessage(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,9 @@ import java.util.regex.Pattern;
|
||||
import static com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity.SUSPICIOUS;
|
||||
|
||||
public class UdioAudioSourceManager implements AudioSourceManager {
|
||||
|
||||
private static final Logger log = LogManager.getLogger(UdioAudioSourceManager.class);
|
||||
|
||||
|
||||
private static final String TRACK_URL_REGEX = "^https://www.udio.com/songs/[0-9A-Za-z]+$";
|
||||
private static final Pattern trackUrlPattern = Pattern.compile(TRACK_URL_REGEX);
|
||||
|
||||
private final HttpInterfaceManager httpInterfaceManager;
|
||||
|
||||
public UdioAudioSourceManager() {
|
||||
@@ -64,11 +60,8 @@ public class UdioAudioSourceManager implements AudioSourceManager {
|
||||
} catch (IOException e) {
|
||||
throw new FriendlyException("Loading Udio track information failed.", SUSPICIOUS, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isTrackEncodable(AudioTrack track) {
|
||||
return true;
|
||||
@@ -94,7 +87,6 @@ public class UdioAudioSourceManager implements AudioSourceManager {
|
||||
}
|
||||
|
||||
private AudioItem loadFromTrackPage(HttpInterface httpInterface, String trackUrl) throws IOException {
|
||||
|
||||
try (CloseableHttpResponse response = httpInterface.execute(new HttpGet(trackUrl))) {
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
|
||||
@@ -124,7 +116,6 @@ public class UdioAudioSourceManager implements AudioSourceManager {
|
||||
String artworkUrl = getArtworkUrlFromImagePath(trackInfo);
|
||||
|
||||
AudioTrackInfo audioTrackInfo = new AudioTrackInfo(title, artist, duration, trackUrl, false, playbackUrl, artworkUrl, null);
|
||||
|
||||
return new UdioAudioTrack(audioTrackInfo, this);
|
||||
}
|
||||
|
||||
@@ -155,5 +146,4 @@ public class UdioAudioSourceManager implements AudioSourceManager {
|
||||
|
||||
return imagePath.replace("public", artworkOptions);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* A generic button task that represents a button to accept a choice.
|
||||
*
|
||||
* @param <P> the type of the parent task, which must implement WithChildren
|
||||
*/
|
||||
public class AcceptButton<P extends WithChildren> extends ButtonTask implements WithParent<P>, NotAcknowledgeable {
|
||||
|
||||
@@ -40,8 +40,9 @@ public class ChannelMessagePurger {
|
||||
|
||||
public boolean canLockBeAcquired() {
|
||||
boolean acquired = lock.tryLock();
|
||||
if (acquired)
|
||||
if (acquired) {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
return acquired;
|
||||
}
|
||||
|
||||
@@ -57,13 +57,13 @@ public class JpaUtils {
|
||||
}
|
||||
|
||||
public static void runWithSession(Consumer<Session> consumer) {
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
consumer.accept(session);
|
||||
}
|
||||
}
|
||||
|
||||
public static void runWithTransaction(Consumer<Session> consumer) {
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
session.beginTransaction();
|
||||
consumer.accept(session);
|
||||
session.getTransaction().commit();
|
||||
@@ -71,7 +71,7 @@ public class JpaUtils {
|
||||
}
|
||||
|
||||
public static void updateWithTransaction(Object persistantEntity, Runnable runnable) {
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
Transaction transaction = session.beginTransaction();
|
||||
|
||||
try {
|
||||
@@ -98,7 +98,7 @@ public class JpaUtils {
|
||||
* @param consumer The comsumer, which exposes the session
|
||||
*/
|
||||
public static void getWithSession(Object persistantEntity, Serializable id, Consumer<Session> consumer) {
|
||||
try(Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
try (Session session = SessionManager.getSessionFactory().openSession()) {
|
||||
tryLoad(session, persistantEntity, id);
|
||||
consumer.accept(session);
|
||||
}
|
||||
|
||||
@@ -29,10 +29,11 @@ import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
|
||||
public class MessageFunction {
|
||||
|
||||
@@ -137,7 +138,9 @@ public class MessageFunction {
|
||||
message.append("- ").append(info.title);
|
||||
}
|
||||
|
||||
if (index == limit) break;
|
||||
if (index == limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return message.toString();
|
||||
@@ -162,7 +165,9 @@ public class MessageFunction {
|
||||
message.addField("Track #" + ++index, info.title, false);
|
||||
}
|
||||
|
||||
if (index == 10) break;
|
||||
if (index == 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
message.setTimestamp(OffsetDateTime.now());
|
||||
|
||||
|
||||
@@ -71,8 +71,9 @@ public class Settings {
|
||||
public String get(String key, String def) {
|
||||
String property = get(key);
|
||||
|
||||
if (property == null || property.isEmpty())
|
||||
if (property == null || property.isEmpty()) {
|
||||
return def;
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
@@ -91,7 +92,8 @@ public class Settings {
|
||||
p.load(is);
|
||||
version = p.getProperty("app.version", "");
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
if (version == null) {
|
||||
version = "0.0.0";
|
||||
|
||||
@@ -24,10 +24,11 @@ public class UserFunction {
|
||||
|
||||
public static boolean isAdmin(Member user) {
|
||||
boolean isAdmin = false;
|
||||
for(Role role : user.getRoles()) {
|
||||
if (role.getPermissions().contains(Permission.MANAGE_SERVER) || role.getPermissions().contains(Permission.ADMINISTRATOR))
|
||||
for (Role role : user.getRoles()) {
|
||||
if (role.getPermissions().contains(Permission.MANAGE_SERVER) || role.getPermissions().contains(Permission.ADMINISTRATOR)) {
|
||||
isAdmin = true;
|
||||
}
|
||||
}
|
||||
|
||||
return isAdmin;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user