Skip to content
This repository was archived by the owner on Jun 9, 2024. It is now read-only.

Commit c676310

Browse files
committed
feature: Allow starting bot with no intents
1 parent d174f34 commit c676310

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/main/java/com/mewna/catnip/CatnipOptions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public final class CatnipOptions implements CatnipOptionsView, Cloneable {
140140
private EntityDelegator entityDelegator = new DefaultEntityDelegator();
141141
private boolean logEventNotInIntentsWarning = true;
142142
private boolean logEntityPresenceWarningOnCustomCache = true;
143+
private boolean iReallyWantToStartTheBotWithNoIntents;
143144

144145
@Override
145146
public Object clone() {

src/main/java/com/mewna/catnip/internal/CatnipImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
*/
7878
@Getter
7979
@Accessors(fluent = true, chain = true)
80-
public class CatnipImpl implements Catnip {
80+
public final class CatnipImpl implements Catnip {
8181
public static final BouncyCastleProvider BOUNCY_CASTLE_PROVIDER = new BouncyCastleProvider();
8282
private static final List<String> UNPATCHABLE_OPTIONS = List.of(
8383
"token",
@@ -136,7 +136,11 @@ private void sanityCheckOptions(@Nonnull final CatnipOptions options) {
136136
throw new IllegalArgumentException("Minimum required API version is v8!");
137137
}
138138
if(options.intents().isEmpty()) {
139-
throw new IllegalArgumentException("Intents are required, but you didn't provide any! Are you *sure* you want a bot that can't do anything?");
139+
if(options.iReallyWantToStartTheBotWithNoIntents()) {
140+
logAdapter().warn("Starting with no intents!");
141+
} else {
142+
throw new IllegalArgumentException("Intents are required, but you didn't provide any! Are you *sure* you want a bot that can't do anything?");
143+
}
140144
}
141145
}
142146

src/main/java/com/mewna/catnip/util/CatnipOptionsView.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,4 +394,10 @@ public interface CatnipOptionsView {
394394
* errors that may come from {@link NoopEntityCache}.
395395
*/
396396
boolean logEntityPresenceWarningOnCustomCache();
397+
398+
/**
399+
* @return Whether or not you can initialise a {@link Catnip} instance with
400+
* no intents.
401+
*/
402+
boolean iReallyWantToStartTheBotWithNoIntents();
397403
}

0 commit comments

Comments
 (0)