简体   繁体   English

Webhook 命令 Discord.js v12

[英]Webhook Command Discord.js v12

I made an Webhook Command for my Discord Bot.我为我的 Discord Bot 创建了一个 Webhook 命令。 It works great without any error but I was wondering if it was possible to show the username and avatar of the user in the webhook.它运行良好,没有任何错误,但我想知道是否可以在 webhook 中显示用户的用户名和头像。 Like if I use the command instead of showing the webhook name and avatar it shows my name and avatar or the person who uses the commands name and avatar.就像我使用命令而不是显示 webhook 名称和头像一样,它会显示我的名字和头像或使用命令名称和头像的人。 Here is my code:这是我的代码:

client.on("message", (message) => {
  if (message.content.toLocaleLowerCase().startsWith("+hook")) {
    let webhookMsg = message.content.substring(9);
    webhookClient.send(webhookMsg)
  } 
})

Can you help me out?你能帮我吗? Thanks In Advance!提前致谢!

You can add options in the second argument of the WebHookClient.send method, see example:您可以在 WebHookClient.send 方法的第二个参数中添加选项,请参见示例:

    webhookClient.send('hello', {
        username: message.author.username,
        avatarURL: message.author.avatarURL()
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM