update JDA and jda Utilities version

fixed typos in the code
This commit is contained in:
Sheldan
2020-06-28 12:04:34 +02:00
parent c44eb80fc5
commit e8767429bf
40 changed files with 106 additions and 107 deletions

View File

@@ -14,7 +14,7 @@ An example implementation of this bot can be seen [here](https://github.com/Shel
## Technologies
* [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper in the version 4.1.1_155
* [JDA](https://github.com/DV8FromTheWorld/JDA/) The Discord API Wrapper in the version 4.1.1_167
* [Spring boot](https://github.com/spring-projects/spring-boot) is used as a framework to create standalone application in Java with Java EE methods. (including Dependency injection and more)
* [Hibernate](https://github.com/hibernate/hibernate-orm) is used as a reference implementation of JPA.
* [Freemarker](https://github.com/apache/freemarker) is used as a templating engine. This is used to provide internationalization for user facing text and enable dynamic embed configuration.

View File

@@ -31,7 +31,7 @@ import java.util.List;
@Slf4j
public class LeaderBoardCommand extends AbstractConditionableCommand {
public static final String LEADERBOARD_POST_EMBED_TEMPLATE = "leaderboard_post";
public static final String LEADER_BOARD_POST_EMBED_TEMPLATE = "leaderboard_post";
@Autowired
private AUserExperienceService userExperienceService;
@@ -57,7 +57,7 @@ public class LeaderBoardCommand extends AbstractConditionableCommand {
LeaderBoardEntry userRank = userExperienceService.getRankOfUserInServer(commandContext.getUserInitiatedContext().getAUserInAServer());
leaderBoardModel.setUserExecuting(converter.fromLeaderBoardEntry(userRank));
MessageToSend messageToSend = templateService.renderEmbedTemplate(LEADERBOARD_POST_EMBED_TEMPLATE, leaderBoardModel);
MessageToSend messageToSend = templateService.renderEmbedTemplate(LEADER_BOARD_POST_EMBED_TEMPLATE, leaderBoardModel);
channelService.sendMessageToSendToChannel(messageToSend, commandContext.getChannel());
return CommandResult.fromSuccess();

View File

@@ -21,7 +21,7 @@ public interface UserExperienceRepository extends JpaRepository<AUserExperience
/**
* Finds all {@link AUserExperience} of the given {@link AServer}
* @param server The {@link AServer} to retriev ethe {@link AUserExperience} for
* @param server The {@link AServer} to retrieve ethe {@link AUserExperience} for
* @return A complete list of {@link AUserExperience} of the given {@link AServer}
*/
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
@@ -30,7 +30,7 @@ public interface UserExperienceRepository extends JpaRepository<AUserExperience
/**
* Retrieves the {@link AUserExperience} ordered by experience, and applies the {@link Pageable} to only filter out certain pages.
* @param server The {@link AServer} to retrieve the {@link AUserExperience} information for
* @param pageable A {@link Pageable} object to indicate the pages which should be retrieved, pagesize is 10
* @param pageable A {@link Pageable} object to indicate the pages which should be retrieved, page size is 10
* @return A list of {@link AUserExperience} of the given {@link AServer} ordered by the experience of the users, paginated by the given
* configuration
*/

View File

@@ -302,10 +302,10 @@ public class AUserExperienceServiceBean implements AUserExperienceService {
}
/**
* Retrieves the leaderboard data for the given page of the given server
* @param server The {@link AServer} to retrieve the leaderboard for
* @param page The desired page on the leaderboard. The pagesize is 10
* @return The {@link LeaderBoard} containing all necessary information concerning the leaderboard
* Retrieves the leader board data for the given page of the given server
* @param server The {@link AServer} to retrieve the leader board for
* @param page The desired page on the leader board. The page size is 10
* @return The {@link LeaderBoard} containing all necessary information concerning the leader board
*/
@Override
public LeaderBoard findLeaderBoardData(AServer server, Integer page) {
@@ -326,7 +326,7 @@ public class AUserExperienceServiceBean implements AUserExperienceService {
/**
* Builds an {@link AUserExperience} and loads the appropriate rank of the passed {@link AUserInAServer}
* @param userInAServer The {@link AUserInAServer} to retrieve the {@link LeaderBoardEntry} for
* @return The {@link LeaderBoardEntry} representing one single row in the leaderboard
* @return The {@link LeaderBoardEntry} representing one single row in the leader board
*/
@Override
public LeaderBoardEntry getRankOfUserInServer(AUserInAServer userInAServer) {

View File

@@ -30,10 +30,10 @@ public class ExperienceRoleServiceBean implements ExperienceRoleService {
private AUserExperienceService userExperienceService;
/**
* Unsets the current configuration for the passed level, and sets the {@link ARole} to be used for this level
* UnSets the current configuration for the passed level, and sets the {@link ARole} to be used for this level
* in the given {@link AServer}
* @param role The {@link ARole} to set the level to
* @param level The level the {@link ARole} should be awareded at
* @param level The level the {@link ARole} should be awarded at
*/
@Override
public void setRoleToLevel(ARole role, Integer level, AChannel feedbackChannel) {

View File

@@ -58,7 +58,7 @@ public class UserExperienceManagementServiceBean implements UserExperienceManage
* Creates or updates the {@link AUserExperience} object. Does not change the level or the role.
* @param user The {@link AUserInAServer} to increase the experience for
* @param experience The experience amount to increase by
* @param messageCount The amount of messags to increase the count by
* @param messageCount The amount of messages to increase the count by
* @return The created/changed {@link AUserExperience} object
*/
@Override

View File

@@ -67,7 +67,7 @@ public class LeaderBoardCommandTest {
LeaderBoardEntryModel leaderBoardEntryModel = LeaderBoardEntryModel.builder().build();
when(converter.fromLeaderBoardEntry(executingUserRank)).thenReturn(leaderBoardEntryModel);
MessageToSend messageToSend = MessageToSend.builder().build();
when(templateService.renderEmbedTemplate(eq(LeaderBoardCommand.LEADERBOARD_POST_EMBED_TEMPLATE), any(LeaderBoardModel.class))).thenReturn(messageToSend);
when(templateService.renderEmbedTemplate(eq(LeaderBoardCommand.LEADER_BOARD_POST_EMBED_TEMPLATE), any(LeaderBoardModel.class))).thenReturn(messageToSend);
CommandResult result = testUnit.execute(context);
verify(channelService, times(1)).sendMessageToSendToChannel(messageToSend, context.getChannel());
CommandTestUtilities.checkSuccessfulCompletion(result);

View File

@@ -7,14 +7,14 @@ import lombok.Setter;
import java.util.List;
/**
* Wrapper object containing a list of {@link LeaderBoardEntry} representing a leaderboard.
* Wrapper object containing a list of {@link LeaderBoardEntry} representing a leader board.
*/
@Getter
@Setter
@Builder
public class LeaderBoard {
/**
* List of {@link LeaderBoardEntry} representing the leaderboard.
* List of {@link LeaderBoardEntry} representing the leader board.
*/
private List<LeaderBoardEntry> entries;
}

View File

@@ -29,7 +29,7 @@ public interface LeaderBoardEntryResult {
Long getMessageCount();
/**
* The current position of the {@link dev.sheldan.abstracto.core.models.database.AUserInAServer} in the leaderboard
* The current position of the {@link dev.sheldan.abstracto.core.models.database.AUserInAServer} in the leader board
* ordered by experience count
*/
Integer getRank();

View File

@@ -7,7 +7,7 @@ import lombok.Setter;
import net.dv8tion.jda.api.entities.Member;
/**
* Model used in the list of members when rendering the leaderboard template. The reason this is necessary,
* Model used in the list of members when rendering the leader board template. The reason this is necessary,
* is because we need more than just the {@link AUserExperience} object, we also need the position of the user in this
* guild and the {@link Member} for convenience in the templates.
*/

View File

@@ -8,8 +8,8 @@ import lombok.experimental.SuperBuilder;
import java.util.List;
/**
* Object containing the complete information passed to the leaderboard template. It contains the leaderboard
* information of the requested page of the total users and the leaderboard information of the user executing the
* Object containing the complete information passed to the leader board template. It contains the leader board
* information of the requested page of the total users and the leader board information of the user executing the
* command.
*/
@Getter

View File

@@ -32,7 +32,7 @@ public interface ExperienceRoleService {
* Calculates the appropriate {@link AExperienceRole} based on the provided list of {@link AExperienceRole}
* @param userExperience The {@link AUserExperience} containing the level to calculate the {@link AExperienceRole}
* @param roles The role configuration to be used when calculating the appropriate {@link AExperienceRole}
* @return The best matching {@link AExperienceRole} accordign to the experience in the provided {@link AUserExperience}
* @return The best matching {@link AExperienceRole} according to the experience in the provided {@link AUserExperience}
*/
AExperienceRole calculateRole(AUserExperience userExperience, List<AExperienceRole> roles);

View File

@@ -11,7 +11,7 @@ import java.util.Optional;
public interface ExperienceLevelManagementService {
/**
* Creates the level referenced by the level and the needed experience in the database.
* @param level The unique level this level should reprsent.
* @param level The unique level this level should represent.
* @param neededExperience The total amount of experience required to reach this level.
* @return A newly created {@link AExperienceLevel} instance.
*/

View File

@@ -44,7 +44,7 @@ public interface ExperienceRoleManagementService {
AExperienceRole getRoleInServer(ARole role);
/**
* Retrives all {@link AExperienceRole} configured in the given {@link AServer}
* Retrieves all {@link AExperienceRole} configured in the given {@link AServer}
* @param server The server to retrieve the list of {@link AExperienceRole} for
* @return A list of {@link AExperienceRole} which are currently configured for the {@link AServer}
*/

View File

@@ -39,7 +39,7 @@ public interface UserExperienceManagementService {
* are not changed.
* @param user The {@link AUserInAServer} to increase the experience for
* @param experience The experience amount to increase by
* @param messageCount The amount of messags to increase the count by
* @param messageCount The amount of messages to increase the count by
* @return The changed/creates {@link AUserExperience} object containing the values.
*/
AUserExperience incrementExpForUser(AUserInAServer user, Long experience, Long messageCount);

View File

@@ -42,8 +42,8 @@ public class UnMute extends AbstractConditionableCommand {
return CommandResult.fromError(templateService.renderSimpleTemplate(NO_ACTIVE_MUTE));
}
Mute mute = muteManagementService.getAMuteOf(member);
muteService.unmuteUser(mute);
muteService.cancelUnmuteJob(mute);
muteService.unMuteUser(mute);
muteService.cancelUnMuteJob(mute);
muteService.completelyUnMuteMember(member);
return CommandResult.fromSuccess();
}

View File

@@ -23,7 +23,7 @@ public class UnMuteJob extends QuartzJobBean {
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
log.info("Executing unmute job for mute {}", muteId);
log.info("Executing unMute job for mute {}", muteId);
muteService.endMute(muteId);
}

View File

@@ -79,11 +79,11 @@ public class MuteServiceBean implements MuteService {
private ChannelManagementService channelManagementService;
public static final String MUTE_LOG_TEMPLATE = "mute_log";
public static final String UNMUTE_LOG_TEMPLATE = "unmute_log";
public static final String UN_MUTE_LOG_TEMPLATE = "unmute_log";
public static final String MUTE_NOTIFICATION_TEMPLATE = "mute_notification";
@Override
public Mute muteMember(Member memberToMute, Member mutingMember, String reason, Instant unmuteDate, Message message) {
public Mute muteMember(Member memberToMute, Member mutingMember, String reason, Instant unMuteDate, Message message) {
FullUser mutedUser = FullUser
.builder()
.aUserInAServer(userInServerManagementService.loadUser(memberToMute))
@@ -95,11 +95,11 @@ public class MuteServiceBean implements MuteService {
.aUserInAServer(userInServerManagementService.loadUser(mutingMember))
.member(mutingMember)
.build();
return muteUser(mutedUser, mutingUser, reason, unmuteDate, message);
return muteUser(mutedUser, mutingUser, reason, unMuteDate, message);
}
@Override
public Mute muteAUserInAServer(AUserInAServer userBeingMuted, AUserInAServer userMuting, String reason, Instant unmuteDate, Message message) {
public Mute muteAUserInAServer(AUserInAServer userBeingMuted, AUserInAServer userMuting, String reason, Instant unMuteDate, Message message) {
FullUser mutedUser = FullUser
.builder()
.aUserInAServer(userBeingMuted)
@@ -111,11 +111,11 @@ public class MuteServiceBean implements MuteService {
.aUserInAServer(userMuting)
.member(botService.getMemberInServer(userMuting))
.build();
return muteUser(mutedUser, mutingUser, reason, unmuteDate, message);
return muteUser(mutedUser, mutingUser, reason, unMuteDate, message);
}
@Override
public Mute muteUser(FullUser userBeingMuted, FullUser userMuting, String reason, Instant unmuteDate, Message message) {
public Mute muteUser(FullUser userBeingMuted, FullUser userMuting, String reason, Instant unMuteDate, Message message) {
AServer serverBeingMutedIn = userBeingMuted.getAUserInAServer().getServerReference();
if(!muteRoleManagementService.muteRoleForServerExists(serverBeingMutedIn)) {
log.error("Mute role for server {} has not been setup.", serverBeingMutedIn.getId());
@@ -123,7 +123,7 @@ public class MuteServiceBean implements MuteService {
}
Member memberBeingMuted = userBeingMuted.getMember();
log.info("User {} mutes user {} until {}",
memberBeingMuted.getIdLong(), userMuting.getMember().getIdLong(), unmuteDate);
memberBeingMuted.getIdLong(), userMuting.getMember().getIdLong(), unMuteDate);
if(message != null) {
log.trace("because of message {} in channel {} in server {}", message.getId(), message.getChannel().getId(), message.getGuild().getId());
} else {
@@ -132,14 +132,14 @@ public class MuteServiceBean implements MuteService {
AUserInAServer userInServerBeingMuted = userBeingMuted.getAUserInAServer();
applyMuteRole(userInServerBeingMuted);
Mute mute = createMuteObject(userMuting, reason, unmuteDate, message, userInServerBeingMuted);
Mute mute = createMuteObject(userMuting, reason, unMuteDate, message, userInServerBeingMuted);
Guild guild = memberBeingMuted.getGuild();
if(memberBeingMuted.getVoiceState() != null && memberBeingMuted.getVoiceState().getChannel() != null) {
guild.kickVoiceMember(memberBeingMuted).queue();
}
sendMuteNotification(message, memberBeingMuted, mute, guild);
String triggerKey = startUnmuteJobFor(unmuteDate, mute);
String triggerKey = startUnMuteJobFor(unMuteDate, mute);
mute.setTriggerKey(triggerKey);
muteManagementService.saveMute(mute);
return mute;
@@ -153,7 +153,7 @@ public class MuteServiceBean implements MuteService {
messageService.sendMessageToUser(memberBeingMuted.getUser(), muteNotificationMessage, textChannel);
}
private Mute createMuteObject(FullUser userMuting, String reason, Instant unmuteDate, Message message, AUserInAServer userInServerBeingMuted) {
private Mute createMuteObject(FullUser userMuting, String reason, Instant unMuteDate, Message message, AUserInAServer userInServerBeingMuted) {
AServerAChannelMessage origin = null;
if(message != null) {
long channelId = message.getChannel().getIdLong();
@@ -166,7 +166,7 @@ public class MuteServiceBean implements MuteService {
.messageId(message.getIdLong())
.build();
}
return muteManagementService.createMute(userInServerBeingMuted, userMuting.getAUserInAServer(), reason, unmuteDate, origin);
return muteManagementService.createMute(userInServerBeingMuted, userMuting.getAUserInAServer(), reason, unMuteDate, origin);
}
@Override
@@ -176,10 +176,10 @@ public class MuteServiceBean implements MuteService {
}
@Override
public String startUnmuteJobFor(Instant unmuteDate, Mute mute) {
Duration muteDuration = Duration.between(Instant.now(), unmuteDate);
public String startUnMuteJobFor(Instant unMuteDate, Mute mute) {
Duration muteDuration = Duration.between(Instant.now(), unMuteDate);
if(muteDuration.getSeconds() < 60) {
log.trace("Directly scheduling the unmute, because it was below the threshold.");
log.trace("Directly scheduling the unMute, because it was below the threshold.");
unMuteScheduler.schedule(() -> {
try {
self.endMute(mute.getId());
@@ -189,24 +189,24 @@ public class MuteServiceBean implements MuteService {
}, muteDuration.toNanos(), TimeUnit.NANOSECONDS);
return null;
} else {
log.trace("Starting scheduled job to execute unmute.");
log.trace("Starting scheduled job to execute unMute.");
JobDataMap parameters = new JobDataMap();
parameters.putAsString("muteId", mute.getId());
return schedulerService.executeJobWithParametersOnce("unMuteJob", "moderation", parameters, Date.from(unmuteDate));
return schedulerService.executeJobWithParametersOnce("unMuteJob", "moderation", parameters, Date.from(unMuteDate));
}
}
@Override
public void cancelUnmuteJob(Mute mute) {
public void cancelUnMuteJob(Mute mute) {
if(mute.getTriggerKey() != null) {
schedulerService.stopTrigger(mute.getTriggerKey());
}
}
@Override
public void muteMemberWithLog(Member memberToMute, Member memberMuting, String reason, Instant unmuteDate, MuteLog muteLog, Message message) {
public void muteMemberWithLog(Member memberToMute, Member memberMuting, String reason, Instant unMuteDate, MuteLog muteLog, Message message) {
log.trace("Muting member with sending a mute log");
Mute mute = muteMember(memberToMute, memberMuting, reason, unmuteDate, message);
Mute mute = muteMember(memberToMute, memberMuting, reason, unMuteDate, message);
muteLog.setMute(mute);
sendMuteLog(muteLog);
}
@@ -217,28 +217,28 @@ public class MuteServiceBean implements MuteService {
postTargetService.sendEmbedInPostTarget(message, MutingPostTarget.MUTE_LOG, muteLogModel.getServer().getId());
}
private void sendUnmuteLog(UnMuteLog muteLogModel) {
log.trace("Sending unmute log to the mute posttarget");
MessageToSend message = templateService.renderEmbedTemplate(UNMUTE_LOG_TEMPLATE, muteLogModel);
private void sendUnMuteLog(UnMuteLog muteLogModel) {
log.trace("Sending unMute log to the mute posttarget");
MessageToSend message = templateService.renderEmbedTemplate(UN_MUTE_LOG_TEMPLATE, muteLogModel);
postTargetService.sendEmbedInPostTarget(message, MutingPostTarget.MUTE_LOG, muteLogModel.getServer().getId());
}
@Override
@Transactional
public void unmuteUser(Mute mute) {
public void unMuteUser(Mute mute) {
if(Boolean.TRUE.equals(mute.getMuteEnded())) {
log.info("Mute {} has ended already, user {} does not need to be unmuted anymore.", mute.getId(), mute.getMutedUser().getUserReference().getId());
log.info("Mute {} has ended already, user {} does not need to be unMuted anymore.", mute.getId(), mute.getMutedUser().getUserReference().getId());
return;
}
AServer mutingServer = mute.getMutingServer();
log.info("Unmuting {} in server {}", mute.getMutedUser().getUserReference().getId(), mutingServer.getId());
log.info("UnMuting {} in server {}", mute.getMutedUser().getUserReference().getId(), mutingServer.getId());
MuteRole muteRole = muteRoleManagementService.retrieveMuteRoleForServer(mutingServer);
log.trace("Using the mute role {} mapping to role {}", muteRole.getId(), muteRole.getRole().getId());
Guild guild = botService.getGuildByIdNullable(mute.getMutingServer().getId());
if(botService.isUserInGuild(guild, mute.getMutedUser())) {
roleService.removeRoleFromUser(mute.getMutedUser(), muteRole.getRole());
} else {
log.info("User to unmute left the guild.");
log.info("User to unMute left the guild.");
}
UnMuteLog unMuteLog = UnMuteLog
.builder()
@@ -248,7 +248,7 @@ public class MuteServiceBean implements MuteService {
.guild(guild)
.server(mute.getMutingServer())
.build();
sendUnmuteLog(unMuteLog);
sendUnMuteLog(unMuteLog);
mute.setMuteEnded(true);
muteManagementService.saveMute(mute);
}
@@ -256,9 +256,9 @@ public class MuteServiceBean implements MuteService {
@Override
@Transactional
public void endMute(Long muteId) {
log.info("Unmuting the mute {}", muteId);
log.info("UnMuting the mute {}", muteId);
Optional<Mute> mute = muteManagementService.findMute(muteId);
mute.ifPresent(this::unmuteUser);
mute.ifPresent(this::unMuteUser);
}
@Override
@@ -266,7 +266,7 @@ public class MuteServiceBean implements MuteService {
List<Mute> allMutesOfUser = muteManagementService.getAllMutesOf(aUserInAServer);
allMutesOfUser.forEach(mute -> {
mute.setMuteEnded(true);
cancelUnmuteJob(mute);
cancelUnMuteJob(mute);
muteManagementService.saveMute(mute);
});
}

View File

@@ -25,14 +25,14 @@ public class MuteManagementServiceBean implements MuteManagementService {
private UserInServerManagementService userInServerManagementService;
@Override
public Mute createMute(AUserInAServer mutedUser, AUserInAServer mutingUser, String reason, Instant unmuteDate, AServerAChannelMessage muteMessage) {
public Mute createMute(AUserInAServer mutedUser, AUserInAServer mutingUser, String reason, Instant unMuteDate, AServerAChannelMessage muteMessage) {
log.trace("Creating mute for user {} executed by user {} in server {}, user will be un-muted at {}",
mutedUser.getUserReference().getId(), mutingUser.getUserReference().getId(), mutedUser.getServerReference().getId(), unmuteDate);
mutedUser.getUserReference().getId(), mutingUser.getUserReference().getId(), mutedUser.getServerReference().getId(), unMuteDate);
Mute mute = Mute
.builder()
.mutedUser(mutedUser)
.mutingUser(mutingUser)
.muteTargetDate(unmuteDate)
.muteTargetDate(unMuteDate)
.mutingServer(mutedUser.getServerReference())
.mutingChannel(muteMessage.getChannel())
.messageId(muteMessage.getMessageId())

View File

@@ -49,8 +49,8 @@ public class UnMuteTest {
Mute mute = Mute.builder().build();
when(muteManagementService.getAMuteOf(memberToUnMute)).thenReturn(mute);
CommandResult result = testUnit.execute(parameters);
verify(muteService, times(1)).unmuteUser(mute);
verify(muteService, times(1)).cancelUnmuteJob(mute);
verify(muteService, times(1)).unMuteUser(mute);
verify(muteService, times(1)).cancelUnMuteJob(mute);
verify(muteService, times(1)).completelyUnMuteMember(memberToUnMute);
CommandTestUtilities.checkSuccessfulCompletion(result);
}

View File

@@ -185,14 +185,14 @@ public class MuteServiceBeanTest {
@Test
public void testCancelUnMuteJob() {
Mute mute = Mute.builder().triggerKey(TRIGGER).build();
testUnit.cancelUnmuteJob(mute);
testUnit.cancelUnMuteJob(mute);
verify(schedulerService, times(1)).stopTrigger(TRIGGER);
}
@Test
public void testCancelNotExistingJob() {
Mute mute = Mute.builder().build();
testUnit.cancelUnmuteJob(mute);
testUnit.cancelUnMuteJob(mute);
verify(schedulerService, times(0)).stopTrigger(anyString());
}
@@ -235,7 +235,7 @@ public class MuteServiceBeanTest {
Mute mute = Mockito.mock(Mute.class);
when(mute.getMuteEnded()).thenReturn(true);
when(mute.getMutedUser()).thenReturn(userBeingMuted);
testUnit.unmuteUser(mute);
testUnit.unMuteUser(mute);
verifyNoUnMuteHappened();
}
@@ -319,7 +319,7 @@ public class MuteServiceBeanTest {
when(mute.getMutingServer()).thenReturn(server);
setupUnMuteMocks(stillInGuild);
testUnit.unmuteUser(mute);
testUnit.unMuteUser(mute);
verifyUnMute(roleRemovals);
}
@@ -329,7 +329,7 @@ public class MuteServiceBeanTest {
when(botService.getGuildByIdNullable(server.getId())).thenReturn(guild);
when(botService.isUserInGuild(guild, userBeingMuted)).thenReturn(stillInGuild);
when(botService.getMemberInServer(userBeingMuted)).thenReturn(memberBeingMuted);
when(templateService.renderEmbedTemplate(eq(MuteServiceBean.UNMUTE_LOG_TEMPLATE), any(UnMuteLog.class))).thenReturn(messageToSend);
when(templateService.renderEmbedTemplate(eq(MuteServiceBean.UN_MUTE_LOG_TEMPLATE), any(UnMuteLog.class))).thenReturn(messageToSend);
}
private void verifyUnMute(int roleRemovals) {

View File

@@ -10,14 +10,14 @@ import net.dv8tion.jda.api.entities.Message;
import java.time.Instant;
public interface MuteService {
Mute muteMember(Member memberToMute, Member userMuting, String reason, Instant unmuteDate, Message message);
Mute muteAUserInAServer(AUserInAServer member, AUserInAServer userMuting, String reason, Instant unmuteDate, Message message);
Mute muteUser(FullUser userToMute, FullUser userMuting, String reason, Instant unmuteDate, Message message);
Mute muteMember(Member memberToMute, Member userMuting, String reason, Instant unMuteDate, Message message);
Mute muteAUserInAServer(AUserInAServer member, AUserInAServer userMuting, String reason, Instant unMuteDate, Message message);
Mute muteUser(FullUser userToMute, FullUser userMuting, String reason, Instant unMuteDate, Message message);
void applyMuteRole(AUserInAServer aUserInAServer);
void muteMemberWithLog(Member memberToMute, Member memberMuting, String reason, Instant unmuteDate, MuteLog log, Message message);
String startUnmuteJobFor(Instant unmuteDate, Mute mute);
void cancelUnmuteJob(Mute mute);
void unmuteUser(Mute mute);
void muteMemberWithLog(Member memberToMute, Member memberMuting, String reason, Instant unMuteDate, MuteLog log, Message message);
String startUnMuteJobFor(Instant unMuteDate, Mute mute);
void cancelUnMuteJob(Mute mute);
void unMuteUser(Mute mute);
void endMute(Long muteId);
void completelyUnMuteUser(AUserInAServer aUserInAServer);
void completelyUnMuteMember(Member member);

View File

@@ -18,11 +18,11 @@ public interface MuteManagementService {
* @param mutedUser The member which is being muted
* @param mutingUser The member which mutes
* @param reason The reason why this user is getting muted
* @param unmuteDate The date at which the mute should end
* @param unMuteDate The date at which the mute should end
* @param muteMessage The message containing the command which caused the mute
* @return The created mute object containing the mute ID
*/
Mute createMute(AUserInAServer mutedUser, AUserInAServer mutingUser, String reason, Instant unmuteDate, AServerAChannelMessage muteMessage);
Mute createMute(AUserInAServer mutedUser, AUserInAServer mutingUser, String reason, Instant unMuteDate, AServerAChannelMessage muteMessage);
/**
* Finds the mute from the database by the given ID.
@@ -60,7 +60,7 @@ public interface MuteManagementService {
Mute getAMuteOf(AUserInAServer userInAServer);
/**
* Returns any active {@link Mute} of this {@link Member} in the databaes
* Returns any active {@link Mute} of this {@link Member} in the database
* @param member The {@link Member} to search a mute for
* @return The found {@link Mute}, and null if none was found
*/
@@ -68,7 +68,7 @@ public interface MuteManagementService {
/**
* Retrieves all active mutes of the given {@link AUserInAServer} in a collection
* @param aUserInAServer The {@link AUserInAServer} to search the actie mutes for
* @param aUserInAServer The {@link AUserInAServer} to search the active mutes for
* @return A collection of {@link Mute} objects of the user which are active
*/
List<Mute> getAllMutesOf(AUserInAServer aUserInAServer);

View File

@@ -44,7 +44,7 @@ public class CloseNoLog extends AbstractConditionableCommand {
@Override
public CommandResult execute(CommandContext commandContext) {
ModMailThread thread = modMailThreadManagementService.getByChannel(commandContext.getUserInitiatedContext().getChannel());
// we dont have a note, therefore we cant pass any, the method handles this accordingly
// we don't have a note, therefore we cant pass any, the method handles this accordingly
modMailThreadService.closeModMailThread(thread, commandContext.getChannel(), null, false, false);
return CommandResult.fromSuccess();
}

View File

@@ -22,7 +22,7 @@ import java.util.List;
/**
* This command can be used to close the mod mail thread without sending a 'closing' message to the user.
* This behaves the same way as the default close commmand otherwise
* This behaves the same way as the default close command otherwise
*/
@Component
public class CloseSilently extends AbstractConditionableCommand {

View File

@@ -11,7 +11,7 @@ import org.springframework.stereotype.Component;
import static dev.sheldan.abstracto.modmail.service.ModMailThreadServiceBean.MODMAIL_CLOSING_MESSAGE_TEXT;
/**
* This listener is used to used to set the initial values of some server specific values, so we dont need to fall
* This listener is used to used to set the initial values of some server specific values, so we don't need to fall
* back to the default values. The values might not be functional, for example mod mail category id, but their existence
* makes things easier
*/

View File

@@ -152,8 +152,8 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
* this method is responsible for creating the instance in the database, sending the header in the newly created text channel and forwarding the initial message
* by the user (if any), after this is complete, this method executes the method to perform the mod mail notification.
* @param aUserInAServer The {@link FullUser} for which a {@link ModMailThread} is being created
* @param initialMessage The {@link Message} which was sent by the user to open a thread, this is null, if the thread was oepend via a command
* @param channel The created {@link TextChannel} in which the mod mail thread is dealth with
* @param initialMessage The {@link Message} which was sent by the user to open a thread, this is null, if the thread was opened via a command
* @param channel The created {@link TextChannel} in which the mod mail thread is dealt with
* @param userInitiated Whether or not the thread was initiated by a member
* @param undoActions The list of actions to undo, in case an exception occurs
*/
@@ -229,7 +229,7 @@ public class ModMailThreadServiceBean implements ModMailThreadService {
@Override
public void createModMailPrompt(AUser user, Message initialMessage) {
List<AUserInAServer> knownServers = userInServerManagementService.getUserInAllServers(user.getId());
// do nothing if we dont know the user
// do nothing if we don't know the user
if(!knownServers.isEmpty()) {
List<ServerChoice> availableGuilds = new ArrayList<>();
HashMap<String, AUserInAServer> choices = new HashMap<>();

View File

@@ -8,7 +8,7 @@ import lombok.Setter;
/**
* This model is used to render any exception happening when executing a command within a {@link ModMailThread}
* and this command failing in any capacity. This model is used to render multiple templates (for differnet kinds of
* and this command failing in any capacity. This model is used to render multiple templates (for different kinds of
* exceptions), all of which might use the information or not.
*/
@Getter

View File

@@ -89,10 +89,10 @@ public class CommandReceivedHandler extends ListenerAdapter {
try {
String contentStripped = event.getMessage().getContentStripped();
List<String> parameters = Arrays.asList(contentStripped.split(" "));
UnParsedCommandParameter unparsedParameter = new UnParsedCommandParameter(contentStripped);
UnParsedCommandParameter unParsedParameter = new UnParsedCommandParameter(contentStripped);
String commandName = commandManager.getCommandName(parameters.get(0), event.getGuild().getIdLong());
foundCommand = commandManager.findCommandByParameters(commandName, unparsedParameter);
Parameters parsedParameters = getParsedParameters(unparsedParameter, foundCommand, event.getMessage(), userInitiatedContext);
foundCommand = commandManager.findCommandByParameters(commandName, unParsedParameter);
Parameters parsedParameters = getParsedParameters(unParsedParameter, foundCommand, event.getMessage(), userInitiatedContext);
CommandContext commandContext = commandContextBuilder.parameters(parsedParameters).build();
ConditionResult conditionResult = commandService.isCommandExecutable(foundCommand, commandContext);
CommandResult commandResult;

View File

@@ -164,24 +164,24 @@ public class MessageCacheBean implements MessageCache {
ReactionPaginationAction users = reaction.retrieveUsers().cache(false);
CachedReaction.CachedReactionBuilder builder = CachedReaction.builder();
List<Long> ausers = new ArrayList<>();
List<Long> aUsers = new ArrayList<>();
users.forEachAsync(user -> {
concreteSelf.loadUser(reaction, ausers, user);
concreteSelf.loadUser(reaction, aUsers, user);
return false;
}).thenAccept(o -> future.complete(builder.build()))
.exceptionally(throwable -> {
log.error("Failed to load reaction users.", throwable);
return null;
});
builder.userInServersIds(ausers);
builder.userInServersIds(aUsers);
builder.emote(emoteService.buildAEmoteFromReaction(reaction.getReactionEmote()));
return future;
}
@Transactional
public void loadUser(MessageReaction reaction, List<Long> ausers, User user) {
public void loadUser(MessageReaction reaction, List<Long> aUsers, User user) {
if(reaction.getGuild() != null) {
ausers.add(userInServerManagementService.loadUser(reaction.getGuild().getIdLong(), user.getIdLong()).getUserInServerId());
aUsers.add(userInServerManagementService.loadUser(reaction.getGuild().getIdLong(), user.getIdLong()).getUserInServerId());
}
}

View File

@@ -50,8 +50,8 @@
<properties>
<maven.build.timestamp.format>yyyy/MM/dd HH:mm</maven.build.timestamp.format>
<jda.version>4.1.1_155</jda.version>
<jda.utilities.version>3.0.3</jda.utilities.version>
<jda.version>4.1.1_167</jda.version>
<jda.utilities.version>3.0.4</jda.utilities.version>
<asciidoctor.maven.plugin.version>2.0.0-RC.1</asciidoctor.maven.plugin.version>
<asciidoctorj.pdf.version>1.5.3</asciidoctorj.pdf.version>
<asciidoctorj.version>2.3.0</asciidoctorj.version>
@@ -166,7 +166,6 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>

View File

@@ -10,7 +10,7 @@ public class SchedulerJobConverter {
/**
* Converts a {@link SchedulerJobProperties} instance to a usable {@link SchedulerJob} instance
* @param properties The instance directly coming from a property file
* @return A instanc eof {@link SchedulerJob} which represents an instance from the database
* @return A instance eof {@link SchedulerJob} which represents an instance from the database
*/
public SchedulerJob fromJobProperties(SchedulerJobProperties properties) {
return SchedulerJob

View File

@@ -8,7 +8,7 @@ import org.springframework.stereotype.Repository;
import javax.persistence.QueryHint;
/**
* Repository repsonsible to access the stored job configuration in the database
* Repository responsible to access the stored job configuration in the database
*/
@Repository
public interface SchedulerJobRepository extends JpaRepository<SchedulerJob, Long> {

View File

@@ -57,7 +57,7 @@ public class SchedulerServiceBean implements SchedulerService {
boolean recurringJob = isRecurringJob(schedulerJob);
jobDetail = scheduleCreator.createJob((Class<? extends QuartzJobBean>) Class.forName(schedulerJob.getClazz()),
!recurringJob, context, schedulerJob.getName(), schedulerJob.getGroupName(), schedulerJob.isRecovery());
// if its a cron job, we can schedule it directly, otherwise we just make the scheduler aware of its existance
// if its a cron job, we can schedule it directly, otherwise we just make the scheduler aware of its existence
// and trigger it later
if(recurringJob) {
Trigger trigger = scheduleCreator.createBasicCronTrigger(new Date(),

View File

@@ -26,7 +26,7 @@ public interface SchedulerService {
/**
* Removes a job from the scheduler.
* @param triggerKey The key of the trigger to unschedule
* @param triggerKey The key of the trigger to unSchedule
* @return if the job was found and unscheduled
*/
boolean unScheduleJob(String triggerKey);

View File

@@ -48,7 +48,7 @@ public class EmbedConfiguration {
*/
private EmbedFooter footer;
/**
* Thhe {@link OffsetDateTime} object used as the time stamp in the {@link net.dv8tion.jda.api.entities.MessageEmbed}
* The {@link OffsetDateTime} object used as the time stamp in the {@link net.dv8tion.jda.api.entities.MessageEmbed}
*/
private OffsetDateTime timeStamp;
/**

View File

@@ -36,7 +36,7 @@ public class TemplateServiceBean implements TemplateService {
/**
* Formats the passed passed count with the embed used for formatting pages.
* @param count The index of the page you want formated.
* @param count The index of the page you want formatted.
* @return The rendered template as a string object
*/
private String getPageString(Integer count) {
@@ -46,8 +46,8 @@ public class TemplateServiceBean implements TemplateService {
}
/**
* Retrieves the key which gets suffixed with '_embed' and this retrives the embed configuration. This configuration is then rendered
* and deserialized with GSON into a {@link EmbedConfiguration} object. This object is then rendered into a {@link MessageToSend} and returned.
* Retrieves the key which gets suffixed with '_embed' and this retrieves the embed configuration. This configuration is then rendered
* and de-serialized with GSON into a {@link EmbedConfiguration} object. This object is then rendered into a {@link MessageToSend} and returned.
* If the individual element do not fit in an embed, for example, if the field count is to high, another embed will be created in the {@link MessageToSend} object.
* If multiple embeds are necessary to provide what the {@link EmbedConfiguration} wanted, this method will automatically set the footer of the additional {@link MessageEmbed}
* with a formatted page count.

View File

@@ -11,7 +11,7 @@ import java.util.Optional;
/**
* ManagementService bean used to retrieve the templates by key from the database.
* This class uses the {@link TemplateRepository} bean to laod the {@link Template} objects.
* This class uses the {@link TemplateRepository} bean to load the {@link Template} objects.
*/
@Component
@Slf4j

View File

@@ -131,7 +131,7 @@ public class SafeFieldIterationsTest {
}
public List<Object> twoListEntryParameter() {
return Arrays.asList(DefaultListAdapter.adapt(Arrays.asList("testing", "othertext"), getWrapper()), new SimpleScalar(TEMPLATE_KEY), new SimpleScalar(FIELD_NAME_TEMPLATE), new SimpleScalar(INLINE_VALUE));
return Arrays.asList(DefaultListAdapter.adapt(Arrays.asList("testing", "otherText"), getWrapper()), new SimpleScalar(TEMPLATE_KEY), new SimpleScalar(FIELD_NAME_TEMPLATE), new SimpleScalar(INLINE_VALUE));
}
private DefaultObjectWrapper getWrapper() {