From f5b9447c473bcd67a12aa2959e57d2a9f1183c95 Mon Sep 17 00:00:00 2001 From: William M Date: Wed, 5 Jun 2024 23:22:37 +0800 Subject: [PATCH] Account for text-based channels other than text channels when handling commands --- pom.xml | 2 +- src/main/java/com/cominatyou/TextCommandHandler.java | 5 ++++- src/main/java/com/cominatyou/util/versioning/Version.java | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 741934d..2e49f00 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.cominatyou hildabot - 2.6.1 + 2.6.2 hildabot https://github.com/CominAtYou/Hildabot diff --git a/src/main/java/com/cominatyou/TextCommandHandler.java b/src/main/java/com/cominatyou/TextCommandHandler.java index 1b25cf4..ed1ace8 100644 --- a/src/main/java/com/cominatyou/TextCommandHandler.java +++ b/src/main/java/com/cominatyou/TextCommandHandler.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Map; import com.cominatyou.commands.*; @@ -14,6 +15,8 @@ import org.javacord.api.event.message.MessageCreateEvent; public class TextCommandHandler { + private static final List textChannelTypes = Arrays.asList(ChannelType.getTextChannelTypes()); + // Commands that can be run in both private channels and guild text channels private static final Map sharedCommands = Map.ofEntries( entry("levelalert", new LevelAlert()), @@ -51,7 +54,7 @@ public static void getCommand(MessageCreateEvent event) { if (sharedCommands.containsKey(command)) { sharedCommands.get(command).execute(event, messageArgs); } - else if (event.getChannel().getType() == ChannelType.SERVER_TEXT_CHANNEL && guildCommands.containsKey(command)) { + else if (textChannelTypes.contains(event.getChannel().getType()) && guildCommands.containsKey(command)) { guildCommands.get(command).execute(event, messageArgs); } } diff --git a/src/main/java/com/cominatyou/util/versioning/Version.java b/src/main/java/com/cominatyou/util/versioning/Version.java index 2711a69..0198895 100644 --- a/src/main/java/com/cominatyou/util/versioning/Version.java +++ b/src/main/java/com/cominatyou/util/versioning/Version.java @@ -1,7 +1,7 @@ package com.cominatyou.util.versioning; public class Version { - public static final String VERSION = "2.6.1"; - public static final String BUILD_NUMBER = "11G047"; + public static final String VERSION = "2.6.2"; + public static final String BUILD_NUMBER = "11G048"; public static final String VERSION_STRING = String.format("%s (%s)", VERSION, BUILD_NUMBER); }