From 18f7599fbcdd7b28489c63effa9985026110c3d8 Mon Sep 17 00:00:00 2001 From: Shawiiz_z Date: Sun, 7 Feb 2021 13:20:00 +0100 Subject: [PATCH 1/3] Send timings in PM when possible. --- .../org/yatopiamc/bot/timings/TimingsMessageListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java b/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java index 15ee723..9ef3d5b 100644 --- a/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java +++ b/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java @@ -314,7 +314,9 @@ private void checkMinecraftVersion(EmbedBuilder embedBuilder, JsonObject timings private CompletableFuture inProgress(Message message) { CompletableFuture future = new CompletableFuture<>(); - message.reply(new EmbedBuilder().setTitle("Query in progress").build()).queue(future::complete, future::completeExceptionally); + message.delete().queueAfter(2, TimeUnit.SECONDS); + EmbedBuilder c = new EmbedBuilder().setTitle("Query in progress"); + message.getAuthor().openPrivateChannel().flatMap((channel) -> channel.sendMessage(c.build())).onErrorFlatMap((error) -> message.reply(c.build())).queue(future::complete, future::completeExceptionally); return future; } } From 5f3c7304fec33d7a18bb5e5a6b7f444fc337087b Mon Sep 17 00:00:00 2001 From: Shawiiz_z Date: Sun, 7 Feb 2021 13:24:04 +0100 Subject: [PATCH 2/3] It's not really useful to reply to a deleted message --- .../java/org/yatopiamc/bot/timings/TimingsMessageListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java b/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java index 9ef3d5b..d4e4282 100644 --- a/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java +++ b/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java @@ -316,7 +316,7 @@ private CompletableFuture inProgress(Message message) { CompletableFuture future = new CompletableFuture<>(); message.delete().queueAfter(2, TimeUnit.SECONDS); EmbedBuilder c = new EmbedBuilder().setTitle("Query in progress"); - message.getAuthor().openPrivateChannel().flatMap((channel) -> channel.sendMessage(c.build())).onErrorFlatMap((error) -> message.reply(c.build())).queue(future::complete, future::completeExceptionally); + message.getAuthor().openPrivateChannel().flatMap((channel) -> channel.sendMessage(c.build())).onErrorFlatMap((error) -> message.getChannel().sendMessage(c.build())).queue(future::complete, future::completeExceptionally); return future; } } From 24fd44c2e4fac3811686b1c1792faeabeb8bd79f Mon Sep 17 00:00:00 2001 From: Shawiiz_z Date: Sun, 7 Feb 2021 13:26:14 +0100 Subject: [PATCH 3/3] Actually it's better to just not delete the message --- .../java/org/yatopiamc/bot/timings/TimingsMessageListener.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java b/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java index d4e4282..81d0297 100644 --- a/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java +++ b/src/main/java/org/yatopiamc/bot/timings/TimingsMessageListener.java @@ -314,9 +314,8 @@ private void checkMinecraftVersion(EmbedBuilder embedBuilder, JsonObject timings private CompletableFuture inProgress(Message message) { CompletableFuture future = new CompletableFuture<>(); - message.delete().queueAfter(2, TimeUnit.SECONDS); EmbedBuilder c = new EmbedBuilder().setTitle("Query in progress"); - message.getAuthor().openPrivateChannel().flatMap((channel) -> channel.sendMessage(c.build())).onErrorFlatMap((error) -> message.getChannel().sendMessage(c.build())).queue(future::complete, future::completeExceptionally); + message.getAuthor().openPrivateChannel().flatMap((channel) -> channel.sendMessage(c.build())).onErrorFlatMap((error) -> message.reply(c.build())).queue(future::complete, future::completeExceptionally); return future; } }