feat(command): add nsfw property and checks
This commit is contained in:
parent
65766db1ac
commit
df34ce9a95
2 changed files with 16 additions and 0 deletions
|
@ -61,6 +61,8 @@ export interface CommandOptions {
|
|||
whitelistedChannels?: string | string[]
|
||||
/** Whitelisted Users. Command can be executed only by these Users (List or one of IDs) */
|
||||
whitelistedUsers?: string | string[]
|
||||
/** Whether the Command can only be used in NSFW channel or not */
|
||||
nsfw?: boolean
|
||||
/** Whether the Command can only be used in Guild (if allowed in DMs) */
|
||||
guildOnly?: boolean
|
||||
/** Whether the Command can only be used in Bot's DMs (if allowed) */
|
||||
|
@ -85,6 +87,7 @@ export class Command implements CommandOptions {
|
|||
whitelistedGuilds?: string | string[]
|
||||
whitelistedChannels?: string | string[]
|
||||
whitelistedUsers?: string | string[]
|
||||
nsfw?: boolean
|
||||
guildOnly?: boolean
|
||||
dmOnly?: boolean
|
||||
ownerOnly?: boolean
|
||||
|
@ -253,6 +256,11 @@ export class CommandBuilder extends Command {
|
|||
return this
|
||||
}
|
||||
|
||||
setNSFW(value: boolean = true): CommandBuilder {
|
||||
this.nsfw = value
|
||||
return this
|
||||
}
|
||||
|
||||
setOwnerOnly(value: boolean = true): CommandBuilder {
|
||||
this.ownerOnly = value
|
||||
return this
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { Message } from '../structures/message.ts'
|
||||
import { GuildTextChannel } from '../structures/textChannel.ts'
|
||||
import { awaitSync } from '../utils/mixedPromise.ts'
|
||||
import { Client, ClientOptions } from './client.ts'
|
||||
import {
|
||||
|
@ -277,6 +278,13 @@ export class CommandClient extends Client implements CommandClientOptions {
|
|||
)
|
||||
return this.emit('commandDmOnly', ctx, command)
|
||||
|
||||
if (
|
||||
command.nsfw === true &&
|
||||
(msg.guild === undefined ||
|
||||
((msg.channel as unknown) as GuildTextChannel).nsfw !== true)
|
||||
)
|
||||
return this.emit('commandNSFW', ctx, command)
|
||||
|
||||
const allPermissions =
|
||||
command.permissions !== undefined
|
||||
? command.permissions
|
||||
|
|
Loading…
Reference in a new issue