2021-04-04 09:29:56 +00:00
|
|
|
import type { Message } from '../structures/message.ts'
|
|
|
|
import type { GuildTextBasedChannel } from '../structures/guildTextChannel.ts'
|
2021-04-04 05:42:15 +00:00
|
|
|
import { Client, ClientOptions } from '../client/mod.ts'
|
2020-12-02 12:29:52 +00:00
|
|
|
import {
|
|
|
|
CategoriesManager,
|
2020-12-06 07:28:01 +00:00
|
|
|
Command,
|
2020-12-02 12:29:52 +00:00
|
|
|
CommandContext,
|
2020-12-06 07:28:01 +00:00
|
|
|
CommandOptions,
|
2020-12-02 12:29:52 +00:00
|
|
|
CommandsManager,
|
|
|
|
parseCommand
|
|
|
|
} from './command.ts'
|
2021-04-04 05:42:15 +00:00
|
|
|
import { Extension, ExtensionsManager } from './extension.ts'
|
2020-12-02 12:29:52 +00:00
|
|
|
|
|
|
|
type PrefixReturnType = string | string[] | Promise<string | string[]>
|
|
|
|
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Command Client options extending Client Options to provide a lot of Commands-related customizations */
|
2020-12-02 12:29:52 +00:00
|
|
|
export interface CommandClientOptions extends ClientOptions {
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Global prefix(s) of the bot. */
|
2020-12-02 12:29:52 +00:00
|
|
|
prefix: string | string[]
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Whether to enable mention prefix or not. */
|
2020-12-02 12:29:52 +00:00
|
|
|
mentionPrefix?: boolean
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Method to get a Guild's custom prefix(s). */
|
2020-12-02 12:29:52 +00:00
|
|
|
getGuildPrefix?: (guildID: string) => PrefixReturnType
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Method to get a User's custom prefix(s). */
|
2020-12-02 12:29:52 +00:00
|
|
|
getUserPrefix?: (userID: string) => PrefixReturnType
|
2020-12-08 07:05:34 +00:00
|
|
|
/** Method to get a Channel's custom prefix(s). */
|
|
|
|
getChannelPrefix?: (channelID: string) => PrefixReturnType
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Method to check if certain Guild is blacklisted from using Commands. */
|
2020-12-02 12:29:52 +00:00
|
|
|
isGuildBlacklisted?: (guildID: string) => boolean | Promise<boolean>
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Method to check if certain User is blacklisted from using Commands. */
|
2020-12-02 12:29:52 +00:00
|
|
|
isUserBlacklisted?: (guildID: string) => boolean | Promise<boolean>
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Method to check if certain Channel is blacklisted from using Commands. */
|
2020-12-02 12:29:52 +00:00
|
|
|
isChannelBlacklisted?: (guildID: string) => boolean | Promise<boolean>
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Allow spaces after prefix? Recommended with Mention Prefix ON. */
|
2020-12-02 12:29:52 +00:00
|
|
|
spacesAfterPrefix?: boolean
|
2020-12-03 03:19:39 +00:00
|
|
|
/** List of Bot's Owner IDs whom can access `ownerOnly` commands. */
|
2020-12-02 12:29:52 +00:00
|
|
|
owners?: string[]
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Whether to allow Bots to use Commands or not, not allowed by default. */
|
2020-12-02 12:29:52 +00:00
|
|
|
allowBots?: boolean
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Whether to allow Commands in DMs or not, allowed by default. */
|
2020-12-02 12:29:52 +00:00
|
|
|
allowDMs?: boolean
|
2020-12-03 03:19:39 +00:00
|
|
|
/** Whether Commands should be case-sensitive or not, not by default. */
|
2020-12-02 12:29:52 +00:00
|
|
|
caseSensitive?: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export class CommandClient extends Client implements CommandClientOptions {
|
|
|
|
prefix: string | string[]
|
|
|
|
mentionPrefix: boolean
|
2020-12-08 07:05:34 +00:00
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
getGuildPrefix: (guildID: string) => PrefixReturnType
|
|
|
|
getUserPrefix: (userID: string) => PrefixReturnType
|
2020-12-08 07:05:34 +00:00
|
|
|
getChannelPrefix: (channelID: string) => PrefixReturnType
|
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
isGuildBlacklisted: (guildID: string) => boolean | Promise<boolean>
|
|
|
|
isUserBlacklisted: (guildID: string) => boolean | Promise<boolean>
|
|
|
|
isChannelBlacklisted: (guildID: string) => boolean | Promise<boolean>
|
2020-12-08 07:05:34 +00:00
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
spacesAfterPrefix: boolean
|
|
|
|
owners: string[]
|
|
|
|
allowBots: boolean
|
|
|
|
allowDMs: boolean
|
|
|
|
caseSensitive: boolean
|
2020-12-08 07:05:34 +00:00
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
extensions: ExtensionsManager = new ExtensionsManager(this)
|
|
|
|
commands: CommandsManager = new CommandsManager(this)
|
|
|
|
categories: CategoriesManager = new CategoriesManager(this)
|
2020-12-08 07:05:34 +00:00
|
|
|
|
2020-12-06 07:28:01 +00:00
|
|
|
_decoratedCommands?: { [name: string]: Command }
|
2020-12-02 12:29:52 +00:00
|
|
|
|
|
|
|
constructor(options: CommandClientOptions) {
|
|
|
|
super(options)
|
|
|
|
this.prefix = options.prefix
|
|
|
|
this.mentionPrefix =
|
|
|
|
options.mentionPrefix === undefined ? false : options.mentionPrefix
|
2020-12-08 07:05:34 +00:00
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
this.getGuildPrefix =
|
|
|
|
options.getGuildPrefix === undefined
|
|
|
|
? (id: string) => this.prefix
|
|
|
|
: options.getGuildPrefix
|
|
|
|
this.getUserPrefix =
|
|
|
|
options.getUserPrefix === undefined
|
|
|
|
? (id: string) => this.prefix
|
|
|
|
: options.getUserPrefix
|
2020-12-08 07:05:34 +00:00
|
|
|
|
|
|
|
this.getChannelPrefix =
|
|
|
|
options.getChannelPrefix === undefined
|
|
|
|
? (id: string) => this.prefix
|
|
|
|
: options.getChannelPrefix
|
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
this.isUserBlacklisted =
|
|
|
|
options.isUserBlacklisted === undefined
|
|
|
|
? (id: string) => false
|
|
|
|
: options.isUserBlacklisted
|
|
|
|
this.isGuildBlacklisted =
|
|
|
|
options.isGuildBlacklisted === undefined
|
|
|
|
? (id: string) => false
|
|
|
|
: options.isGuildBlacklisted
|
|
|
|
this.isChannelBlacklisted =
|
|
|
|
options.isChannelBlacklisted === undefined
|
|
|
|
? (id: string) => false
|
|
|
|
: options.isChannelBlacklisted
|
2020-12-08 07:05:34 +00:00
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
this.spacesAfterPrefix =
|
|
|
|
options.spacesAfterPrefix === undefined
|
|
|
|
? false
|
|
|
|
: options.spacesAfterPrefix
|
2020-12-08 07:05:34 +00:00
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
this.owners = options.owners === undefined ? [] : options.owners
|
|
|
|
this.allowBots = options.allowBots === undefined ? false : options.allowBots
|
|
|
|
this.allowDMs = options.allowDMs === undefined ? true : options.allowDMs
|
|
|
|
this.caseSensitive =
|
|
|
|
options.caseSensitive === undefined ? false : options.caseSensitive
|
|
|
|
|
2020-12-06 07:28:01 +00:00
|
|
|
if (this._decoratedCommands !== undefined) {
|
|
|
|
Object.values(this._decoratedCommands).forEach((entry) => {
|
|
|
|
this.commands.add(entry)
|
|
|
|
})
|
2020-12-06 07:41:37 +00:00
|
|
|
this._decoratedCommands = undefined
|
2020-12-06 07:28:01 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
this.on(
|
|
|
|
'messageCreate',
|
|
|
|
async (msg: Message) => await this.processMessage(msg)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-12-05 02:24:08 +00:00
|
|
|
/** Processes a Message to Execute Command. */
|
2020-12-02 12:29:52 +00:00
|
|
|
async processMessage(msg: Message): Promise<any> {
|
|
|
|
if (!this.allowBots && msg.author.bot === true) return
|
|
|
|
|
2021-02-21 13:18:18 +00:00
|
|
|
const isUserBlacklisted = await this.isUserBlacklisted(msg.author.id)
|
|
|
|
if (isUserBlacklisted) return
|
2020-12-02 12:29:52 +00:00
|
|
|
|
2021-02-21 13:18:18 +00:00
|
|
|
const isChannelBlacklisted = await this.isChannelBlacklisted(msg.channel.id)
|
|
|
|
if (isChannelBlacklisted) return
|
2020-12-02 12:29:52 +00:00
|
|
|
|
|
|
|
if (msg.guild !== undefined) {
|
2021-02-21 13:18:18 +00:00
|
|
|
const isGuildBlacklisted = await this.isGuildBlacklisted(msg.guild.id)
|
|
|
|
if (isGuildBlacklisted) return
|
2020-12-02 12:29:52 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 07:05:34 +00:00
|
|
|
let prefix: string | string[] = []
|
|
|
|
if (typeof this.prefix === 'string') prefix = [...prefix, this.prefix]
|
|
|
|
else prefix = [...prefix, ...this.prefix]
|
|
|
|
|
2021-02-21 13:18:18 +00:00
|
|
|
const userPrefix = await this.getUserPrefix(msg.author.id)
|
2020-12-08 07:05:34 +00:00
|
|
|
if (userPrefix !== undefined) {
|
|
|
|
if (typeof userPrefix === 'string') prefix = [...prefix, userPrefix]
|
|
|
|
else prefix = [...prefix, ...userPrefix]
|
|
|
|
}
|
2020-12-02 12:29:52 +00:00
|
|
|
|
|
|
|
if (msg.guild !== undefined) {
|
2021-02-21 13:18:18 +00:00
|
|
|
const guildPrefix = await this.getGuildPrefix(msg.guild.id)
|
2020-12-08 07:05:34 +00:00
|
|
|
if (guildPrefix !== undefined) {
|
|
|
|
if (typeof guildPrefix === 'string') prefix = [...prefix, guildPrefix]
|
|
|
|
else prefix = [...prefix, ...guildPrefix]
|
|
|
|
}
|
2020-12-02 12:29:52 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 07:05:34 +00:00
|
|
|
prefix = [...new Set(prefix)]
|
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
let mentionPrefix = false
|
|
|
|
|
2020-12-08 07:05:34 +00:00
|
|
|
let usedPrefix = prefix
|
|
|
|
.filter((v) => msg.content.startsWith(v))
|
|
|
|
.sort((b, a) => a.length - b.length)[0]
|
|
|
|
if (usedPrefix === undefined && this.mentionPrefix) mentionPrefix = true
|
2020-12-02 12:29:52 +00:00
|
|
|
|
|
|
|
if (mentionPrefix) {
|
|
|
|
if (msg.content.startsWith(this.user?.mention as string) === true)
|
2020-12-08 07:05:34 +00:00
|
|
|
usedPrefix = this.user?.mention as string
|
2020-12-02 12:29:52 +00:00
|
|
|
else if (
|
|
|
|
msg.content.startsWith(this.user?.nickMention as string) === true
|
|
|
|
)
|
2020-12-08 07:05:34 +00:00
|
|
|
usedPrefix = this.user?.nickMention as string
|
2020-12-02 12:29:52 +00:00
|
|
|
else return
|
|
|
|
}
|
|
|
|
|
2020-12-08 07:05:34 +00:00
|
|
|
if (typeof usedPrefix !== 'string') return
|
|
|
|
prefix = usedPrefix
|
2020-12-02 12:29:52 +00:00
|
|
|
|
|
|
|
const parsed = parseCommand(this, msg, prefix)
|
2020-12-16 09:24:42 +00:00
|
|
|
if (parsed === undefined) return
|
2020-12-08 06:43:06 +00:00
|
|
|
const command = this.commands.fetch(parsed)
|
2020-12-02 12:29:52 +00:00
|
|
|
|
|
|
|
if (command === undefined) return
|
|
|
|
const category =
|
|
|
|
command.category !== undefined
|
|
|
|
? this.categories.get(command.category)
|
|
|
|
: undefined
|
|
|
|
|
|
|
|
// Guild whitelist exists, and if does and Command used in a Guild, is this Guild allowed?
|
|
|
|
// This is a bit confusing here, if these settings on a Command exist, and also do on Category, Command overrides them
|
|
|
|
if (
|
|
|
|
command.whitelistedGuilds === undefined &&
|
|
|
|
category?.whitelistedGuilds !== undefined &&
|
|
|
|
msg.guild !== undefined &&
|
|
|
|
category.whitelistedGuilds.includes(msg.guild.id) === false
|
|
|
|
)
|
|
|
|
return
|
|
|
|
if (
|
|
|
|
command.whitelistedGuilds !== undefined &&
|
|
|
|
msg.guild !== undefined &&
|
|
|
|
command.whitelistedGuilds.includes(msg.guild.id) === false
|
|
|
|
)
|
|
|
|
return
|
|
|
|
|
|
|
|
// Checks for Channel Whitelist
|
|
|
|
if (
|
|
|
|
command.whitelistedChannels === undefined &&
|
|
|
|
category?.whitelistedChannels !== undefined &&
|
|
|
|
category.whitelistedChannels.includes(msg.channel.id) === false
|
|
|
|
)
|
|
|
|
return
|
|
|
|
if (
|
|
|
|
command.whitelistedChannels !== undefined &&
|
|
|
|
command.whitelistedChannels.includes(msg.channel.id) === false
|
|
|
|
)
|
|
|
|
return
|
|
|
|
|
|
|
|
// Checks for Users Whitelist
|
|
|
|
if (
|
|
|
|
command.whitelistedUsers === undefined &&
|
|
|
|
category?.whitelistedUsers !== undefined &&
|
|
|
|
category.whitelistedUsers.includes(msg.author.id) === false
|
|
|
|
)
|
|
|
|
return
|
|
|
|
if (
|
|
|
|
command.whitelistedUsers !== undefined &&
|
|
|
|
command.whitelistedUsers.includes(msg.author.id) === false
|
|
|
|
)
|
|
|
|
return
|
|
|
|
|
|
|
|
const ctx: CommandContext = {
|
|
|
|
client: this,
|
|
|
|
name: parsed.name,
|
|
|
|
prefix,
|
|
|
|
args: parsed.args,
|
|
|
|
argString: parsed.argString,
|
|
|
|
message: msg,
|
|
|
|
author: msg.author,
|
|
|
|
command,
|
|
|
|
channel: msg.channel,
|
|
|
|
guild: msg.guild
|
|
|
|
}
|
|
|
|
|
|
|
|
// In these checks too, Command overrides Category if present
|
2020-12-05 02:24:08 +00:00
|
|
|
// Checks if Command is only for Owners
|
2020-12-02 12:29:52 +00:00
|
|
|
if (
|
|
|
|
(command.ownerOnly !== undefined || category === undefined
|
|
|
|
? command.ownerOnly
|
|
|
|
: category.ownerOnly) === true &&
|
|
|
|
!this.owners.includes(msg.author.id)
|
|
|
|
)
|
2021-01-20 10:05:15 +00:00
|
|
|
return this.emit('commandOwnerOnly', ctx)
|
2020-12-02 12:29:52 +00:00
|
|
|
|
2020-12-05 02:24:08 +00:00
|
|
|
// Checks if Command is only for Guild
|
2020-12-02 12:29:52 +00:00
|
|
|
if (
|
|
|
|
(command.guildOnly !== undefined || category === undefined
|
|
|
|
? command.guildOnly
|
|
|
|
: category.guildOnly) === true &&
|
|
|
|
msg.guild === undefined
|
|
|
|
)
|
2021-01-20 10:05:15 +00:00
|
|
|
return this.emit('commandGuildOnly', ctx)
|
2020-12-02 12:29:52 +00:00
|
|
|
|
2020-12-05 02:24:08 +00:00
|
|
|
// Checks if Command is only for DMs
|
2020-12-02 12:29:52 +00:00
|
|
|
if (
|
|
|
|
(command.dmOnly !== undefined || category === undefined
|
|
|
|
? command.dmOnly
|
|
|
|
: category.dmOnly) === true &&
|
|
|
|
msg.guild !== undefined
|
|
|
|
)
|
2021-01-20 10:05:15 +00:00
|
|
|
return this.emit('commandDmOnly', ctx)
|
2020-12-02 12:29:52 +00:00
|
|
|
|
2020-12-08 07:09:58 +00:00
|
|
|
if (
|
|
|
|
command.nsfw === true &&
|
|
|
|
(msg.guild === undefined ||
|
2021-03-19 15:39:14 +00:00
|
|
|
((msg.channel as unknown) as GuildTextBasedChannel).nsfw !== true)
|
2020-12-08 07:09:58 +00:00
|
|
|
)
|
2021-01-20 10:05:15 +00:00
|
|
|
return this.emit('commandNSFW', ctx)
|
2020-12-08 07:09:58 +00:00
|
|
|
|
2020-12-02 12:29:52 +00:00
|
|
|
const allPermissions =
|
|
|
|
command.permissions !== undefined
|
|
|
|
? command.permissions
|
|
|
|
: category?.permissions
|
|
|
|
|
|
|
|
if (
|
|
|
|
(command.botPermissions !== undefined ||
|
2021-03-19 10:50:16 +00:00
|
|
|
category?.botPermissions !== undefined ||
|
|
|
|
allPermissions !== undefined) &&
|
2020-12-02 12:29:52 +00:00
|
|
|
msg.guild !== undefined
|
|
|
|
) {
|
|
|
|
// TODO: Check Overwrites too
|
|
|
|
const me = await msg.guild.me()
|
|
|
|
const missing: string[] = []
|
|
|
|
|
|
|
|
let permissions =
|
|
|
|
command.botPermissions === undefined
|
|
|
|
? category?.permissions
|
|
|
|
: command.botPermissions
|
|
|
|
|
|
|
|
if (permissions !== undefined) {
|
|
|
|
if (typeof permissions === 'string') permissions = [permissions]
|
|
|
|
|
|
|
|
if (allPermissions !== undefined)
|
|
|
|
permissions = [...new Set(...permissions, ...allPermissions)]
|
|
|
|
|
|
|
|
for (const perm of permissions) {
|
|
|
|
if (me.permissions.has(perm) === false) missing.push(perm)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (missing.length !== 0)
|
2021-01-20 10:05:15 +00:00
|
|
|
return this.emit('commandBotMissingPermissions', ctx, missing)
|
2020-12-02 12:29:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
(command.userPermissions !== undefined ||
|
2021-03-19 10:50:16 +00:00
|
|
|
category?.userPermissions !== undefined ||
|
|
|
|
allPermissions !== undefined) &&
|
2020-12-02 12:29:52 +00:00
|
|
|
msg.guild !== undefined
|
|
|
|
) {
|
|
|
|
let permissions =
|
|
|
|
command.userPermissions !== undefined
|
|
|
|
? command.userPermissions
|
|
|
|
: category?.userPermissions
|
|
|
|
|
|
|
|
if (permissions !== undefined) {
|
|
|
|
if (typeof permissions === 'string') permissions = [permissions]
|
|
|
|
|
|
|
|
if (allPermissions !== undefined)
|
|
|
|
permissions = [...new Set(...permissions, ...allPermissions)]
|
|
|
|
|
|
|
|
const missing: string[] = []
|
|
|
|
|
|
|
|
for (const perm of permissions) {
|
|
|
|
const has = msg.member?.permissions.has(perm)
|
|
|
|
if (has !== true) missing.push(perm)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (missing.length !== 0)
|
2021-01-20 10:05:15 +00:00
|
|
|
return this.emit('commandUserMissingPermissions', ctx, missing)
|
2020-12-02 12:29:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command.args !== undefined) {
|
|
|
|
if (typeof command.args === 'boolean' && parsed.args.length === 0)
|
2021-01-20 10:05:15 +00:00
|
|
|
return this.emit('commandMissingArgs', ctx)
|
2020-12-02 12:29:52 +00:00
|
|
|
else if (
|
|
|
|
typeof command.args === 'number' &&
|
|
|
|
parsed.args.length < command.args
|
|
|
|
)
|
2021-01-20 10:05:15 +00:00
|
|
|
this.emit('commandMissingArgs', ctx)
|
2020-12-02 12:29:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2021-01-20 10:05:15 +00:00
|
|
|
this.emit('commandUsed', ctx)
|
2020-12-02 12:29:52 +00:00
|
|
|
|
2021-02-21 13:18:18 +00:00
|
|
|
const beforeExecute = await command.beforeExecute(ctx)
|
2020-12-02 12:29:52 +00:00
|
|
|
if (beforeExecute === false) return
|
|
|
|
|
2021-02-21 13:18:18 +00:00
|
|
|
const result = await command.execute(ctx)
|
2021-03-19 10:50:16 +00:00
|
|
|
await command.afterExecute(ctx, result)
|
2020-12-02 12:29:52 +00:00
|
|
|
} catch (e) {
|
2021-04-17 07:41:07 +00:00
|
|
|
try {
|
|
|
|
await command.onError(ctx, e)
|
|
|
|
} catch (e) {
|
|
|
|
this.emit('commandError', ctx, e)
|
|
|
|
}
|
2021-01-20 10:05:15 +00:00
|
|
|
this.emit('commandError', ctx, e)
|
2020-12-02 12:29:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-06 07:28:01 +00:00
|
|
|
|
2021-01-01 05:55:23 +00:00
|
|
|
/** Command decorator */
|
2020-12-06 07:28:01 +00:00
|
|
|
export function command(options?: CommandOptions) {
|
|
|
|
return function (target: CommandClient | Extension, name: string) {
|
2020-12-12 12:27:35 +00:00
|
|
|
if (target._decoratedCommands === undefined) target._decoratedCommands = {}
|
2020-12-06 07:28:01 +00:00
|
|
|
|
2020-12-12 12:27:35 +00:00
|
|
|
const prop = ((target as unknown) as {
|
2020-12-06 07:28:01 +00:00
|
|
|
[name: string]: (ctx: CommandContext) => any
|
|
|
|
})[name]
|
|
|
|
|
2021-01-01 05:55:23 +00:00
|
|
|
if (typeof prop !== 'function')
|
2021-03-19 10:50:16 +00:00
|
|
|
throw new Error('@command decorator can only be used on class methods')
|
2020-12-12 12:27:35 +00:00
|
|
|
|
|
|
|
const command = new Command()
|
|
|
|
|
|
|
|
command.name = name
|
|
|
|
command.execute = prop
|
|
|
|
|
2020-12-06 07:28:01 +00:00
|
|
|
if (options !== undefined) Object.assign(command, options)
|
|
|
|
|
2020-12-08 06:43:06 +00:00
|
|
|
if (target instanceof Extension) command.extension = target
|
|
|
|
|
2020-12-06 07:41:37 +00:00
|
|
|
target._decoratedCommands[command.name] = command
|
2020-12-06 07:28:01 +00:00
|
|
|
}
|
|
|
|
}
|