[英]Discord.js embed command
Some Info:一些信息:
I've been trying to make a command that makes the bot embed a title and description (ex. !embed (Title here) | (Description here)) so anyone who has the right permissions can use the bot to embed but I'm either really dumb or extremely persistent on a so called lead in my code that leads to nowhere.我一直在尝试制作一个命令,让机器人嵌入标题和描述(例如 !embed(此处的标题)|(此处的描述)),因此任何拥有正确权限的人都可以使用该机器人进行嵌入,但我在我的代码中所谓的导致无处可去的地方,要么真的很愚蠢,要么非常执着。
Problem:问题:
Cannot seem to get the title input and the description input to not mess with each other in a weird way (Putting the title into the description or the other way around) the vertical slash is suppose to be the divider between the title and description but I can't get it to work no-matter how hard I mess with my code.似乎无法让标题输入和描述输入不会以一种奇怪的方式相互混淆(将标题放入描述中或相反)垂直斜杠被认为是标题和描述之间的分隔线,但我无论我多么努力地弄乱我的代码,都无法让它工作。
Code:代码:
const Discord = require("discord.js");
module.exports.run = async (client, msg, args) => {
args.slice(0).join(" ")
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(args[0])
.setDescription(args.slice(1).join(" "))
msg.channel.send(embed);
}
module.exports.help = {
name: "embed"
}
The error is just here args.slice(0).join(" ")
.错误就在这里
args.slice(0).join(" ")
。
You need to store the new value of the args into the args value to update it.您需要将 args 的新值存储到 args 值中以对其进行更新。
So change that to: args = args.slice(0).join(" ")
所以将其更改为:
args = args.slice(0).join(" ")
And normally it will perfectly work!通常它会完美地工作!
Edit:编辑:
You can use a specific typo in the command like -command -t Title with multiple words -d Description with multiple words
.您可以在命令中使用特定的错字,例如
-command -t Title with multiple words -d Description with multiple words
。 Then you can adapt your code.然后你可以调整你的代码。
const Discord = require("discord.js");
module.exports.run = async (client, msg, args) => {
args.slice(0).join(" ")
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(args.join(" ").split("-t")[1].split("-d")[0].trim())
.setDescription(args.join(" ").split("-d")[1].trim())
msg.channel.send(embed);
}
module.exports.help = {
name: "embed"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.