📜  webhook discord.js - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:22.749000             🧑  作者: Mango

代码示例1
client.on("message", async message => {
  if (message.author.bot) return;
  if (message.webhookID) return;
  if (!message.content.startsWith(prefix)) return;
    let command = message.content.split(" ")[0];
    command = command.slice(prefix.length);
    let args = message.content.split(" ").slice(1);
    if (command == "قلله") {

  const avatar = message.author.avatarURL()
  let args = message.content.split(" ").slice(1);
  const webhooks = await message.channel.fetchWebhooks();
    const webhook = webhooks.first();

  if (!webhook) {
    webhook = await message.channel.createWebhook(`Islam webhook`, {
      avatar: client.user.displayAvatarURL()
    });
  }

    try {
        await webhook.send(args.join(""), {
            username: message.author.username,
            avatarURL: avatar,}

        );} catch (error) {console.error('Error trying to send: ', error);}}
});