Skip to content

Commit 4b4fdd5

Browse files
committed
Update JDA and remove a lot of unused old features
Signed-off-by: KiriCattus <19393068+KiriCattus@users.noreply.github.com>
1 parent 12c2c1b commit 4b4fdd5

File tree

67 files changed

+30
-6695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+30
-6695
lines changed

src/commander/java/com/mcmoddev/mmdbot/commander/TheCommander.java

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,10 @@
2929
import com.mcmoddev.mmdbot.commander.annotation.RegisterSlashCommand;
3030
import com.mcmoddev.mmdbot.commander.cfwebhooks.CFProjects;
3131
import com.mcmoddev.mmdbot.commander.cfwebhooks.CurseForgeManager;
32-
import com.mcmoddev.mmdbot.commander.commands.EvaluateCommand;
33-
import com.mcmoddev.mmdbot.commander.commands.GistCommand;
34-
import com.mcmoddev.mmdbot.commander.commands.RoleSelectCommand;
3532
import com.mcmoddev.mmdbot.commander.commands.curseforge.CurseForgeCommand;
36-
import com.mcmoddev.mmdbot.commander.commands.menu.message.GistContextMenu;
37-
import com.mcmoddev.mmdbot.commander.commands.menu.user.UserInfoContextMenu;
3833
import com.mcmoddev.mmdbot.commander.config.Configuration;
3934
import com.mcmoddev.mmdbot.commander.config.GuildConfiguration;
4035
import com.mcmoddev.mmdbot.commander.config.PermissionList;
41-
import com.mcmoddev.mmdbot.commander.docs.ConfigBasedElementLoader;
42-
import com.mcmoddev.mmdbot.commander.docs.DocsCommand;
43-
import com.mcmoddev.mmdbot.commander.docs.NormalDocsSender;
44-
import com.mcmoddev.mmdbot.commander.eventlistener.ReferencingListener;
4536
import com.mcmoddev.mmdbot.commander.updatenotifiers.UpdateNotifiers;
4637
import com.mcmoddev.mmdbot.commander.util.EventListeners;
4738
import com.mcmoddev.mmdbot.commander.util.mc.MCVersions;
@@ -63,10 +54,8 @@
6354
import com.mcmoddev.mmdbot.core.util.Utils;
6455
import com.mcmoddev.mmdbot.core.util.config.ConfigurateUtils;
6556
import com.mcmoddev.mmdbot.core.util.config.SnowflakeValue;
66-
import com.mcmoddev.mmdbot.core.util.dictionary.DictionaryUtils;
6757
import com.mcmoddev.mmdbot.core.util.event.DismissListener;
6858
import com.mcmoddev.mmdbot.core.util.event.OneTimeEventListener;
69-
import de.ialistannen.javadocapi.querying.FuzzyElementQuery;
7059
import io.github.cdimascio.dotenv.Dotenv;
7160
import io.github.matyrobbrt.curseforgeapi.CurseForgeAPI;
7261
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
@@ -77,7 +66,7 @@
7766
import net.dv8tion.jda.api.Permission;
7867
import net.dv8tion.jda.api.entities.Guild;
7968
import net.dv8tion.jda.api.entities.Message;
80-
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
69+
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
8170
import net.dv8tion.jda.api.entities.emoji.Emoji;
8271
import net.dv8tion.jda.api.events.Event;
8372
import net.dv8tion.jda.api.events.session.ReadyEvent;
@@ -145,12 +134,6 @@ public TheCommander createBot(final Path runPath) {
145134

146135
.writeComment("The API key to use for CurseForge requests: ")
147136
.writeValue("CF_API_KEY", "")
148-
149-
.writeComment("The OwlBot API Token used for dictionary lookup:")
150-
.writeValue("OWL_BOT_TOKEN", "")
151-
152-
.writeComment("The token used for GitHub requests. (Mainly for creating gists)")
153-
.writeValue("GITHUB_TOKEN", "")
154137
)
155138
.load());
156139
} catch (IOException e) {
@@ -175,11 +158,6 @@ public Logger getLogger() {
175158
GatewayIntent.MESSAGE_CONTENT
176159
);
177160

178-
private static final Set<Message.MentionType> DEFAULT_MENTIONS = EnumSet.of(
179-
Message.MentionType.EMOJI,
180-
Message.MentionType.CHANNEL
181-
);
182-
183161
private static final Set<Permission> PERMISSIONS = EnumSet.of(
184162
Permission.MESSAGE_MANAGE,
185163
Permission.MANAGE_WEBHOOKS,
@@ -256,14 +234,9 @@ public static ComponentListener.Builder getComponentListener(final String featur
256234
private final Path runPath;
257235
private final Long2ObjectMap<GuildConfiguration> guildConfigs = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<>());
258236

259-
private final String githubToken;
260-
261237
public TheCommander(final Path runPath, final Dotenv dotenv) {
262238
this.dotenv = dotenv;
263239
this.runPath = runPath;
264-
265-
DictionaryUtils.setToken(dotenv.get("OWL_BOT_TOKEN", null));
266-
githubToken = dotenv.get("GITHUB_TOKEN", "");
267240
}
268241

269242
@Override
@@ -335,8 +308,6 @@ public void start() {
335308
.setOwnerId(generalConfig.bot().getOwners().get(0).asString())
336309
.setCoOwnerIds(coOwners.toArray(String[]::new))
337310
.setPrefixes(generalConfig.bot().getPrefixes().toArray(String[]::new))
338-
.addCommands(new GistCommand(), EvaluateCommand.COMMAND)
339-
.addContextMenus(new GistContextMenu(), new UserInfoContextMenu())
340311
.setManualUpsert(true)
341312
.useHelpBuilder(false)
342313
.setActivity(null)
@@ -385,31 +356,8 @@ record SlashCommandRegistration(Object fieldValue, RegisterSlashCommand annotati
385356
generalConfig.bot().guild(), PERMISSIONS);
386357
EventListeners.COMMANDS_LISTENER.addListeners(upserter);
387358

388-
// Evaluation
389-
if (generalConfig.features().isEvaluationEnabled()) {
390-
EventListeners.COMMANDS_LISTENER.addListener(new EvaluateCommand.ModalListener());
391-
}
392-
393-
// Docs
394-
{
395-
try {
396-
final var loader = new ConfigBasedElementLoader(runPath.resolve("docs"));
397-
final var command = new DocsCommand(new FuzzyElementQuery(), loader, new NormalDocsSender(), getComponentListener("docs-cmd"));
398-
commandClient.addSlashCommand(command);
399-
} catch (Exception e) {
400-
LOGGER.error("Exception trying to load docs command! ", e);
401-
}
402-
}
403-
404359
// Button listeners
405-
EventListeners.COMMANDS_LISTENER.addListeners(new DismissListener(), RoleSelectCommand.COMMAND);
406-
407-
if (generalConfig.features().isReferencingEnabled()) {
408-
EventListeners.MISC_LISTENER.addListener(new ReferencingListener());
409-
}
410-
411-
//This was broken when Discord updated file attachments to have new values at the end and needs either fixing or removing.
412-
//EventListeners.MISC_LISTENER.addListeners(new ThreadListener(), new FilePreviewListener());
360+
EventListeners.COMMANDS_LISTENER.addListeners(new DismissListener());
413361

414362
COLLECT_TASKS_LISTENER.register(Events.MISC_BUS);
415363
CurseForgeCommand.RG_TASK_SCHEDULER_LISTENER.register(Events.MISC_BUS);
@@ -520,16 +468,12 @@ public RestAction<Message> getMessageByLink(final String link) {
520468
.map(info -> {
521469
final var guild = getJda().getGuildById(info.guildId());
522470
if (guild == null) return null;
523-
final var channel = guild.getChannelById(MessageChannel.class, info.channelId());
471+
final var channel = guild.getChannelById(GuildMessageChannel.class, info.channelId());
524472
return channel == null ? null : channel.retrieveMessageById(info.messageId());
525473
})
526474
.orElse(null);
527475
}
528476

529-
public String getGithubToken() {
530-
return githubToken;
531-
}
532-
533477
public GuildConfiguration getConfigForGuild(long guildId) {
534478
synchronized (guildConfigs) {
535479
return guildConfigs.computeIfAbsent(guildId, rethrowFunction(id -> {

0 commit comments

Comments
 (0)