Discord.js-突击队缺少参数回复
Discord.js-commando missing argument reply
我正在将我的命令从 vanilla discord.js 移植到 commando 框架。我有一个命令,当缺少参数时,它会警告用户。
const { Command } = require('discord.js-commando');
module.exports = class ServerCommand extends Command {
constructor(client) {
super(client, {
name: 'say',
aliases: ['s'],
group: 'mod',
memberName: 'say',
description: 'Make the bot speak for you.',
userPermissions: ['MANAGE_CHANNELS'],
examples: [client.commandPrefix + 'say <text>',client.commandPrefix + 'say hello world'],
args: [{
key: 'text',
prompt: 'What should the bot say?',
type: 'string',
}]
})
}
run(message, { text }) {
if (text == '' || !text)
message.say("You didn't specify what the bot should say.")
message.say(text);
message.delete();
}
}
现在,有了 commando,它会在缺少 arg 时自动通过回复警告用户。
我的问题是,如何覆盖它?
提前致谢!
我处理了这个添加默认值 属性 'default': 'isempty'
然后我在命令的代码中捕获它。所以,代码看起来像这样:
const { Command } = require('discord.js-commando');
module.exports = class ServerCommand extends Command {
constructor(client) {
super(client, {
name: 'say',
aliases: ['s'],
group: 'mod',
memberName: 'say',
description: 'Make the bot speak for you.',
userPermissions: ['MANAGE_CHANNELS'],
examples: [client.commandPrefix + 'say <text>',client.commandPrefix + 'say hello world'],
args: [{
key: 'text',
prompt: 'What should the bot say?',
type: 'string',
'default': 'isempty',
}]
})
}
run(message, { text }) {
if (text == 'isempty') return message.say("You didn't specify what the bot should say.");
message.say(text);
message.delete();
}
}
我正在将我的命令从 vanilla discord.js 移植到 commando 框架。我有一个命令,当缺少参数时,它会警告用户。
const { Command } = require('discord.js-commando');
module.exports = class ServerCommand extends Command {
constructor(client) {
super(client, {
name: 'say',
aliases: ['s'],
group: 'mod',
memberName: 'say',
description: 'Make the bot speak for you.',
userPermissions: ['MANAGE_CHANNELS'],
examples: [client.commandPrefix + 'say <text>',client.commandPrefix + 'say hello world'],
args: [{
key: 'text',
prompt: 'What should the bot say?',
type: 'string',
}]
})
}
run(message, { text }) {
if (text == '' || !text)
message.say("You didn't specify what the bot should say.")
message.say(text);
message.delete();
}
}
现在,有了 commando,它会在缺少 arg 时自动通过回复警告用户。 我的问题是,如何覆盖它?
提前致谢!
我处理了这个添加默认值 属性 'default': 'isempty'
然后我在命令的代码中捕获它。所以,代码看起来像这样:
const { Command } = require('discord.js-commando');
module.exports = class ServerCommand extends Command {
constructor(client) {
super(client, {
name: 'say',
aliases: ['s'],
group: 'mod',
memberName: 'say',
description: 'Make the bot speak for you.',
userPermissions: ['MANAGE_CHANNELS'],
examples: [client.commandPrefix + 'say <text>',client.commandPrefix + 'say hello world'],
args: [{
key: 'text',
prompt: 'What should the bot say?',
type: 'string',
'default': 'isempty',
}]
})
}
run(message, { text }) {
if (text == 'isempty') return message.say("You didn't specify what the bot should say.");
message.say(text);
message.delete();
}
}