Skip to content

Commit

Permalink
ignore messages from other channels
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyagara committed Sep 23, 2024
1 parent 1ea43ed commit 43b1729
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/cooptweaks/discord/Discord.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public static Discord getInstance() {

private static MinecraftServer SERVER;
private static GatewayDiscordClient GATEWAY;

private static Snowflake BOT_USER_ID;
private static Snowflake CHANNEL_ID;

private static RestChannel CHANNEL;

/** Slash commands. */
Expand Down Expand Up @@ -138,6 +141,7 @@ public void Start(ConfigMap config) {
.filter(Objects::nonNull)
.doOnNext(channel -> {
CHANNEL = channel;
CHANNEL_ID = channel.getId();
BOT_READY.set(true);

// Process queued events now that the bot is ready.
Expand Down Expand Up @@ -195,6 +199,12 @@ private void onMessage(MessageCreateEvent event) {
}

Message message = event.getMessage();

// Ignore messages from other channels.
if (!message.getChannelId().equals(CHANNEL_ID)) {
return;
}

Optional<User> author = message.getAuthor();

if (author.isEmpty()) {
Expand Down

0 comments on commit 43b1729

Please sign in to comment.