Skip to content
This repository was archived by the owner on Oct 1, 2019. It is now read-only.

Commit a7bcc7b

Browse files
committed
Release 2.5.1: Bugfixes, Javadoc
2 parents c574f48 + ea02cca commit a7bcc7b

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

build.gradle

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ apply plugin: 'application'
1616
apply plugin: 'com.github.johnrengelman.shadow'
1717
apply plugin: "com.github.spotbugs"
1818

19+
javadoc {
20+
source = sourceSets.main.allJava
21+
classpath = configurations.compile
22+
failOnError = false
23+
}
24+
1925
spotbugs {
2026
ignoreFailures = true
2127
}
@@ -25,7 +31,7 @@ tasks.withType(JavaCompile) {
2531
options.encoding = "UTF-8"
2632
}
2733

28-
version = '2.5.0'
34+
version = '2.5.1'
2935
sourceCompatibility = 1.8
3036
mainClassName = 'de.nikos410.discordbot.DiscordBot'
3137

src/main/java/de/nikos410/discordbot/modules/ModStuff.java

+17-4
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ public void command_unmute(final IMessage message, final String userString) {
339339
* @param channel The channel to send error messages to. Can be null.
340340
*/
341341
private void muteUserForGuild(final IUser user, final IGuild guild, final int muteDuration, final ChronoUnit muteDurationUnit, final IChannel channel) {
342+
if (!guild.getUsers().contains(user)) {
343+
throw new IllegalArgumentException("Specified user is not a member of the specified guild!");
344+
}
345+
342346
// Get mute role for this guild
343347
final IRole muteRole = getMuteRoleForGuild(guild);
344348
if (muteRole == null) {
@@ -801,10 +805,15 @@ public void onStartup(final ReadyEvent event) {
801805

802806
final long guildLongID = Long.parseLong(guildStringID);
803807
final IGuild guild = event.getClient().getGuildByID(guildLongID);
804-
LOG.debug("Found guild '{}'.", guild.getName());
805808

806-
restoreGuildUserMutes(guild);
807-
restoreGuildChannelMutes(guild);
809+
if (guild == null) {
810+
LOG.warn("Found modstuff entry for guild with invalid ID '%l'. Skipping.", guildLongID);
811+
}
812+
else {
813+
LOG.debug("Found guild '{}'.", guild.getName());
814+
restoreGuildUserMutes(guild);
815+
restoreGuildChannelMutes(guild);
816+
}
808817
}
809818

810819
LOG.info("Restored all mutes.");
@@ -841,7 +850,11 @@ private void restoreGuildUserMutes(final IGuild guild) {
841850
final String unmuteTimestampString = currentUserMute.getString("mutedUntil");
842851
final LocalDateTime unmuteTimestamp = LocalDateTime.parse(unmuteTimestampString, formatter);
843852

844-
if (LocalDateTime.now().isBefore(unmuteTimestamp)) {
853+
if (user == null) {
854+
LOG.info("Mute for user with id {} on guild '{}' (ID: {}) could not be restored. User is not a member of the guild",
855+
userLongID, guild.getName(), guild.getStringID());
856+
}
857+
else if (LocalDateTime.now().isBefore(unmuteTimestamp)) {
845858
final int delaySeconds = (int)LocalDateTime.now().until(unmuteTimestamp, ChronoUnit.SECONDS);
846859
muteUserForGuild(user, guild, delaySeconds, ChronoUnit.SECONDS, null);
847860
LOG.info("Restored mute for user '{}' (ID: {}) on guild '{}' (ID: {}). Muted until {}",

src/main/java/de/nikos410/discordbot/util/discord/DiscordIO.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private DiscordIO() {
2626
}
2727

2828
/**
29-
* Send a list of lines to the specified channel. If the message gets too long (>2000 characters)
29+
* Send a list of lines to the specified channel. If the message gets too long (>2000 characters)
3030
* it will be split into multiple messages. The individual lines will not be split.
3131
*
3232
* Will try 20 times, once every 0.5 seconds, if the bot gets rate limited.
@@ -61,7 +61,7 @@ public static synchronized List<IMessage> sendMessage(final IChannel channel, fi
6161
}
6262

6363
/**
64-
* Send a string to a channel. If the string is too long (>2000 characters), it will be split into
64+
* Send a string to a channel. If the string is too long (&gt;2000 characters), it will be split into
6565
* multiple messages. Will split in the middle of lines or words.
6666
*
6767
* Will try 20 times, once every 0.5 seconds, if the bot gets rate limited.

0 commit comments

Comments
 (0)