我还在学习Javascript之类的东西,进入discord.js,所以我很确定我输入的代码绝对错误,并且确实需要工作。
基本上,我要做的是拆分命令的参数,并将其分成嵌入的新行。
例如,如果我要执行以下操作:!results "Result 1" "Result 2" "Result 3"
,它将输出到类似表的嵌入中:
RESULTS:
Result 1
Result 2
Result 3
相反,我的输出一直显示为:
Image of what happens in discord
我从Google搜索中尝试了各种不同的方法,但是似乎找不到所需的东西。
const { RichEmbed } = require("discord.js");
module.exports = {
name: "results",
category: "info",
description: "posts results in embed",
usage: "<mention, id>",
run: async (client, message, args) => {
if (message.deletable) message.delete();
let [result1, result2, result3, result4, result5, result6, result7] = args;
if (!args[0])
return message.channel.send("Please provide Result 1.").then(m => m.delete(5000));
if (!args[1])
return message.channel.send("Please provide Result 2.").then(m => m.delete(5000));
if (!args[2])
return message.channel.send("Please provide Result 3.").then(m => m.delete(5000));
if (!args[3])
return message.channel.send("Please provide Result 4.").then(m => m.delete(5000));
if (!args[4])
return message.channel.send("Please provide Result 5.").then(m => m.delete(5000));
if (!args[5])
return message.channel.send("Please provide Result 6.").then(m => m.delete(5000));
if (!args[6])
return message.channel.send("Please provide Result 7.").then(m => m.delete(5000));
const channel = message.guild.channels.find(c => c.name === "cards")
if (!channel)
return message.channel.send("Couldn't find a `#cards` channel").then(m => m.delete(5000));
const embed = new RichEmbed()
.setColor("RANDOM")
.setTimestamp()
.setAuthor("Posted by GM:", (message.author.username, message.author.displayAvatarURL))
.setTitle("**TestTitle**")
.setFooter(message.guild.name, message.guild.iconURL)
.setDescription(`**__Results!__**`)
.addField(`**> Result 1:** ${result1}`)
.addField(`**> Result 2:** ${result2}`)
.addField(`**> Result 3:** ${result3}`)
.addField(`**> Result 4:** ${result4}`)
.addField(`**> Result 5:** ${result5}`)
.addField(`**> Result 6:** ${result6}`)
.addField(`**> Result 7:** ${result7}`);
return channel.send(embed);
}
}
编辑:我已经取得了一些进展,这是最新的代码,这是输出:
答案 0 :(得分:0)
您正在添加一个字段,该字段需要标题和值。但是,您只是在赋予它价值。 我建议仅使用描述字段,并用新行将您的内容分开。它通常看起来会更好。请务必注意,描述字段最多只能为2048 characters。
以下是您可以查看的指南: https://discordjs.guide/popular-topics/embeds.html#embed-preview