diff options
| author | Zeyla Hellyer <[email protected]> | 2017-04-26 21:27:16 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-04-26 21:27:16 -0700 |
| commit | 9268f9c10ef47ffeaeb3d5040e65b1093e04b866 (patch) | |
| tree | 94f8b0a8d38b2f91206ee2010ee110c3b1ce76dd /src/ext/framework/command.rs | |
| parent | Make `User.discriminator` a u16 (diff) | |
| download | serenity-9268f9c10ef47ffeaeb3d5040e65b1093e04b866.tar.xz serenity-9268f9c10ef47ffeaeb3d5040e65b1093e04b866.zip | |
Add `is_nsfw` check to channels
A new feature in Discord is warning users about NSFW channels. This can
be useful when wanting to determine if a command can be used in a
channel or not, depending on the command content.
To help with this, provide a utility function named `utils::is_nsfw`.
This function accepts a channel name, which determines if the channel
is NSFW.
This information is not provided with data from the server. It is
determined client-side based on a few rules.
The rules for a channel being NSFW are:
- must be a guild channel
- must be a text channel
- must be named `nsfw` or be prefixed with `nsfw-`
If any of these conditions are false, then the channel is not NSFW.
Additionally, provide four helper methods:
- `GuildChannel::is_nsfw`: follows rules
- `Group::is_nsfw`: always false
- `PrivateChannel::is_nsfw`: always false
- `Channel::is_nsfw`: depends on inner channel (one of 3 above)
This check is volatile, as Discord may change requirements at any time.
The check provided by the library should not be taken as being accurate
all the time.
Diffstat (limited to 'src/ext/framework/command.rs')
0 files changed, 0 insertions, 0 deletions