Skip to content

Commit

Permalink
Add Command#nsfwOnly(boolean)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chew committed Sep 8, 2021
1 parent 840a98f commit e7334eb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ public abstract class Command
* <br>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
* <br>Default: {@code false}
*/
protected boolean nsfwOnly = false;

/**
* A String name of a role required to use this command.
*/
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit e7334eb

Please sign in to comment.