简体   繁体   中英

Webhook Command Discord.js v12

I made an Webhook Command for my Discord Bot. 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. 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. 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('hello', {
        username: message.author.username,
        avatarURL: message.author.avatarURL()
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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