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
src/models
|
@ -61,6 +61,8 @@ export interface CommandOptions {
|
||||||
whitelistedChannels?: string | string[]
|
whitelistedChannels?: string | string[]
|
||||||
/** Whitelisted Users. Command can be executed only by these Users (List or one of IDs) */
|
/** Whitelisted Users. Command can be executed only by these Users (List or one of IDs) */
|
||||||
whitelistedUsers?: string | string[]
|
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) */
|
/** Whether the Command can only be used in Guild (if allowed in DMs) */
|
||||||
guildOnly?: boolean
|
guildOnly?: boolean
|
||||||
/** Whether the Command can only be used in Bot's DMs (if allowed) */
|
/** 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[]
|
whitelistedGuilds?: string | string[]
|
||||||
whitelistedChannels?: string | string[]
|
whitelistedChannels?: string | string[]
|
||||||
whitelistedUsers?: string | string[]
|
whitelistedUsers?: string | string[]
|
||||||
|
nsfw?: boolean
|
||||||
guildOnly?: boolean
|
guildOnly?: boolean
|
||||||
dmOnly?: boolean
|
dmOnly?: boolean
|
||||||
ownerOnly?: boolean
|
ownerOnly?: boolean
|
||||||
|
@ -253,6 +256,11 @@ export class CommandBuilder extends Command {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setNSFW(value: boolean = true): CommandBuilder {
|
||||||
|
this.nsfw = value
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
setOwnerOnly(value: boolean = true): CommandBuilder {
|
setOwnerOnly(value: boolean = true): CommandBuilder {
|
||||||
this.ownerOnly = value
|
this.ownerOnly = value
|
||||||
return this
|
return this
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Message } from '../structures/message.ts'
|
import { Message } from '../structures/message.ts'
|
||||||
|
import { GuildTextChannel } from '../structures/textChannel.ts'
|
||||||
import { awaitSync } from '../utils/mixedPromise.ts'
|
import { awaitSync } from '../utils/mixedPromise.ts'
|
||||||
import { Client, ClientOptions } from './client.ts'
|
import { Client, ClientOptions } from './client.ts'
|
||||||
import {
|
import {
|
||||||
|
@ -277,6 +278,13 @@ export class CommandClient extends Client implements CommandClientOptions {
|
||||||
)
|
)
|
||||||
return this.emit('commandDmOnly', ctx, command)
|
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 =
|
const allPermissions =
|
||||||
command.permissions !== undefined
|
command.permissions !== undefined
|
||||||
? command.permissions
|
? command.permissions
|
||||||
|
|
Loading…
Reference in a new issue