[英]Discord.js webhook embed
I was able to make a webhook embed:我能够嵌入一个 webhook:
let user = message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if (!user) return message.channel.send("Please provide a user!");
const webhook = await message.channel.createWebhook(user.displayName, {
avatar: user.user.displayAvatarURL(),
channel: message.channel.id,
});
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitle(args.join(" ").split("-t")[1].split("-d")[0].trim())
.setDescription(args.join(" ").split("-d")[1].split("-f")[0].trim())
.setFooter(args.join(" ").split("-f")[1].split("-i")[0].trim())
.setImage(args.join(" ").split("-i")[1].split("-th")[0].trim())
.setThumbnail(args.join(" ").split("-th")[1].trim())
.setTimestamp();
await webhook.send(embed).then(() => {
webhook.delete();
});
this is the command format:这是命令格式:
?sembed -t <title> -d <description> -f <footer> -i <iamge> -th <thumbnail>
When running the command, it sends nothing if I leave the title/description/footer/image/thumbnail blank.运行命令时,如果我将标题/描述/页脚/图像/缩略图留空,它不会发送任何内容。
What should I add or change to make the bot send the embed without completing the format?我应该添加或更改什么以使机器人在不完成格式的情况下发送嵌入?
try this:尝试这个:
await webhook.send({ embeds: [embed] }).then(() => {
webhook.delete();
});
This is because discord.jsv13 want to have the content specified for what it is, so it can send it to the client这是因为 discord.jsv13 想要指定内容,所以它可以将其发送给客户端
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.