Skip to content

Commit

Permalink
Fix errors with webhook in some cases (closes #105 + slash command wi…
Browse files Browse the repository at this point in the history
…th relay bot messages)
  • Loading branch information
DenisD3D committed May 28, 2024
1 parent 224aef7 commit 3ad69d2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ public static void onMessageCreate(MessageCreateEvent event) {
if (event.getMessage().getWebhookId().isPresent()) { // Webhook messages
if (!Mc2Discord.INSTANCE.config.misc.relay_bot_messages) return; // No bot messages

if (event.getMessage().getWebhook().blockOptional().flatMap(Webhook::getName).orElse("").equals(Mc2Discord.INSTANCE.vars.mc2discord_webhook_name))
return; // Self messages
if (Objects.equals(event.getMessage().getWebhook().map(Webhook::getName).onErrorResume(throwable -> Mono.just(Optional.of(Mc2Discord.INSTANCE.vars.mc2discord_webhook_name)))
.map(name -> name.orElse(""))
.block(), Mc2Discord.INSTANCE.vars.mc2discord_webhook_name))
return; // Self messages or slash commands

if (event.getMember().isEmpty())
return;

if (Mc2Discord.INSTANCE.config.channels.channels.stream().filter(channel -> channel.subscriptions.contains("chat") || channel.subscriptions.contains("discord")).anyMatch(channel -> channel.channel_id.equals(event.getMessage().getChannelId()))) { // Chat or Discord
processMessage(event, event.getMember().get());
Expand Down

0 comments on commit 3ad69d2

Please sign in to comment.