Skip to content

Commit b15b90c

Browse files
Fixed NPE in HelpPingCommand
1 parent 3390c78 commit b15b90c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,33 +87,35 @@ public void execute(@NotNull SlashCommandInteractionEvent event) {
8787
/**
8888
* Determines if a user is forbidden from sending a help-ping command due
8989
* to their status in the server.
90+
*
9091
* @param reservation The channel reservation for the channel they're
9192
* trying to send the command in.
92-
* @param member The member.
93-
* @param config The guild config.
93+
* @param member The member.
94+
* @param config The guild config.
9495
* @return True if the user is forbidden from sending the command.
9596
*/
9697
private boolean isHelpPingForbiddenForMember(@NotNull ChannelReservation reservation, @NotNull Member member, @NotNull GuildConfig config) {
9798
Set<Role> allowedRoles = Set.of(config.getModerationConfig().getStaffRole(), config.getHelpConfig().getHelperRole());
9899
return !(
99100
reservation.getUserId() == member.getUser().getIdLong() ||
100-
member.getRoles().stream().anyMatch(allowedRoles::contains) ||
101-
member.isOwner()
101+
member.getRoles().stream().anyMatch(allowedRoles::contains) ||
102+
member.isOwner()
102103
);
103104
}
104105

105106
/**
106107
* Determines if the user's timeout has elapsed (or doesn't exist), which
107108
* implies that it's fine for the user to send the command.
109+
*
108110
* @param memberId The members' id.
109-
* @param config The guild config.
111+
* @param config The guild config.
110112
* @return True if the user's timeout has elapsed or doesn't exist, or
111113
* false if the user should NOT send the command because of their timeout.
112114
*/
113115
private boolean isHelpPingTimeoutElapsed(long memberId, GuildConfig config) {
114-
Long lastPing = lastPingTimes.get(memberId).first();
116+
Pair<Long, Guild> lastPing = lastPingTimes.get(memberId);
115117
return lastPing == null ||
116-
lastPing + config.getHelpConfig().getHelpPingTimeoutSeconds() * 1000L < System.currentTimeMillis();
118+
lastPing.first() + config.getHelpConfig().getHelpPingTimeoutSeconds() * 1000L < System.currentTimeMillis();
117119
}
118120

119121
/**

0 commit comments

Comments
 (0)