javascript - 我将如何修复嵌入命令中的意外标记/添加特征?
问题描述
我正在编写一个小机器人项目,为了挑战自己,我决定编写一个新命令。该命令应该进行嵌入,并且在该嵌入中,[提及目标用户和使用该命令的人],[嵌入短视频]
- 代码
module.exports = {
name: "bonk",
description: "bonks someone",
category: "funsies",
command: true,
execute(message, args, Discord) {
const bonkEmbed = new Discord.MessageEmbed()
.setColor("#cc4371")
.setTitle("<@user> BONKED <@target user>")
.setDescription("[somethin, idfk]")
.setThumbnail("https://discord.com/channels/774446440252309524/881660577351630849/887115025775476747")
.addFields({ name: "you got bonked!", value: "https://discord.com/channels/774446440252309524/881660577351630849/887110690719010847" }),
.setTimestamp()
.setFooter('~~lmao~~');
message.channel.send(bonkEmbed);
}
};
module.exports = {
name: 'impostor',
description: 'Calls someone an impostor.',
category: 'funsies',
command: true,
execute(message, args) {
const user = message.mentions.users.first() || message.author;
var receiver = "<@!" + user + ">";
message.channel.send(receiver + " was the impostor", {
files: ['https://media.discordapp.net/attachments/716942890089316383/755907669453438996/among_us_lmao.png?width=356&height=475']
});
},
};
由于我对javascript缺乏经验,我将这两个代码中的后者用作前者的一种脚手架。我使用了一种已经存在的嵌入格式,但这给我在命令提示符下带来了问题。它不希望某些对于此命令起作用必不可少的令牌,而且我不知道如何修复它们。
解决方案
您无法在嵌入标题中添加提及,请尝试在描述中使用提及
顺便说一句,它不会提及用户,它就像一个文本......
此外,您正在将消息链接设置为缩略图和字段!
推荐阅读
- python - 为什么在使用命令行设置本地时间时使用 timedatectl 从 python 设置时间设置 UTC 时间?
- php - 两个控制器方法中的codeigniter会话数据
- tensorflow - 错误:预期 conv3d_1_input 有 5 个维度,但得到了形状为 (10, 224, 224, 3) 的数组
- javascript - 使用百分比而不是像素会改变 html 5 画布的属性吗?
- powerbi - 使用从另一个表中查找的列创建列
- javascript - 如何使用 Next.js 和 Rails 后端安全地存储 JWT?
- vue.js - 在方法中调用 API 并获取 [object Promise]
- sql - 编写 SQL 查询,返回主列中每个排序值的结果
- angular - 在 Angular 8 中,如何从浏览器控制台访问注入的服务?
- django - 'PermissionError: [Errno 13] Permission denied:' 当上传到 /media/