update original message

This commit is contained in:
Lee 2024-07-04 02:58:29 +01:00
parent 040846ef0a
commit 2fcc1b66c1
4 changed files with 10 additions and 11 deletions

@ -159,11 +159,6 @@
<artifactId>spotify-web-api-java</artifactId>
<version>8.4.0</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.1.8</version>
</dependency>
<dependency>
<groupId>uk.co.conoregan</groupId>
<artifactId>themoviedbapi</artifactId>

@ -137,11 +137,9 @@ public class RequestSubCommand extends BatSubCommand implements EventListener {
Button.primary("drag-request-accept", "Accept"),
Button.danger("drag-request-decline", "Decline")
))
.queue(message -> {
JOIN_REQUESTS.stream()
.queue(message -> JOIN_REQUESTS.stream()
.filter(r -> r.getVoiceChannel().getId().equals(targetChannel.getId()))
.findFirst().ifPresent(request -> request.setRequestMessage(message));
});
.findFirst().ifPresent(request -> request.setRequestMessage(message)));
event.replyEmbeds(EmbedUtils.successEmbed()
.setDescription("Request to join %s's voice channel has been sent.".formatted(target.getAsMention()))
.build())

@ -28,7 +28,7 @@ public class RequestListener implements EventListener {
.findFirst();
if (optionalDragRequest.isEmpty()) {
event.replyEmbeds(EmbedUtils.errorEmbed()
.setDescription("You do not have a request to cancel.")
.setDescription("%s, you do not have a request to cancel.".formatted(user.getDiscordUser().getAsMention()))
.build()).queue();
return;
}

@ -31,6 +31,12 @@ public class TargetChannelListener implements EventListener {
if (event.getComponentId().equals("drag-request-accept")) {
joinRequest.getVoiceChannel().getGuild().moveVoiceMember(joinRequest.getMember(), joinRequest.getVoiceChannel()).queue();
joinRequest.getInteractionHook().retrieveOriginal().queue(message -> {
message.editMessageEmbeds(EmbedUtils.successEmbed()
.setDescription("%s has accepted your request to join their voice channel!".formatted(joinRequest.getTarget().getAsMention()))
.build()).queue(then -> then.delete().queueAfter(10, java.util.concurrent.TimeUnit.SECONDS));
message.editMessageComponents().queue();
});
event.replyEmbeds(EmbedUtils.successEmbed()
.setDescription("You have accepted %s's request to join your voice channel!".formatted(joinRequest.getMember().getAsMention()))
.build())