我的機器人有問題...我收到錯誤訊息
RangeError [EMBED_FIELD_NAME]: MessageEmbed field names must be non-empty strings.
at Function.verifyString (C:\Users\beucodi\Documents\r-Wof-bot\node_modules\discord.js\src\util\Util.js:413:41)
at Function.normalizeField (C:\Users\beucodi\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:479:18)
at C:\Users\beucodi\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:501:14
at Array.map (<anonymous>)
at Function.normalizeFields (C:\Users\beucodi\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:500:8)
at MessageEmbed.addFields (C:\Users\beucodi\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:322:42)
at MessageEmbed.addField (C:\Users\beucodi\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:313:17)
at Client.<anonymous> (C:\Users\beucodi\Documents\r-Wof-bot\bot.js:2081:7)
at Client.emit (node:events:390:28)
at InteractionCreateAction.handle (C:\Users\beucodi\Documents\r-Wof-bot\node_modules\discord.js\src\client\actions\InteractionCreate.js:70:12) { [Symbol(code)]: 'EMBED_FIELD_NAME'
}
即使欄位值不為空...任何人都可以幫助我嗎?這是發生錯誤的代碼片段:
case 'help':
let command = interaction.options.getString('cmd', false);
if(command === null)
try{
let embed = new Discord.MessageEmbed()
.setTitle('Help')
.setColor('ORANGE')
.setFooter('Use /help cmd:<command> for more informations on that command!')
.addField({ name: 'kill', value: /*'Kills the bot. (Only available to bot-helper role)'*/'hi' }) //line 2081
.addField({ name: 'ping', value: 'Get the time delay between when you send the message and when the bot detects it.' })
.addField({ name: 'snek', value: 'snek.' })
.addField({ name: 'stalk', value: 'Get notified when the user whith the specified id logs in. Only works with this server\'s members.' })
.addField({ name: 'oc get', value: 'Get infos about an oc. Needs to have fetched the oc to the database from the message beforehand. See /help cmd:ocmessage.' })
.addField({ name: 'oc edit', value: 'Allows for the owner of the oc to edit in the database in case the data is wrong.' })
.addField({ name: 'quote', value: 'Starts a quizz about a quote. Guess the character who said that quote!' })
.addField({ name: 'fac, flip a coin', value: 'Flips a swiss coin. Warning: There is 1 in 100000000000000000 chance that the piece lands on its side. Be careful!' })
.addField({ name: 'hybridgen', value: 'A hybrid generator for you!' })
.addField({ name: 'oc message', value: 'Adds a message to the database' })
.addField({ name: 'help', valuse: 'Shows this message!' });
interaction.reply(embed);
} catch (e) {
console.warn(e);
}
}
uj5u.com熱心網友回復:
我假設您只需要在每個中洗掉name:和,例如:,但是您將收到另一個錯誤,因為您正在嘗試使用 發送嵌入,您必須使用才能使其作業value:.addField.addField('snek', 'snek.')interaction.reply(embed)interaction.reply({embeds: [embed]})
uj5u.com熱心網友回復:
addField 方法需要 3 個引數
embed.addField(名稱:字串,值:字串,行內:布林值)
你可以把你的代碼改成這樣:
case 'help':
let command = interaction.options.getString('cmd', false);
if(command === null)
try{
let embed = new Discord.MessageEmbed()
.setTitle('Help')
.setColor('ORANGE')
.setFooter('Use /help cmd:<command> for more informations on that command!')
.addField('kill', /*'Kills the bot. (Only available to bot-helper role)'*/'hi')
.addField('ping', 'Get the time delay between when you send the message and when the bot detects it.')
.addField('snek', 'snek.')
.addField('stalk', 'Get notified when the user whith the specified id logs in. Only works with this server\'s members.')
.addField('oc get', 'Get infos about an oc. Needs to have fetched the oc to the database from the message beforehand. See /help cmd:ocmessage.')
.addField('oc edit', 'Allows for the owner of the oc to edit in the database in case the data is wrong.')
.addField('quote', 'Starts a quizz about a quote. Guess the character who said that quote!')
.addField('fac, flip a coin', 'Flips a swiss coin. Warning: There is 1 in 100000000000000000 chance that the piece lands on its side. Be careful!')
.addField('hybridgen', 'A hybrid generator for you!')
.addField('oc message', 'Adds a message to the database')
.addField('help','Shows this message!');
interaction.reply(embed);
} catch (e) {
console.warn(e);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/361103.html
標籤:javascript 节点.js 不和谐 不和谐.js
