Use JDA LTS #8
14 arquivos alterados com 85 adições e 65 exclusões
25
build.gradle
25
build.gradle
|
|
@ -30,6 +30,10 @@ group = project.maven_group
|
||||||
sourceCompatibility = 16
|
sourceCompatibility = 16
|
||||||
targetCompatibility = 16
|
targetCompatibility = 16
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
includeTransitive
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||||
|
|
@ -37,20 +41,20 @@ dependencies {
|
||||||
include(modImplementation(fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version)))
|
include(modImplementation(fabricApi.module("fabric-lifecycle-events-v1", project.fabric_version)))
|
||||||
include(modImplementation(fabricApi.module("fabric-api-base", project.fabric_version)))
|
include(modImplementation(fabricApi.module("fabric-api-base", project.fabric_version)))
|
||||||
|
|
||||||
implementation include('net.dv8tion:JDA:5.0.0-alpha.5') {
|
implementation('net.dv8tion:JDA:4.4.0') {
|
||||||
exclude module: 'opus-java'
|
exclude module: 'opus-java'
|
||||||
}
|
}
|
||||||
|
|
||||||
include "net.sf.trove4j:trove4j:3.0.3"
|
includeTransitive implementation('net.dv8tion:JDA:4.4.0_352') {
|
||||||
include 'org.apache.commons:commons-collections4:4.1'
|
exclude module: 'opus-java'
|
||||||
include 'com.neovisionaries:nv-websocket-client:2.14'
|
}
|
||||||
include 'com.squareup.okhttp3:okhttp:3.13.0'
|
|
||||||
include 'com.squareup.okio:okio:1.17.2'
|
|
||||||
include 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
|
|
||||||
include 'com.fasterxml.jackson.core:jackson-annotations:2.10.1'
|
|
||||||
include 'com.fasterxml.jackson.core:jackson-core:2.10.1'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configurations.getByName("includeTransitive").resolvedConfiguration.resolvedArtifacts.forEach(dep -> {
|
||||||
|
if (!dep.id.componentIdentifier.displayName.contains("slf4j-api"))
|
||||||
|
dependencies.add("include", dep.id.componentIdentifier.displayName)
|
||||||
|
})
|
||||||
|
|
||||||
compileJava {
|
compileJava {
|
||||||
sourceCompatibility = 16
|
sourceCompatibility = 16
|
||||||
targetCompatibility = 16
|
targetCompatibility = 16
|
||||||
|
|
@ -115,7 +119,7 @@ curseforge {
|
||||||
id = "575422"
|
id = "575422"
|
||||||
changelog = ENV.CHANGELOG ?: "No changelog provided"
|
changelog = ENV.CHANGELOG ?: "No changelog provided"
|
||||||
releaseType = "release"
|
releaseType = "release"
|
||||||
addGameVersion "1.18-Snapshot"
|
addGameVersion "$project.minecraft_version"
|
||||||
addGameVersion "Fabric"
|
addGameVersion "Fabric"
|
||||||
|
|
||||||
mainArtifact(remapJar) {
|
mainArtifact(remapJar) {
|
||||||
|
|
@ -148,7 +152,6 @@ task github(dependsOn: remapMavenJar) {
|
||||||
releaseBuilder.name("[$project.supported_versions] AutoWhitelist - $project.version")
|
releaseBuilder.name("[$project.supported_versions] AutoWhitelist - $project.version")
|
||||||
releaseBuilder.body(ENV.CHANGELOG ?: "No changelog provided")
|
releaseBuilder.body(ENV.CHANGELOG ?: "No changelog provided")
|
||||||
releaseBuilder.commitish(getBranch())
|
releaseBuilder.commitish(getBranch())
|
||||||
releaseBuilder.prerelease(false)
|
|
||||||
|
|
||||||
def ghRelease = releaseBuilder.create()
|
def ghRelease = releaseBuilder.create()
|
||||||
ghRelease.uploadAsset(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"), "application/java-archive");
|
ghRelease.uploadAsset(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar"), "application/java-archive");
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
minecraft_version=1.18.2-pre1
|
minecraft_version=1.18.2
|
||||||
yarn_mappings=1.18.2-pre1+build.3
|
yarn_mappings=1.18.2+build.1
|
||||||
loader_version=0.13.2
|
loader_version=0.13.2
|
||||||
mod_version=1.0.0
|
mod_version=1.0.1
|
||||||
maven_group=com.awakenedredstone
|
maven_group=com.awakenedredstone
|
||||||
archives_base_name=autowhitelist
|
archives_base_name=autowhitelist
|
||||||
|
|
||||||
supported_versions=1.18.2-pre1+
|
supported_versions=1.18.2+
|
||||||
|
|
||||||
fabric_version=0.47.3+1.18.2
|
fabric_version=0.47.3+1.18.2
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ public class Config {
|
||||||
json.add("token", new JsonPrimitive("bot-token"));
|
json.add("token", new JsonPrimitive("bot-token"));
|
||||||
json.add("clientId", new JsonPrimitive("client-id"));
|
json.add("clientId", new JsonPrimitive("client-id"));
|
||||||
json.add("discordServerId", new JsonPrimitive("discord-server-id"));
|
json.add("discordServerId", new JsonPrimitive("discord-server-id"));
|
||||||
//json.add("enableSlashCommands", new JsonPrimitive(false)); Disabled due to high times to update global commands and not being practical for now
|
//json.add("enableSlashCommands", new JsonPrimitive(false)); Removed due to high times to update global commands and not being practical for now
|
||||||
JsonObject whitelistJson = JsonHelper.getNestedObject(json, "whitelist", true);
|
JsonObject whitelistJson = JsonHelper.getNestedObject(json, "whitelist", true);
|
||||||
if (whitelistJson == null) {
|
if (whitelistJson == null) {
|
||||||
AutoWhitelist.LOGGER.error("Something went wrong when generating the default config file!");
|
AutoWhitelist.LOGGER.error("Something went wrong when generating the default config file!");
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
//import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.util.logging.UncaughtExceptionHandler;
|
import net.minecraft.util.logging.UncaughtExceptionHandler;
|
||||||
|
|
@ -104,6 +104,8 @@ public class Bot implements Runnable {
|
||||||
builder.setMemberCachePolicy(MemberCachePolicy.ALL);
|
builder.setMemberCachePolicy(MemberCachePolicy.ALL);
|
||||||
jda = builder.build();
|
jda = builder.build();
|
||||||
try {
|
try {
|
||||||
|
jda.getPresence().setActivity(Activity.of(Activity.ActivityType.valueOf(new TranslatableText("bot.activity.type").getString().toUpperCase().replace("PLAYING", "DEFAULT")), new TranslatableText("bot.activity.message").getString()));
|
||||||
|
} catch (IllegalArgumentException | NullPointerException e) { //TODO: remove the replace once JDA is updated to 5.x.x
|
||||||
jda.getPresence().setActivity(Activity.of(Activity.ActivityType.valueOf(new TranslatableText("bot.activity.type").getString().toUpperCase()), new TranslatableText("bot.activity.message").getString()));
|
jda.getPresence().setActivity(Activity.of(Activity.ActivityType.valueOf(new TranslatableText("bot.activity.type").getString().toUpperCase()), new TranslatableText("bot.activity.message").getString()));
|
||||||
} catch (IllegalArgumentException | NullPointerException e) {
|
} catch (IllegalArgumentException | NullPointerException e) {
|
||||||
AutoWhitelist.LOGGER.error("Failed to set bot activity, the chosen activity type value is not valid.", e);
|
AutoWhitelist.LOGGER.error("Failed to set bot activity, the chosen activity type value is not valid.", e);
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,11 @@ import com.mojang.brigadier.StringReader;
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
//import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
@ -74,7 +75,7 @@ public class CommandManager {
|
||||||
embedBuilder.setDescription(mutableText.getString());
|
embedBuilder.setDescription(mutableText.getString());
|
||||||
embedBuilder.setFooter(new TranslatableText("command.feedback.message.signature").getString());
|
embedBuilder.setFooter(new TranslatableText("command.feedback.message.signature").getString());
|
||||||
embedBuilder.setColor(BotHelper.MessageType.ERROR.hexColor);
|
embedBuilder.setColor(BotHelper.MessageType.ERROR.hexColor);
|
||||||
((SlashCommandInteractionEvent)commandSource.getEvent()).deferReply(true).queue(m -> m.editOriginal(new MessageBuilder().setEmbeds(embedBuilder.build()).build()).queue());
|
// ((SlashCommandInteractionEvent)commandSource.getEvent()).deferReply(true).queue(m -> m.editOriginal(new MessageBuilder().setEmbeds(embedBuilder.build()).build()).queue());
|
||||||
} else {
|
} else {
|
||||||
commandSource.sendError(mutableText);
|
commandSource.sendError(mutableText);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@ import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
//import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.api.requests.restaction.MessageAction;
|
import net.dv8tion.jda.api.requests.restaction.MessageAction;
|
||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
//import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||||
import net.minecraft.scoreboard.Team;
|
import net.minecraft.scoreboard.Team;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
|
|
@ -40,10 +40,10 @@ public class RegisterCommand {
|
||||||
LiteralCommandNode<DiscordCommandSource> literalCommandNode = dispatcher.register(CommandManager.literal("register").requires(DiscordCommandSource::isFromGuild)
|
LiteralCommandNode<DiscordCommandSource> literalCommandNode = dispatcher.register(CommandManager.literal("register").requires(DiscordCommandSource::isFromGuild)
|
||||||
.then(CommandManager.argument("minecraft_username", StringArgumentType.word()).executes((source) -> {
|
.then(CommandManager.argument("minecraft_username", StringArgumentType.word()).executes((source) -> {
|
||||||
if (source.getSource().getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
if (source.getSource().getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
||||||
((SlashCommandInteractionEvent) source.getSource().getEvent()).deferReply().queue(m -> {
|
// ((SlashCommandInteractionEvent) source.getSource().getEvent()).deferReply().queue(m -> {
|
||||||
execute(source.getSource(), StringArgumentType.getString(source, "minecraft_username"));
|
// execute(source.getSource(), StringArgumentType.getString(source, "minecraft_username"));
|
||||||
m.deleteOriginal().queue();
|
// m.deleteOriginal().queue();
|
||||||
});
|
// });
|
||||||
} else {
|
} else {
|
||||||
execute(source.getSource(), StringArgumentType.getString(source, "minecraft_username"));
|
execute(source.getSource(), StringArgumentType.getString(source, "minecraft_username"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import com.awakenedredstone.autowhitelist.discord.api.command.DiscordCommandSour
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
//import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -47,7 +47,7 @@ public class BotStatusCommand {
|
||||||
|
|
||||||
embedBuilder.addField("Discord timings", output, false);
|
embedBuilder.addField("Discord timings", output, false);
|
||||||
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
||||||
((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
// ((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ import com.awakenedredstone.autowhitelist.discord.api.text.TranslatableText;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
//import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
//import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.PlayerManager;
|
import net.minecraft.server.PlayerManager;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
|
|
@ -69,7 +69,7 @@ public class ServerStatusCommand {
|
||||||
embedBuilder.addField("Server information", serverInformation.toString(), true);
|
embedBuilder.addField("Server information", serverInformation.toString(), true);
|
||||||
|
|
||||||
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
||||||
((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
// ((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,10 @@ package com.awakenedredstone.autowhitelist.discord.commands.developer;
|
||||||
import com.awakenedredstone.autowhitelist.AutoWhitelist;
|
import com.awakenedredstone.autowhitelist.AutoWhitelist;
|
||||||
import com.awakenedredstone.autowhitelist.discord.api.command.CommandManager;
|
import com.awakenedredstone.autowhitelist.discord.api.command.CommandManager;
|
||||||
import com.awakenedredstone.autowhitelist.discord.api.command.DiscordCommandSource;
|
import com.awakenedredstone.autowhitelist.discord.api.command.DiscordCommandSource;
|
||||||
import com.awakenedredstone.autowhitelist.lang.TranslatableText;
|
|
||||||
import com.awakenedredstone.autowhitelist.util.Debugger;
|
import com.awakenedredstone.autowhitelist.util.Debugger;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
//import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
|
||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
@ -61,7 +57,7 @@ public class StatusCommand {
|
||||||
|
|
||||||
embedBuilder.addField("Processing timings", output2.toString(), true);
|
embedBuilder.addField("Processing timings", output2.toString(), true);
|
||||||
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
||||||
((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
// ((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ import com.awakenedredstone.autowhitelist.discord.api.text.TranslatableText;
|
||||||
import com.awakenedredstone.autowhitelist.discord.api.util.Formatting;
|
import com.awakenedredstone.autowhitelist.discord.api.util.Formatting;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
//import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
//import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
//import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||||
|
|
||||||
import static com.awakenedredstone.autowhitelist.discord.Bot.jda;
|
import static com.awakenedredstone.autowhitelist.discord.Bot.jda;
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class TestCommand {
|
||||||
description += "\n" + new LiteralText("Test complete, I think.").markdownFormatted();
|
description += "\n" + new LiteralText("Test complete, I think.").markdownFormatted();
|
||||||
embedBuilder.setDescription(description);
|
embedBuilder.setDescription(description);
|
||||||
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
||||||
((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
// ((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@ import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||||
import com.mojang.brigadier.tree.CommandNode;
|
import com.mojang.brigadier.tree.CommandNode;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
//import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
//import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
//import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
//import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
//import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@ public class HelpCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
||||||
((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
// ((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +75,7 @@ public class HelpCommand {
|
||||||
embedBuilder.appendDescription(new LiteralText("`" + AutoWhitelist.getConfigData().prefix + result + "` | ").append(new TranslatableText("command.description." + result)).getString());
|
embedBuilder.appendDescription(new LiteralText("`" + AutoWhitelist.getConfigData().prefix + result + "` | ").append(new TranslatableText("command.description." + result)).getString());
|
||||||
}
|
}
|
||||||
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
||||||
((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
// ((SlashCommandInteractionEvent)source.getEvent()).replyEmbeds(embedBuilder.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
source.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import com.awakenedredstone.autowhitelist.discord.api.text.TranslatableText;
|
||||||
import com.awakenedredstone.autowhitelist.discord.api.util.Formatting;
|
import com.awakenedredstone.autowhitelist.discord.api.util.Formatting;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
//import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||||
|
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
|
|
@ -24,12 +24,12 @@ public class PingCommand {
|
||||||
|
|
||||||
public static void execute(DiscordCommandSource source) {
|
public static void execute(DiscordCommandSource source) {
|
||||||
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
if (source.getType() == DiscordCommandSource.CommandType.SLASH_COMMAND) {
|
||||||
((SlashCommandInteractionEvent)source.getEvent()).deferReply().queue(r -> {
|
/*((SlashCommandInteractionEvent)source.getEvent()).deferReply().queue(r -> {
|
||||||
r.editOriginal("Ping: ...").queue(m -> {
|
r.editOriginal("Ping: ...").queue(m -> {
|
||||||
long ping = ((SlashCommandInteractionEvent)source.getEvent()).getInteraction().getTimeCreated().until(m.getTimeCreated(), ChronoUnit.MILLIS);
|
long ping = ((SlashCommandInteractionEvent)source.getEvent()).getInteraction().getTimeCreated().until(m.getTimeCreated(), ChronoUnit.MILLIS);
|
||||||
m.editMessage("Ping: " + ping + "ms | Websocket: " + m.getJDA().getGatewayPing() + "ms").queue();
|
m.editMessage("Ping: " + ping + "ms | Websocket: " + m.getJDA().getGatewayPing() + "ms").queue();
|
||||||
});
|
});
|
||||||
});
|
});*/
|
||||||
} else {
|
} else {
|
||||||
source.getChannel().sendMessage("Ping: ...").queue(m -> {
|
source.getChannel().sendMessage("Ping: ...").queue(m -> {
|
||||||
long ping = source.getMessage().getTimeCreated().until(m.getTimeCreated(), ChronoUnit.MILLIS);
|
long ping = source.getMessage().getTimeCreated().until(m.getTimeCreated(), ChronoUnit.MILLIS);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.awakenedredstone.autowhitelist.discord.events;
|
||||||
|
|
||||||
import com.awakenedredstone.autowhitelist.AutoWhitelist;
|
import com.awakenedredstone.autowhitelist.AutoWhitelist;
|
||||||
import com.awakenedredstone.autowhitelist.discord.DiscordDataProcessor;
|
import com.awakenedredstone.autowhitelist.discord.DiscordDataProcessor;
|
||||||
import com.awakenedredstone.autowhitelist.discord.api.AutoWhitelistAPI;
|
|
||||||
import com.awakenedredstone.autowhitelist.lang.TranslatableText;
|
import com.awakenedredstone.autowhitelist.lang.TranslatableText;
|
||||||
import com.awakenedredstone.autowhitelist.mixin.ServerConfigEntryMixin;
|
import com.awakenedredstone.autowhitelist.mixin.ServerConfigEntryMixin;
|
||||||
import com.awakenedredstone.autowhitelist.util.ExtendedGameProfile;
|
import com.awakenedredstone.autowhitelist.util.ExtendedGameProfile;
|
||||||
|
|
@ -10,7 +9,10 @@ import com.awakenedredstone.autowhitelist.util.FailedToUpdateWhitelistException;
|
||||||
import com.awakenedredstone.autowhitelist.util.InvalidTeamNameException;
|
import com.awakenedredstone.autowhitelist.util.InvalidTeamNameException;
|
||||||
import com.awakenedredstone.autowhitelist.whitelist.ExtendedWhitelist;
|
import com.awakenedredstone.autowhitelist.whitelist.ExtendedWhitelist;
|
||||||
import com.awakenedredstone.autowhitelist.whitelist.ExtendedWhitelistEntry;
|
import com.awakenedredstone.autowhitelist.whitelist.ExtendedWhitelistEntry;
|
||||||
|
import com.mojang.brigadier.arguments.*;
|
||||||
|
import com.mojang.brigadier.tree.ArgumentCommandNode;
|
||||||
import com.mojang.brigadier.tree.CommandNode;
|
import com.mojang.brigadier.tree.CommandNode;
|
||||||
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
import net.dv8tion.jda.api.entities.User;
|
import net.dv8tion.jda.api.entities.User;
|
||||||
|
|
@ -19,10 +21,9 @@ import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||||
import net.dv8tion.jda.api.hooks.SubscribeEvent;
|
import net.dv8tion.jda.api.hooks.SubscribeEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.Command;
|
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
|
||||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
//import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||||
import net.minecraft.scoreboard.Scoreboard;
|
import net.minecraft.scoreboard.Scoreboard;
|
||||||
import net.minecraft.scoreboard.Team;
|
import net.minecraft.scoreboard.Team;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
@ -30,14 +31,11 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static com.awakenedredstone.autowhitelist.discord.Bot.*;
|
import static com.awakenedredstone.autowhitelist.discord.Bot.*;
|
||||||
import static com.awakenedredstone.autowhitelist.discord.Bot.whitelistDataMap;
|
|
||||||
import static com.awakenedredstone.autowhitelist.util.Debugger.analyzeTimings;
|
import static com.awakenedredstone.autowhitelist.util.Debugger.analyzeTimings;
|
||||||
|
|
||||||
public class CoreEvents {
|
public class CoreEvents {
|
||||||
|
|
@ -45,7 +43,7 @@ public class CoreEvents {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onReady(ReadyEvent e) {
|
public void onReady(ReadyEvent e) {
|
||||||
AutoWhitelist.LOGGER.info("Finishing setup.");
|
AutoWhitelist.LOGGER.info("Finishing setup.");
|
||||||
if (AutoWhitelist.getConfigData().enableSlashCommands) {
|
/*if (AutoWhitelist.getConfigData().enableSlashCommands) {
|
||||||
List<Command> commands = jda.retrieveCommands().complete();
|
List<Command> commands = jda.retrieveCommands().complete();
|
||||||
AutoWhitelistAPI.dispatcher().getRoot().getChildren().forEach(command -> {
|
AutoWhitelistAPI.dispatcher().getRoot().getChildren().forEach(command -> {
|
||||||
if (commands.stream().map(Command::getName).noneMatch(slashCommand -> slashCommand.equalsIgnoreCase(command.getName()))) {
|
if (commands.stream().map(Command::getName).noneMatch(slashCommand -> slashCommand.equalsIgnoreCase(command.getName()))) {
|
||||||
|
|
@ -53,8 +51,8 @@ public class CoreEvents {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).queue());
|
jSlashCommandDatada.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).queue());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (scheduledUpdate != null) {
|
if (scheduledUpdate != null) {
|
||||||
scheduledUpdate.cancel(false);
|
scheduledUpdate.cancel(false);
|
||||||
|
|
@ -152,8 +150,28 @@ public class CoreEvents {
|
||||||
if (command.getRedirect() != null) {
|
if (command.getRedirect() != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CommandDataImpl commandData = new CommandDataImpl(command.getName().toLowerCase(), new TranslatableText("command.description." + command.getName()).getString());
|
// CommandDataImpl commandData = new CommandDataImpl(command.getName().toLowerCase(), new TranslatableText("command.description." + command.getName()).getString());
|
||||||
command.getChildren().forEach(node -> commandData.addOptions(new OptionData(OptionType.STRING, node.getName(), new TranslatableText("command.description." + command.getName() + "." + node.getName()).getString())));
|
boolean required = command.getCommand() == null;
|
||||||
//jda.upsertCommand(commandData).queue();
|
command.getChildren().forEach(node -> {
|
||||||
|
if (node instanceof LiteralCommandNode) {
|
||||||
|
// commandData.addOptions(new OptionData(OptionType.SUB_COMMAND, node.getName(), new TranslatableText("command.description." + command.getName() + "." + node.getName()).getString(), required));
|
||||||
|
}
|
||||||
|
else if (node instanceof ArgumentCommandNode node1) {
|
||||||
|
OptionType type;
|
||||||
|
ArgumentType<?> type1 = node1.getType();
|
||||||
|
if (type1 instanceof BoolArgumentType) {
|
||||||
|
type = OptionType.BOOLEAN;
|
||||||
|
} else if (type1 instanceof DoubleArgumentType || type1 instanceof FloatArgumentType) {
|
||||||
|
type = OptionType.NUMBER;
|
||||||
|
} else if (type1 instanceof IntegerArgumentType || type1 instanceof LongArgumentType) {
|
||||||
|
type = OptionType.INTEGER;
|
||||||
|
} else {
|
||||||
|
type = OptionType.STRING;
|
||||||
|
}
|
||||||
|
// commandData.addOptions(new OptionData(type, node.getName(), new TranslatableText("command.description." + command.getName() + "." + node.getName()).getString(), required));
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
// jda.upsertCommand(commandData).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import com.awakenedredstone.autowhitelist.AutoWhitelist;
|
||||||
import com.awakenedredstone.autowhitelist.discord.api.AutoWhitelistAPI;
|
import com.awakenedredstone.autowhitelist.discord.api.AutoWhitelistAPI;
|
||||||
import com.awakenedredstone.autowhitelist.discord.api.command.DiscordCommandSource;
|
import com.awakenedredstone.autowhitelist.discord.api.command.DiscordCommandSource;
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
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 net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.hooks.SubscribeEvent;
|
import net.dv8tion.jda.api.hooks.SubscribeEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
import net.dv8tion.jda.api.interactions.commands.OptionMapping;
|
||||||
|
|
@ -29,7 +29,7 @@ public class GatewayEvents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
/*@SubscribeEvent
|
||||||
public void onSlashCommand(SlashCommandInteractionEvent event) {
|
public void onSlashCommand(SlashCommandInteractionEvent event) {
|
||||||
String command = "/".concat(event.getName()).concat(event.getOptions().stream().map(OptionMapping::getAsString).map(v -> " " + v).collect(Collectors.joining()));
|
String command = "/".concat(event.getName()).concat(event.getOptions().stream().map(OptionMapping::getAsString).map(v -> " " + v).collect(Collectors.joining()));
|
||||||
if (event.isFromGuild()) {
|
if (event.isFromGuild()) {
|
||||||
|
|
@ -37,5 +37,5 @@ public class GatewayEvents {
|
||||||
} else {
|
} else {
|
||||||
AutoWhitelistAPI.INSTANCE.getCommandManager().execute(new DiscordCommandSource(event.getUser(), null, event.getChannel(), DiscordCommandSource.CommandType.SLASH_COMMAND, event), command);
|
AutoWhitelistAPI.INSTANCE.getCommandManager().execute(new DiscordCommandSource(event.getUser(), null, event.getChannel(), DiscordCommandSource.CommandType.SLASH_COMMAND, event), command);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Referência em uma nova issue