Compare commits
2 Commits
f60ad91478
...
d88513ee49
Author | SHA1 | Date |
---|---|---|
Joe | d88513ee49 | |
Joe | fbddc45353 |
88
pom.xml
88
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>uk.co.angrybee.joe</groupId>
|
||||
<artifactId>discord-whitelister</artifactId>
|
||||
<version>1.5.0</version>
|
||||
<version>1.5.1</version>
|
||||
|
||||
<name>discord-whitelister</name>
|
||||
<url>https://github.com/JoeShimell/DiscordWhitelisterSpigot</url>
|
||||
|
@ -45,14 +45,14 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>4.3.0_346</version>
|
||||
<version>5.0.0-beta.19</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>club.minnced</groupId>
|
||||
|
@ -61,28 +61,40 @@
|
|||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.json-simple</groupId>
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.googlecode.json-simple</groupId>-->
|
||||
<!-- <artifactId>json-simple</artifactId>-->
|
||||
<!-- <version>1.1.1</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.3</version>
|
||||
<version>1.4.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>1.4.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>2.0.10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.26</version>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<version>3.5.1</version>
|
||||
<type>maven-plugin</type>
|
||||
</dependency>
|
||||
|
||||
|
@ -91,8 +103,7 @@
|
|||
<groupId>com.github.LeonMangler</groupId>
|
||||
<artifactId>SuperVanish</artifactId>
|
||||
<!-- POM is invalid with java compiler ver > 8 (maven-compiler-plugin source & target version is set to 8) -->
|
||||
<!-- TODO: get updated version if/when available for better support with compiler versions > 8 -->
|
||||
<version>6.2.6-2</version>
|
||||
<version>fbc303bbee6e129e56b3e89c5e83e98ee2127ff2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -100,7 +111,7 @@
|
|||
<dependency>
|
||||
<groupId>net.essentialsx</groupId>
|
||||
<artifactId>EssentialsX</artifactId>
|
||||
<version>2.19.0</version>
|
||||
<version>2.20.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
@ -114,10 +125,16 @@
|
|||
<dependency>
|
||||
<groupId>com.github.mbax</groupId>
|
||||
<artifactId>VanishNoPacket</artifactId>
|
||||
<version>0cb428ff27ced0b97b9601a3088e9b93616c907c</version>
|
||||
<version>341a9a9710848d85813f7dfdab0b606d46ab264a</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -125,54 +142,54 @@
|
|||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.3.2</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.3.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<version>3.12.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.22.1</version>
|
||||
<version>3.2.5</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.3.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<version>3.1.1</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<version>3.1.1</version>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<version>4.0.0-M13</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.5.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<version>3.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
|
@ -215,10 +232,10 @@
|
|||
<shadedPattern>uk.co.angrybee.joe.shaded.org.yaml.snakeyaml</shadedPattern>
|
||||
</relocation>
|
||||
|
||||
<relocation>
|
||||
<pattern>org.json.simple</pattern>
|
||||
<shadedPattern>uk.co.angrybee.joe.shaded.org.json.simple</shadedPattern>
|
||||
</relocation>
|
||||
<!-- <relocation>-->
|
||||
<!-- <pattern>org.json.simple</pattern>-->
|
||||
<!-- <shadedPattern>uk.co.angrybee.joe.shaded.org.json.simple</shadedPattern>-->
|
||||
<!-- </relocation>-->
|
||||
|
||||
<relocation>
|
||||
<pattern>org.jetbrains.annotations</pattern>
|
||||
|
@ -279,6 +296,11 @@
|
|||
<pattern>ch.qos.logback</pattern>
|
||||
<shadedPattern>uk.co.angrybee.joe.shaded.ch.qos.logback</shadedPattern>
|
||||
</relocation>
|
||||
|
||||
<relocation>
|
||||
<pattern>com.google.code.gson</pattern>
|
||||
<shadedPattern>uk.co.angrybee.joe.shaded.com.google.code.gson</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -286,7 +308,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.8</version>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>test</phase>
|
||||
|
@ -309,15 +331,15 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<source>19</source>
|
||||
<target>19</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<version>3.5.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package uk.co.angrybee.joe;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -14,7 +16,7 @@ public class AuthorPermissions
|
|||
private boolean userIsBanned = false;
|
||||
private boolean userCanUseClear = false;
|
||||
|
||||
public AuthorPermissions(SlashCommandEvent event) {
|
||||
public AuthorPermissions(SlashCommandInteractionEvent event) {
|
||||
for (Role role : event.getMember().getRoles())
|
||||
{
|
||||
if(!DiscordWhitelister.useIdForRoles)
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
package uk.co.angrybee.joe;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
|
||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||
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.SubcommandData;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
|
@ -19,9 +26,6 @@ import net.dv8tion.jda.api.utils.ChunkingFilter;
|
|||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import uk.co.angrybee.joe.commands.discord.*;
|
||||
import uk.co.angrybee.joe.events.ShutdownEvents;
|
||||
import uk.co.angrybee.joe.stores.UserList;
|
||||
|
@ -31,8 +35,11 @@ import javax.annotation.Nonnull;
|
|||
import javax.security.auth.login.LoginException;
|
||||
import java.awt.Color;
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.RecursiveTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static net.dv8tion.jda.api.interactions.commands.OptionType.*;
|
||||
|
@ -94,9 +101,9 @@ public class DiscordClient extends ListenerAdapter {
|
|||
javaDiscordAPI = JDABuilder.createDefault(clientToken)
|
||||
.setMemberCachePolicy(MemberCachePolicy.ALL)
|
||||
.setBulkDeleteSplittingEnabled(false)
|
||||
.disableCache(CacheFlag.VOICE_STATE, CacheFlag.EMOTE)
|
||||
.disableCache(CacheFlag.VOICE_STATE)
|
||||
.setContextEnabled(true)
|
||||
.enableIntents(GatewayIntent.GUILD_MEMBERS)
|
||||
.enableIntents(GatewayIntent.GUILD_MEMBERS, GatewayIntent.MESSAGE_CONTENT)
|
||||
.setChunkingFilter(ChunkingFilter.ALL)
|
||||
.addEventListeners(new DiscordClient())
|
||||
.addEventListeners(new ShutdownEvents())
|
||||
|
@ -107,31 +114,51 @@ public class DiscordClient extends ListenerAdapter {
|
|||
|
||||
CommandListUpdateAction commands = javaDiscordAPI.updateCommands();
|
||||
|
||||
commands.addCommands(
|
||||
new CommandData("whitelist", "Edit the whitelist.")
|
||||
.addSubcommands(
|
||||
new SubcommandData("add", "Add a user to the whitelist")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to add", true)
|
||||
.addOption(USER, "discord_user", "Discord user to bind to", false),
|
||||
new SubcommandData("remove", "Remove user from the whitelist")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to remove", true),
|
||||
new SubcommandData("clear", "Clear whitelists assigned to your account"),
|
||||
new SubcommandData("whois", "Find the Discord name linked to a Minecraft name")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft name to search", false)
|
||||
.addOption(USER, "discord_user", "Minecraft name to search", false)),
|
||||
// commands.addCommands(
|
||||
// new CommandData("whitelist", "Edit the whitelist.")
|
||||
// .addSubcommands(
|
||||
// new SubcommandData("add", "Add a user to the whitelist")
|
||||
// .addOption(STRING, "minecraft_username", "Minecraft username to add", true)
|
||||
// .addOption(USER, "discord_user", "Discord user to bind to", false),
|
||||
// new SubcommandData("remove", "Remove user from the whitelist")
|
||||
// .addOption(STRING, "minecraft_username", "Minecraft username to remove", true),
|
||||
// new SubcommandData("clear", "Clear whitelists assigned to your account"),
|
||||
// new SubcommandData("whois", "Find the Discord name linked to a Minecraft name")
|
||||
// .addOption(STRING, "minecraft_username", "Minecraft name to search", false)
|
||||
// .addOption(USER, "discord_user", "Minecraft name to search", false)),
|
||||
//
|
||||
// new CommandData("clearname", "Clear name from all lists")
|
||||
// .addOption(STRING, "minecraft_username", "Minecraft username to clear", true),
|
||||
// new CommandData("clearban", "Clear ban from user")
|
||||
// .addOption(STRING, "minecraft_username", "Minecraft username to unban", true),
|
||||
// new CommandData("help", "Show bot info"))
|
||||
// .queue();
|
||||
|
||||
new CommandData("clearname", "Clear name from all lists")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to clear", true),
|
||||
new CommandData("clearban", "Clear ban from user")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to unban", true),
|
||||
new CommandData("help", "Show bot info"))
|
||||
commands.addCommands(
|
||||
Commands.slash("whitelist", "Edit the whitelist.")
|
||||
.addSubcommands(
|
||||
new SubcommandData("add", "Add a user to the whitelist")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to add", true)
|
||||
.addOption(USER, "discord_user", "Discord user to bind to", false),
|
||||
new SubcommandData("remove", "Remove user from the whitelist")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to remove", true),
|
||||
new SubcommandData("clear", "Clear whitelists assigned to your account"),
|
||||
new SubcommandData("whois", "Find the Discord name linked to a Minecraft name")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft name to search", false)
|
||||
.addOption(USER, "discord_user", "Minecraft name to search", false)),
|
||||
|
||||
Commands.slash("clearname", "Clear name from all lists")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to clear", true),
|
||||
Commands.slash("clearban", "Clear ban from user")
|
||||
.addOption(STRING, "minecraft_username", "Minecraft username to unban", true),
|
||||
Commands.slash("help", "Show bot info"))
|
||||
.queue();
|
||||
|
||||
// Send the new set of commands to discord, this will override any existing global commands with the new set provided here
|
||||
|
||||
|
||||
return 0;
|
||||
} catch (LoginException | InterruptedException e) {
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
return 1;
|
||||
} catch (IllegalStateException e) {
|
||||
|
@ -314,7 +341,7 @@ public class DiscordClient extends ListenerAdapter {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSlashCommand(SlashCommandEvent event) {
|
||||
public void onSlashCommandInteraction(SlashCommandInteractionEvent event) {
|
||||
|
||||
// Todo: add help: CommandInfo.ExecuteCommand(messageReceivedEvent);
|
||||
// Todo: add remove message thing
|
||||
|
@ -328,7 +355,7 @@ public class DiscordClient extends ListenerAdapter {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Arrays.asList(targetTextChannels).contains(event.getTextChannel().getId())) {
|
||||
if (!Arrays.asList(targetTextChannels).contains(event.getChannelId())) {
|
||||
MessageEmbed messageEmbed = CreateEmbeddedMessage("Sorry!",
|
||||
("This bot can only used in the specified channel."), EmbedMessageType.FAILURE).build();
|
||||
ReplyAndRemoveAfterSeconds(event, messageEmbed);
|
||||
|
@ -422,11 +449,14 @@ public class DiscordClient extends ListenerAdapter {
|
|||
|
||||
@Override
|
||||
public void onMessageReceived(MessageReceivedEvent messageReceivedEvent) {
|
||||
if (!messageReceivedEvent.isFromType(ChannelType.TEXT)) {
|
||||
|
||||
if(!messageReceivedEvent.isFromType(ChannelType.TEXT))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if message should be handled
|
||||
if (!Arrays.asList(targetTextChannels).contains(messageReceivedEvent.getTextChannel().getId()))
|
||||
if (!Arrays.asList(targetTextChannels).contains(messageReceivedEvent.getChannel().getId()))
|
||||
return;
|
||||
|
||||
if (messageReceivedEvent.getAuthor().getIdLong() == javaDiscordAPI.getSelfUser().getIdLong())
|
||||
|
@ -438,7 +468,7 @@ public class DiscordClient extends ListenerAdapter {
|
|||
|
||||
// TODO remove, use in command classes when complete
|
||||
User author = messageReceivedEvent.getAuthor();
|
||||
TextChannel channel = messageReceivedEvent.getTextChannel();
|
||||
TextChannel channel = messageReceivedEvent.getChannel().asTextChannel();
|
||||
|
||||
// if no commands are executed, delete the message, if enabled
|
||||
if (DiscordWhitelister.removeUnnecessaryMessages) {
|
||||
|
@ -824,27 +854,28 @@ public class DiscordClient extends ListenerAdapter {
|
|||
}
|
||||
|
||||
|
||||
public static String minecraftUsernameToUUID(String minecraftUsername) {
|
||||
URL playerURL;
|
||||
String inputStream;
|
||||
BufferedReader bufferedReader;
|
||||
public static String minecraftUsernameToUUID(String minecraftUsername)
|
||||
{
|
||||
String playerId = null;
|
||||
|
||||
String playerUUID = null;
|
||||
try
|
||||
{
|
||||
URL pURL = new URL("https://api.mojang.com/users/profiles/minecraft/" + minecraftUsername);
|
||||
URLConnection req = pURL.openConnection();
|
||||
req.connect();
|
||||
|
||||
try {
|
||||
playerURL = new URL("https://api.mojang.com/users/profiles/minecraft/" + minecraftUsername);
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(playerURL.openStream()));
|
||||
inputStream = bufferedReader.readLine();
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
JsonElement root = (JsonElement) jsonParser.parse(new InputStreamReader((InputStream) req.getContent()));
|
||||
JsonObject rootObj = root.getAsJsonObject();
|
||||
playerId = rootObj.get("id").getAsString();
|
||||
|
||||
if (inputStream != null) {
|
||||
JSONObject inputStreamObject = (JSONObject) JSONValue.parseWithException(inputStream);
|
||||
playerUUID = inputStreamObject.get("id").toString();
|
||||
}
|
||||
} catch (IOException | ParseException e) {
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return playerUUID;
|
||||
return playerId;
|
||||
}
|
||||
|
||||
public static void ExecuteServerCommand(String command) {
|
||||
|
@ -977,7 +1008,7 @@ public class DiscordClient extends ListenerAdapter {
|
|||
}
|
||||
|
||||
|
||||
public static void ReplyAndRemoveAfterSeconds(SlashCommandEvent event, MessageEmbed messageEmbed) {
|
||||
public static void ReplyAndRemoveAfterSeconds(SlashCommandInteractionEvent event, MessageEmbed messageEmbed) {
|
||||
if (DiscordWhitelister.removeUnnecessaryMessages)
|
||||
event.replyEmbeds(messageEmbed).queue(message -> message.deleteOriginal().queueAfter(DiscordWhitelister.removeMessageWaitTime, TimeUnit.SECONDS));
|
||||
else
|
||||
|
|
|
@ -10,5 +10,5 @@ public class VersionInfo
|
|||
return "v." + getVersion();
|
||||
}
|
||||
|
||||
private static String version = "1.5.0";
|
||||
private static String version = "1.5.1";
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
|
@ -19,10 +21,10 @@ import java.util.concurrent.TimeUnit;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class CommandAdd {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_user, Member target) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_user, Member target) {
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
Member member = event.getMember();
|
||||
|
||||
int timesWhitelisted =0;
|
||||
|
@ -260,6 +262,7 @@ public class CommandAdd {
|
|||
/* Do as much as possible off the main server thread.
|
||||
convert username into UUID to avoid depreciation and rate limits (according to https://minotar.net/) */
|
||||
String playerUUID = DiscordClient.minecraftUsernameToUUID(finalNameToAdd);
|
||||
|
||||
final boolean invalidMinecraftName = playerUUID == null;
|
||||
|
||||
/* Configure success & failure messages here instead of on the main server thread -
|
||||
|
@ -407,10 +410,10 @@ public class CommandAdd {
|
|||
});
|
||||
}
|
||||
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_user) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_user) {
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
Member member = event.getMember();
|
||||
|
||||
int timesWhitelisted =0;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package uk.co.angrybee.joe.commands.discord;
|
||||
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -14,11 +16,11 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
public class CommandClear {
|
||||
public static void ExecuteCommand(SlashCommandEvent event) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event) {
|
||||
// Clear whitelists for limited-whitelisters
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
|
||||
if (!DiscordWhitelister.mainConfig.getFileConfiguration().getBoolean("allow-limited-whitelisters-to-unwhitelist-self")) {
|
||||
MessageEmbed messageEmbed = DiscordClient.CreateEmbeddedMessage("This Command is disabled",
|
||||
|
|
|
@ -3,9 +3,9 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -13,11 +13,11 @@ import uk.co.angrybee.joe.stores.InGameRemovedList;
|
|||
import uk.co.angrybee.joe.stores.RemovedList;
|
||||
|
||||
public class CommandClearban {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_user) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_user) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
|
||||
|
||||
if (authorPermissions.isUserCanUseClear()) {
|
||||
|
|
|
@ -2,9 +2,8 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -14,7 +13,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
public class CommandClearname {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_name) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_name) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package uk.co.angrybee.joe.commands.discord;
|
||||
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
|
||||
public class CommandInfo
|
||||
{
|
||||
public static void ExecuteCommand(SlashCommandEvent event)
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event)
|
||||
{
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
|
|
|
@ -2,7 +2,8 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -17,11 +18,11 @@ import java.util.Set;
|
|||
|
||||
public class CommandRemove {
|
||||
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_name) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_name) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
Member member = event.getMember();
|
||||
|
||||
// Remove Command
|
||||
|
|
|
@ -2,28 +2,20 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.exceptions.AccountTypeException;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
import uk.co.angrybee.joe.configs.MainConfig;
|
||||
import uk.co.angrybee.joe.stores.UserList;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CommandWhoIs {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, String mc_name) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, String mc_name) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
TextChannel channel = event.getTextChannel();
|
||||
TextChannel channel = event.getChannel().asTextChannel();
|
||||
|
||||
if (!authorPermissions.isUserCanAddRemove() && !authorPermissions.isUserCanAdd()) {
|
||||
DiscordClient.ReplyAndRemoveAfterSeconds(event, DiscordClient.CreateInsufficientPermsMessage(author));
|
||||
|
|
|
@ -3,9 +3,10 @@ package uk.co.angrybee.joe.commands.discord;
|
|||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
//import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
//import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import uk.co.angrybee.joe.AuthorPermissions;
|
||||
import uk.co.angrybee.joe.DiscordClient;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
@ -15,7 +16,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
public class CommandWhoIsDiscord {
|
||||
public static void ExecuteCommand(SlashCommandEvent event, Member target) {
|
||||
public static void ExecuteCommand(SlashCommandInteractionEvent event, Member target) {
|
||||
|
||||
AuthorPermissions authorPermissions = new AuthorPermissions(event);
|
||||
User author = event.getUser();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package uk.co.angrybee.joe.events;
|
||||
|
||||
import net.dv8tion.jda.api.events.ShutdownEvent;
|
||||
import net.dv8tion.jda.api.events.session.ShutdownEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.api.requests.CloseCode;
|
||||
import uk.co.angrybee.joe.DiscordWhitelister;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: DiscordWhitelister
|
||||
version: 1.5.0
|
||||
api-version: 1.17
|
||||
version: 1.5.1
|
||||
api-version: 1.19
|
||||
author: Joe Shimell
|
||||
main: uk.co.angrybee.joe.DiscordWhitelister
|
||||
description: Discord Whitelister.
|
||||
|
|
Loading…
Reference in New Issue