我正在尝试发出一个命令,以便我输入两个名称,这些名称被标识为 Query1 和 Query2,但是,我不知道该怎么做,有人可以帮助我吗?
const {MessageEmbed} = require('discord.js');
module.exports ={
name : 'battle',
aliases: ['batalha'],
run : async(client, message) => {
await message.delete();
const query1 = args[0].join(" ");
if(!query1) return message.reply('Adicione o primeiro nome!');
const query2 = args[1].join(" ");
if(!query2) return message.reply('Adicione o segundo nome!')
var embed = new MessageEmbed()
.setColor('RANDOM')
.setAuthor('BATALHA DE FOTOS', client.user.avatarURL)
.setDescription(`Marque o emoji de acordo com o seu voto: \n\n ${query1}: ? \n${query2}: ?`)
.setFooter(message.author.username, message.author.displayAvatarURL)
.setTimestamp()
.setThumbnail('https://i.imgur.com/1oHJJZQ.png')
const msg = await message.channel.send(embed)
await msg.react('?')
await msg.react('?')
}
}
<块引用>
错误
(node:864) UnhandledPromiseRejectionWarning: ReferenceError: args is not defined
at Object.run (C:\Users\Pc\Desktop\RemakeGANGBOT\commands\info\battle.js:10:24)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:864) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:864) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
答案 0 :(得分:1)
您似乎没有定义 args
。您可以在为您的命令运行任何代码之前定义它:
const args = message.content.trim().split(/ +/g);