Skip to content

Commit c9d6cc7

Browse files
authored
Merge pull request #429 from danthe1st/help-ack-timestamps
add timestamp to acknowledging help notifications
2 parents c0e3a44 + 95c3847 commit c9d6cc7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/main/java/net/javadiscord/javabot/listener/HugListener.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package net.javadiscord.javabot.listener;
22

33
import lombok.RequiredArgsConstructor;
4-
import net.dv8tion.jda.api.entities.Message;
5-
import net.dv8tion.jda.api.entities.Webhook;
64
import net.dv8tion.jda.api.entities.channel.ChannelType;
75
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
86
import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildChannel;

src/main/java/net/javadiscord/javabot/systems/help/commands/HelpPingSubcommand.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
1515
import net.dv8tion.jda.api.interactions.components.buttons.Button;
1616
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
17+
import net.dv8tion.jda.api.utils.TimeFormat;
1718
import net.javadiscord.javabot.annotations.AutoDetectableComponentHandler;
1819
import net.javadiscord.javabot.data.config.BotConfig;
1920
import net.javadiscord.javabot.data.config.GuildConfig;
@@ -26,6 +27,7 @@
2627
import xyz.dynxsty.dih4jda.util.ComponentIdBuilder;
2728

2829
import java.awt.Color;
30+
import java.time.Instant;
2931
import java.time.OffsetDateTime;
3032
import java.util.List;
3133
import java.util.Map;
@@ -53,7 +55,7 @@ public class HelpPingSubcommand extends SlashCommand.Subcommand implements Butto
5355
* @param botConfig The main configuration of the bot
5456
*/
5557
public HelpPingSubcommand(BotConfig botConfig, ScheduledExecutorService asyncPool) {
56-
setCommandData(new SubcommandData("ping", "Notify those with the help-ping role that your question is urgent."));
58+
setCommandData(new SubcommandData("ping", "Notify potential helpers that your question is urgent."));
5759
lastPingTimes = new ConcurrentHashMap<>();
5860
this.botConfig = botConfig;
5961
asyncPool.scheduleWithFixedDelay(this::cleanTimeoutCache, CACHE_CLEANUP_DELAY, CACHE_CLEANUP_DELAY, TimeUnit.SECONDS);
@@ -214,14 +216,18 @@ private void acknowledgeChangeAction(ButtonInteractionEvent event, boolean ackno
214216
.stream()
215217
.map(e->new EmbedBuilder(e)
216218
.setColor(acknowledged ? Color.GRAY : Color.YELLOW)
217-
.addField("marked as " + (acknowledged?"acknowledged":"needs help") + " by",
218-
event.getUser().getAsMention(), false))
219+
.addField("marked as " + (acknowledged?"acknowledged":"needs help"),
220+
"by " + event.getUser().getAsMention()+" "+getCurrentFormattedTimestamp(), false))
219221
.map(this::removeOldField)
220222
.map(EmbedBuilder::build)
221223
.toList())
222224
.setActionRow(acknowledged?createUndoAcknowledgementButton():createAcknowledgementButton())
223225
.queue();
224226
}
227+
228+
private String getCurrentFormattedTimestamp() {
229+
return TimeFormat.RELATIVE.format(Instant.now().toEpochMilli());
230+
}
225231

226232
private String getForumTagText(ForumTag tag) {
227233
EmojiUnion emoji = tag.getEmoji();

0 commit comments

Comments
 (0)