Skip to content

Commit e201e4a

Browse files
committed
fixed minor issues.
1 parent 3bc9739 commit e201e4a

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/main/java/net/discordjug/javabot/systems/user_commands/format_code/FormatCodeInteractionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ private boolean isValid(ComponentInteraction event) {
112112

113113
Member member = event.getMember();
114114
if (member == null) {
115-
Responses.errorWithTitle(event, "Server Required", "This button may only be used inside a server.").queue();
115+
Responses.errorWithTitle(event, "Server Required", "This may only be used inside a server.").queue();
116116
return false;
117117
}
118-
if (!(member.getIdLong() == requesterId || Checks.hasStaffRole(botConfig, member))) {
118+
if (member.getIdLong() != requesterId || !Checks.hasStaffRole(botConfig, member)) {
119119
Responses.errorWithTitle(event, "Access Denied", "You are not authorized to perform this action.").queue();
120120
return false;
121121
}

src/main/java/net/discordjug/javabot/systems/user_commands/format_code/LinkedMessages.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ public class LinkedMessages {
1616
private LinkedMessages() {
1717
}
1818

19-
/**
19+
/**
2020
* Resolves a block of messages ending at {@code triggerMessage} and passes the
2121
* bot's own messages to {@code onResolved}, ordered from newest to oldest.
2222
* If {@code inclusive} is {@code true}, {@code triggerMessage} is included in
2323
* the resolved block; otherwise, only the preceding {@code total} messages are
24-
* considered. Runs {@code onError} if the block can't be safely resolved.
24+
* considered. When {@code inclusive} is {@code true}, {@code total} must be at
25+
* least 2: {@code triggerMessage} counts as one of the {@code total} messages
26+
* and the remaining {@code total - 1} are fetched from the channel history, so
27+
* a single-message inclusive block is not supported. Runs {@code onError} if
28+
* the block can't be safely resolved.
2529
*
2630
* @param triggerMessage the message marking the end of the block
27-
* @param total the number of messages to resolve
31+
* @param total the number of messages to resolve; must be at least 2 when {@code inclusive} is {@code true}
2832
* @param inclusive whether {@code triggerMessage} should be included in the resolved block
2933
* @param onResolved receives the bot's messages, ordered from newest to oldest
3034
* @param onError runs if the block can't be safely resolved
3135
*/
3236
static void resolveBefore(Message triggerMessage, int total, boolean inclusive,Consumer<List<Message>> onResolved, Runnable onError) {
33-
if (total <= 1 && inclusive) {
34-
verify(List.of(triggerMessage), total, onResolved, onError);
35-
return;
36-
}
3737
triggerMessage.getChannel().getHistoryBefore(triggerMessage.getIdLong(), inclusive?total-1 :total).queue(history -> {
3838
List<Message> block = new ArrayList<>(history.getRetrievedHistory());
3939
if (inclusive){

0 commit comments

Comments
 (0)