diff --git a/command/src/main/java/com/jagrosh/jdautilities/command/Command.java b/command/src/main/java/com/jagrosh/jdautilities/command/Command.java index 264eaf26..b66356da 100644 --- a/command/src/main/java/com/jagrosh/jdautilities/command/Command.java +++ b/command/src/main/java/com/jagrosh/jdautilities/command/Command.java @@ -99,7 +99,15 @@ public abstract class Command *
Default {@code true}. */ protected boolean guildOnly = true; - + + /** + * {@code true} if the command may only be used in an NSFW + * {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} or DMs. + * {@code false} if it may be used anywhere + *
Default: {@code false} + */ + protected boolean nsfwOnly = false; + /** * A String name of a role required to use this command. */ @@ -316,6 +324,13 @@ else if(!event.getSelfMember().hasPermission(vc, p)) } } } + + // nsfw check + if (nsfwOnly && !event.getTextChannel().isNSFW()) + { + terminate(event, "This command may only be used in NSFW text channels!"); + return; + } } else if(guildOnly) { diff --git a/command/src/main/java/com/jagrosh/jdautilities/command/SlashCommand.java b/command/src/main/java/com/jagrosh/jdautilities/command/SlashCommand.java index d52f2558..e0e4a56e 100644 --- a/command/src/main/java/com/jagrosh/jdautilities/command/SlashCommand.java +++ b/command/src/main/java/com/jagrosh/jdautilities/command/SlashCommand.java @@ -308,6 +308,13 @@ else if(!selfMember.hasPermission(vc, p)) } } } + + // nsfw check + if (nsfwOnly && !event.getTextChannel().isNSFW()) + { + terminate(event, "This command may only be used in NSFW text channels!", client); + return; + } } else if(guildOnly) {