本文介绍了Discord Bot嵌入变量返回为未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码,值始终未定义 https://cdn.discordapp.com/attachments/501784044649054231/509529437419732994/unknown. png
This is my code and the values keep being undefinedhttps://cdn.discordapp.com/attachments/501784044649054231/509529437419732994/unknown.png
该代码应该是
!rebirth 1 1 1
它应该以嵌入方式回复
集体现金1
生命币1
令牌1
Collective cash 1
Lifecoins 1
Tokens 1
exports.run = (_client, message, args) => {
let {Cash} = args[0]; // Remember arrays are 0-based!.
let {Tokens} = args[1];
let {LifeCoins} = args[2];
const Discord = require('discord.js')
var embed = new Discord.RichEmbed()
.setTitle("Rebirth")
.setAuthor("Author Name", `${message.author.avatarURL}`)
.setTimestamp()
.addField("Collective Cash", `${Cash}`)
.addField("Lifecoins", `${LifeCoins}`)
.addField("Tokens", `${Tokens}`)
.addBlankField(true)
message.channel.send({
embed
})
}
推荐答案
exports.run = (_client, message, args) => {
let rest_of_the_string = message.content.slice('embed'.length); //removes the first part
let array_of_arguments = rest_of_the_string.split(' '); //[Cash LifeCoints Tokens]
const Discord = require('discord.js')
var embed = new Discord.RichEmbed()
.setTitle("Rebirth")
.setAuthor("Author Name", `${message.author.avatarURL}`)
.setTimestamp()
.addField("Collective Cash", array_of_arguments[0])
.addField("Lifecoins", array_of_arguments[1])
.addField("Tokens", array_of_arguments[2])
.addBlankField(true)
message.channel.send({
embed
})
}
尝试
这篇关于Discord Bot嵌入变量返回为未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!