Skip to content

Commit 87e3ce6

Browse files
committed
Add ErrorHandlers to LazyUtilities
1 parent ee6e037 commit 87e3ce6

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

src/main/java/xyz/srnyx/lazylibrary/utility/LazyUtilities.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,57 @@
88

99
import net.dv8tion.jda.api.Permission;
1010
import net.dv8tion.jda.api.entities.Member;
11+
import net.dv8tion.jda.api.entities.Message;
1112
import net.dv8tion.jda.api.entities.User;
1213
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
1314
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
15+
import net.dv8tion.jda.api.exceptions.ErrorHandler;
1416
import net.dv8tion.jda.api.interactions.AutoCompleteQuery;
1517
import net.dv8tion.jda.api.interactions.Interaction;
1618
import net.dv8tion.jda.api.interactions.commands.Command;
1719
import net.dv8tion.jda.api.interactions.commands.OptionType;
1820
import net.dv8tion.jda.api.interactions.commands.build.OptionData;
21+
import net.dv8tion.jda.api.requests.ErrorResponse;
1922

2023
import org.jetbrains.annotations.NotNull;
2124

2225
import xyz.srnyx.javautilities.manipulation.Mapper;
2326

2427
import xyz.srnyx.lazylibrary.LazyEmoji;
2528

26-
import java.util.Collection;
27-
import java.util.Comparator;
28-
import java.util.List;
29+
import java.util.*;
2930
import java.util.function.Function;
3031

3132

3233
/**
3334
* Class for miscellaneous utilities
3435
*/
3536
public class LazyUtilities {
37+
/**
38+
* An empty set of {@link Message.MentionType mention types}
39+
*/
40+
@NotNull public static final Set<Message.MentionType> NO_MENTIONS = Collections.emptySet();
41+
/**
42+
* An {@link ErrorHandler} that ignores {@link ErrorResponse#UNKNOWN_MESSAGE} errors
43+
*/
44+
@NotNull public static final ErrorHandler IGNORE_UNKNOWN_MESSAGE = new ErrorHandler().ignore(ErrorResponse.UNKNOWN_MESSAGE);
45+
/**
46+
* An {@link ErrorHandler} that ignores {@link ErrorResponse#CANNOT_SEND_TO_USER} errors
47+
*/
48+
@NotNull public static final ErrorHandler IGNORE_CANNOT_SEND_TO_USER = new ErrorHandler().ignore(ErrorResponse.CANNOT_SEND_TO_USER);
49+
/**
50+
* An {@link ErrorHandler} that ignores {@link ErrorResponse#UNKNOWN_MEMBER} errors
51+
*/
52+
@NotNull public static final ErrorHandler IGNORE_UNKNOWN_MEMBER = new ErrorHandler().ignore(ErrorResponse.UNKNOWN_MEMBER);
53+
/**
54+
* An {@link ErrorHandler} that ignores {@link ErrorResponse#MAX_MESSAGE_PINS} errors
55+
*/
56+
@NotNull public static final ErrorHandler IGNORE_MAX_MESSAGE_PINS = new ErrorHandler().ignore(ErrorResponse.MAX_MESSAGE_PINS);
57+
/**
58+
* An {@link ErrorHandler} that ignores {@link ErrorResponse#MISSING_PERMISSIONS} errors
59+
*/
60+
@NotNull public static final ErrorHandler IGNORE_MISSING_PERMISSIONS = new ErrorHandler().ignore(ErrorResponse.MISSING_PERMISSIONS);
61+
3662
/**
3763
* Get a {@link PaginatorBuilder} with:
3864
* <ul>

0 commit comments

Comments
 (0)