|
4 | 4 | import net.dv8tion.jda.api.entities.Guild;
|
5 | 5 | import net.dv8tion.jda.api.entities.Message;
|
6 | 6 | import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
| 7 | +import net.dv8tion.jda.api.exceptions.ErrorResponseException; |
| 8 | +import net.dv8tion.jda.api.requests.ErrorResponse; |
7 | 9 | import org.jetbrains.annotations.NotNull;
|
8 | 10 | import org.slf4j.Logger;
|
9 | 11 | import org.slf4j.LoggerFactory;
|
@@ -51,12 +53,18 @@ public void onMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
51 | 53 |
|
52 | 54 | private static void reactWith(@NotNull String emoteName, @NotNull String fallbackUnicodeEmote,
|
53 | 55 | @NotNull Guild guild, @NotNull Message message) {
|
54 |
| - getEmoteByName(emoteName, guild).map(message::addReaction).orElseGet(() -> { |
55 |
| - logger.warn( |
56 |
| - "Unable to vote on a suggestion with the configured emote ('{}'), using fallback instead.", |
57 |
| - emoteName); |
58 |
| - return message.addReaction(fallbackUnicodeEmote); |
59 |
| - }).queue(); |
| 56 | + try { |
| 57 | + getEmoteByName(emoteName, guild).map(message::addReaction).orElseGet(() -> { |
| 58 | + logger.warn( |
| 59 | + "Unable to vote on a suggestion with the configured emote ('{}'), using fallback instead.", |
| 60 | + emoteName); |
| 61 | + return message.addReaction(fallbackUnicodeEmote); |
| 62 | + }).complete(); |
| 63 | + } catch (ErrorResponseException exception) { |
| 64 | + if (exception.getErrorResponse() != ErrorResponse.REACTION_BLOCKED) { |
| 65 | + throw exception; |
| 66 | + } |
| 67 | + } |
60 | 68 | }
|
61 | 69 |
|
62 | 70 | private static @NotNull Optional<Emote> getEmoteByName(@NotNull String name,
|
|
0 commit comments