首页 > 解决方案 > 嵌入页脚不和谐机器人中的用户名

问题描述

我希望请求命令的用户的用户名显示在页脚中。我尝试了很多事情,但我不知道我应该怎么做。我的代码在这里:

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')
        }
    })

标签: javascriptdiscorddiscord.jsbots

解决方案


你正在寻找.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')
        }
    })

如下所述,您需要将您的嵌入放在消息事件侦听器中


推荐阅读