Skip to content

Commit efa1cb7

Browse files
Merge pull request #268 from Java-Discord/dynxsty/fix_help_ping
Fixed (and Improved) `/help-ping`
2 parents 0a10bee + babbfc2 commit efa1cb7

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package net.javadiscord.javabot.systems.help.commands;
22

3-
import net.dv8tion.jda.api.entities.Guild;
4-
import net.dv8tion.jda.api.entities.Member;
3+
import net.dv8tion.jda.api.EmbedBuilder;
4+
import net.dv8tion.jda.api.entities.*;
55
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
66
import net.dv8tion.jda.api.requests.restaction.interactions.ReplyCallbackAction;
77
import net.javadiscord.javabot.Bot;
@@ -10,6 +10,7 @@
1010
import net.javadiscord.javabot.command.interfaces.SlashCommand;
1111
import net.javadiscord.javabot.systems.help.HelpChannelManager;
1212

13+
import java.util.EnumSet;
1314
import java.util.Map;
1415
import java.util.concurrent.ConcurrentHashMap;
1516
import java.util.concurrent.TimeUnit;
@@ -52,11 +53,20 @@ public ReplyCallbackAction handleSlashCommandInteraction(SlashCommandInteraction
5253
return Responses.warning(event, "Sorry, but you can only use this command occasionally. Please try again later.");
5354
}
5455
lastPingTimes.put(event.getMember(), System.currentTimeMillis());
55-
var role = channelManager.getConfig().getHelpPingRole();
56-
event.getChannel().sendMessage(role.getAsMention()).queue();
57-
return event.replyFormat("Done!").setEphemeral(true);
56+
Role role = channelManager.getConfig().getHelpPingRole();
57+
event.getChannel().sendMessage(role.getAsMention())
58+
.allowedMentions(EnumSet.of(Message.MentionType.ROLE))
59+
.setEmbeds(this.buildAuthorEmbed(event.getUser()))
60+
.queue();
61+
return event.replyFormat("Successfully pinged " + role.getAsMention()).setEphemeral(true);
5862
} else {
5963
return Responses.warning(event, WRONG_CHANNEL_MSG);
6064
}
6165
}
66+
67+
private MessageEmbed buildAuthorEmbed(User author) {
68+
return new EmbedBuilder()
69+
.setTitle("Requested by " + author.getAsTag())
70+
.build();
71+
}
6272
}

0 commit comments

Comments
 (0)