| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3bc9739 commit e201e4a
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -112,10 +112,10 @@ private boolean isValid(ComponentInteraction event) { | |||
| 112 | 112 | ||
| 113 | 113 | Member member = event.getMember(); | |
| 114 | 114 | 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(); | ||
| 116 | 116 | return false; | |
| 117 | 117 | } | |
| 118 | - if (!(member.getIdLong() == requesterId || Checks.hasStaffRole(botConfig, member))) { | ||
| 118 | + if (member.getIdLong() != requesterId || !Checks.hasStaffRole(botConfig, member)) { | ||
| 119 | 119 | Responses.errorWithTitle(event, "Access Denied", "You are not authorized to perform this action.").queue(); | |
| 120 | 120 | return false; | |
| 121 | 121 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,24 +16,24 @@ public class LinkedMessages { | |||
| 16 | 16 | private LinkedMessages() { | |
| 17 | 17 | } | |
| 18 | 18 | ||
| 19 | - /** | ||
| 19 | + /** | ||
| 20 | 20 | * Resolves a block of messages ending at {@code triggerMessage} and passes the | |
| 21 | 21 | * bot's own messages to {@code onResolved}, ordered from newest to oldest. | |
| 22 | 22 | * If {@code inclusive} is {@code true}, {@code triggerMessage} is included in | |
| 23 | 23 | * 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. | ||
| 25 | 29 | * | |
| 26 | 30 | * @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} | ||
| 28 | 32 | * @param inclusive whether {@code triggerMessage} should be included in the resolved block | |
| 29 | 33 | * @param onResolved receives the bot's messages, ordered from newest to oldest | |
| 30 | 34 | * @param onError runs if the block can't be safely resolved | |
| 31 | 35 | */ | |
| 32 | 36 | 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 | - } | ||
| 37 | 37 | triggerMessage.getChannel().getHistoryBefore(triggerMessage.getIdLong(), inclusive?total-1 :total).queue(history -> { | |
| 38 | 38 | List<Message> block = new ArrayList<>(history.getRetrievedHistory()); | |
| 39 | 39 | if (inclusive){ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments