From 60644f6cbb64cebcdabfe7024869cc02919b52bf Mon Sep 17 00:00:00 2001 From: danthe1st Date: Thu, 10 Aug 2023 12:00:25 +0200 Subject: [PATCH 1/3] add timestamp to acknowledging help notifications --- .../systems/help/commands/HelpPingSubcommand.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java b/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java index ec5b26361..2959bd978 100644 --- a/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java +++ b/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java @@ -14,6 +14,7 @@ import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; import net.dv8tion.jda.api.interactions.components.buttons.Button; import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; +import net.dv8tion.jda.api.utils.TimeFormat; import net.javadiscord.javabot.annotations.AutoDetectableComponentHandler; import net.javadiscord.javabot.data.config.BotConfig; import net.javadiscord.javabot.data.config.GuildConfig; @@ -26,6 +27,7 @@ import xyz.dynxsty.dih4jda.util.ComponentIdBuilder; import java.awt.Color; +import java.time.Instant; import java.time.OffsetDateTime; import java.util.List; import java.util.Map; @@ -214,14 +216,18 @@ private void acknowledgeChangeAction(ButtonInteractionEvent event, boolean ackno .stream() .map(e->new EmbedBuilder(e) .setColor(acknowledged ? Color.GRAY : Color.YELLOW) - .addField("marked as " + (acknowledged?"acknowledged":"needs help") + " by", - event.getUser().getAsMention(), false)) + .addField("marked as " + (acknowledged?"acknowledged":"needs help"), + "by " + event.getUser().getAsMention()+" at "+getCurrentFormattedTimestamp(), false)) .map(this::removeOldField) .map(EmbedBuilder::build) .toList()) .setActionRow(acknowledged?createUndoAcknowledgementButton():createAcknowledgementButton()) .queue(); } + + private String getCurrentFormattedTimestamp() { + return TimeFormat.DATE_TIME_SHORT.format(Instant.now().toEpochMilli()); + } private String getForumTagText(ForumTag tag) { EmojiUnion emoji = tag.getEmoji(); From 6f0acaa2db1a47696300a09a41b70d495745f370 Mon Sep 17 00:00:00 2001 From: danthe1st Date: Thu, 10 Aug 2023 12:07:30 +0200 Subject: [PATCH 2/3] improve /help ping command description --- .../javabot/systems/help/commands/HelpPingSubcommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java b/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java index 2959bd978..89a5c0d53 100644 --- a/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java +++ b/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java @@ -55,7 +55,7 @@ public class HelpPingSubcommand extends SlashCommand.Subcommand implements Butto * @param botConfig The main configuration of the bot */ public HelpPingSubcommand(BotConfig botConfig, ScheduledExecutorService asyncPool) { - setCommandData(new SubcommandData("ping", "Notify those with the help-ping role that your question is urgent.")); + setCommandData(new SubcommandData("ping", "Notify potential helpers that your question is urgent.")); lastPingTimes = new ConcurrentHashMap<>(); this.botConfig = botConfig; asyncPool.scheduleWithFixedDelay(this::cleanTimeoutCache, CACHE_CLEANUP_DELAY, CACHE_CLEANUP_DELAY, TimeUnit.SECONDS); From 95c3847b919311b249a4774fdd26ac5a2782fc21 Mon Sep 17 00:00:00 2001 From: danthe1st Date: Wed, 16 Aug 2023 21:08:46 +0200 Subject: [PATCH 3/3] relative timestamps in /help ping --- .../java/net/javadiscord/javabot/listener/HugListener.java | 2 -- .../javabot/systems/help/commands/HelpPingSubcommand.java | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/javadiscord/javabot/listener/HugListener.java b/src/main/java/net/javadiscord/javabot/listener/HugListener.java index ccff2edef..c25d18dff 100644 --- a/src/main/java/net/javadiscord/javabot/listener/HugListener.java +++ b/src/main/java/net/javadiscord/javabot/listener/HugListener.java @@ -1,8 +1,6 @@ package net.javadiscord.javabot.listener; import lombok.RequiredArgsConstructor; -import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.Webhook; import net.dv8tion.jda.api.entities.channel.ChannelType; import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildChannel; diff --git a/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java b/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java index 89a5c0d53..1edf47cbd 100644 --- a/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java +++ b/src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java @@ -217,7 +217,7 @@ private void acknowledgeChangeAction(ButtonInteractionEvent event, boolean ackno .map(e->new EmbedBuilder(e) .setColor(acknowledged ? Color.GRAY : Color.YELLOW) .addField("marked as " + (acknowledged?"acknowledged":"needs help"), - "by " + event.getUser().getAsMention()+" at "+getCurrentFormattedTimestamp(), false)) + "by " + event.getUser().getAsMention()+" "+getCurrentFormattedTimestamp(), false)) .map(this::removeOldField) .map(EmbedBuilder::build) .toList()) @@ -226,7 +226,7 @@ private void acknowledgeChangeAction(ButtonInteractionEvent event, boolean ackno } private String getCurrentFormattedTimestamp() { - return TimeFormat.DATE_TIME_SHORT.format(Instant.now().toEpochMilli()); + return TimeFormat.RELATIVE.format(Instant.now().toEpochMilli()); } private String getForumTagText(ForumTag tag) {