[英]Command that allows someone to send embed message discord.js
So I want to make a command that allows someone to send an embed message, they can decide the description, and color, no need for a title.所以我想做一个允许某人发送嵌入消息的命令,他们可以决定描述和颜色,不需要标题。 and to set a color, they should write "-color #[color]" (EG: .embed description -color #00000): That's my code:
要设置颜色,他们应该写“-color #[color]”(例如:.embed description -color #00000):那是我的代码:
const say = args.join(" ");
message.channel.send(say)
message.delete()
}
if (command === 'embed') {
if (!args[1]) return message.reply('Please input a description and a color.');
description : arg[1]
color : arg[2]
const exampleEmbed = new Discord.MessageEmbed()
.setColor(color)
.setDescription(description)
channel.send(exampleEmbed);
}
However it's not working, also I'm new in discord.js, can someone fix my code?但是它不起作用,我也是 discord.js 的新人,有人可以修复我的代码吗?
Try this:试试这个:
if (args.length < 2) return message.reply('Please provide a color and a description')
let description = '';
do {
if (args[0].toLowerCase() === '-color') {
args.shift();
break;
}
description += ` ${args.shift()}`
} while (args.length > 1)
if (!args[0]) return message.reply('Please provide a color')
if (description === '') return message.reply('Please provide a description')
let exampleEmbed = new Discord.MessageEmbed()
.setDescription(description)
.setColor(args[0])
message.channel.send(exampleEmbed)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.