mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-06 01:11:04 +00:00
[AB-358] upgrading to JDA 5
removal of jda-utils adding message context commands [AB-360] fixing confirmation buttons being triggered by somebody not the author
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>abstracto-modules</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.3.14-SNAPSHOT</version>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.3.14-SNAPSHOT</version>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -19,10 +19,7 @@ import dev.sheldan.abstracto.remind.service.management.ReminderManagementService
|
||||
import dev.sheldan.abstracto.scheduling.model.JobParameters;
|
||||
import dev.sheldan.abstracto.scheduling.service.SchedulerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -133,7 +130,7 @@ public class RemindServiceBean implements ReminderService {
|
||||
reminderId, channel.getId(), server.getId(), reminderToRemindFor.getRemindedUser().getUserReference().getId());
|
||||
Optional<Guild> guildToAnswerIn = guildService.getGuildByIdOptional(server.getId());
|
||||
if(guildToAnswerIn.isPresent()) {
|
||||
Optional<TextChannel> channelToAnswerIn = channelService.getTextChannelFromServerOptional(server.getId(), channel.getId());
|
||||
Optional<GuildMessageChannel> channelToAnswerIn = channelService.getMessageChannelFromServerOptional(server.getId(), channel.getId());
|
||||
// only send the message if the channel still exists, if not, only set the reminder to reminded.
|
||||
if(channelToAnswerIn.isPresent()) {
|
||||
memberService.getMemberInServerAsync(server.getId(), reminderToRemindFor.getRemindedUser().getUserReference().getId()).thenAccept(member ->
|
||||
@@ -150,7 +147,7 @@ public class RemindServiceBean implements ReminderService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public CompletableFuture<Void> sendReminderText(Long reminderId, TextChannel channelToAnswerIn, Member member) {
|
||||
public CompletableFuture<Void> sendReminderText(Long reminderId, GuildMessageChannel channelToAnswerIn, Member member) {
|
||||
Reminder reminder = reminderManagementService.loadReminder(reminderId);
|
||||
log.debug("Sending remind message for reminder {} to user user {} in server {}.", reminderId, member.getIdLong(), member.getGuild().getIdLong());
|
||||
ExecutedReminderModel build = ExecutedReminderModel
|
||||
|
||||
@@ -16,10 +16,7 @@ import dev.sheldan.abstracto.scheduling.model.JobParameters;
|
||||
import dev.sheldan.abstracto.scheduling.service.SchedulerService;
|
||||
import dev.sheldan.abstracto.core.templating.model.MessageToSend;
|
||||
import dev.sheldan.abstracto.core.templating.service.TemplateService;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -73,7 +70,7 @@ public class RemindServiceBeanTest {
|
||||
private Message message;
|
||||
|
||||
@Mock
|
||||
private TextChannel channel;
|
||||
private GuildMessageChannel channel;
|
||||
|
||||
@Mock
|
||||
private ScheduledExecutorService instantReminderScheduler;
|
||||
@@ -155,7 +152,7 @@ public class RemindServiceBeanTest {
|
||||
when(reminderManagementService.loadReminder(REMINDER_ID)).thenReturn(remindedReminder);
|
||||
Guild guildMock = Mockito.mock(Guild.class);
|
||||
when(guildService.getGuildByIdOptional(SERVER_ID)).thenReturn(Optional.of(guildMock));
|
||||
when(channelService.getTextChannelFromServerOptional(SERVER_ID, CHANNEL_ID)).thenReturn(Optional.of(channel));
|
||||
when(channelService.getMessageChannelFromServerOptional(SERVER_ID, CHANNEL_ID)).thenReturn(Optional.of(channel));
|
||||
Member mockedMember = Mockito.mock(Member.class);
|
||||
when(memberService.getMemberInServerAsync(SERVER_ID, USER_ID)).thenReturn(CompletableFuture.completedFuture(mockedMember));
|
||||
testUnit.executeReminder(REMINDER_ID);
|
||||
@@ -174,7 +171,7 @@ public class RemindServiceBeanTest {
|
||||
when(guildService.getGuildByIdOptional(SERVER_ID)).thenReturn(Optional.of(guildMock));
|
||||
when(aUserInAServer.getUserReference()).thenReturn(user);
|
||||
when(remindedReminder.getRemindedUser()).thenReturn(aUserInAServer);
|
||||
when(channelService.getTextChannelFromServerOptional(SERVER_ID, CHANNEL_ID)).thenReturn(Optional.empty());
|
||||
when(channelService.getMessageChannelFromServerOptional(SERVER_ID, CHANNEL_ID)).thenReturn(Optional.empty());
|
||||
testUnit.executeReminder(REMINDER_ID);
|
||||
verify(reminderManagementService, times(1)).setReminded(remindedReminder);
|
||||
verify(self, times(0)).sendReminderText(anyLong(), any(), any(Member.class));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<artifactId>remind</artifactId>
|
||||
<groupId>dev.sheldan.abstracto.modules</groupId>
|
||||
<version>1.3.14-SNAPSHOT</version>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user