javascript - 嵌入页脚不和谐机器人中的用户名
问题描述
我希望请求命令的用户的用户名显示在页脚中。我尝试了很多事情,但我不知道我应该怎么做。我的代码在这里:
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#000033')
.setTitle('```Help```')
.setDescription('For more help, type .help (command)')
.addFields(
{ name: '.list', value: 'Opens list of all the achievements' },
{ name: '.profile', value: 'Opens achievement statistics from a member', },
{ name: '.leaderbord', value: 'Opens a leaderbord of the members with most achievements', },
{ name: '.bot', value: 'Opens bot links and information about the bot', },
{ name: '.setup', value: 'Starts the setup of the bot (only for administrators)', }
)
.setTimestamp()
.setFooter("here should the name stand")
client.on("message", (message) => {
if (message.content == ".help") {
message.channel.send(exampleEmbed)
console.log(message.member.user.tag +' executed command .HELP')
}
})
解决方案
你正在寻找.setFooter(message.author.username)
完整代码:
client.on("message", (message) => {
if (message.content == ".help") {
const exampleEmbed = new Discord.MessageEmbed()
.setColor('#000033')
.setTitle('```Help```')
.setDescription('For more help, type .help (command)')
.addFields(
{ name: '.list', value: 'Opens list of all the achievements' },
{ name: '.profile', value: 'Opens achievement statistics from a member', },
{ name: '.leaderbord', value: 'Opens a leaderbord of the members with most achievements', },
{ name: '.bot', value: 'Opens bot links and information about the bot', },
{ name: '.setup', value: 'Starts the setup of the bot (only for administrators)', }
)
.setTimestamp()
.setFooter(message.author.username);
message.channel.send(exampleEmbed)
console.log(message.member.user.tag +' executed command .HELP')
}
})
如下所述,您需要将您的嵌入放在消息事件侦听器中
推荐阅读
- javascript - 反应:输入 onChange 不会触发第二次,第一次工作
- c# - 在文件夹中另存为 iText.Layout.Element.Image
- macos - 如何在 SwiftUI 中自动扩展 NSTextView 的高度?
- datetime - 如何在mule 4中转换日期?
- python - 我是 python 新手,我在研究假新闻检测算法,我在从 url 中提取网站名称时遇到问题
- python - Discord.py 类型错误:on_message() 缺少 1 个必需的仅关键字参数:“搜索”
- sql - 在 Postgres 中存储站点的开放时间
- ip - 我们可以用 IP 地址做什么?
- java - 如何修改部署在不同国家的spring boot rest api的业务逻辑
- mysql - 如何使用 MySQL 查询去除具有相同颜色或大小的重复记录