'Discord.js Webhooks 10 limit on channel

Every time a user send messages a webhook edits its name and shows message.author.username but after After some time maybe because of an error the webhook creates 2 or more webhooks and keeps showing message author names.

How to use only 1 webhook?


let webhook = await client.channels.cache.get(smchannel[i]).fetchWebhooks();
webhook = webhook.find(x => x.name === message.member.nickname ? message.member.nickname : message.author.username);
        
      
webhook = await client.channels.cache.get(smchannel[i]).createWebhook('Chat Guy', {
            
avatar: client.user.displayAvatarURL({ dynamic: true })});
        
        
await webhook.edit({
name: message.member.nickname ? message.member.nickname : message.author.username,
avatar: message.author.displayAvatarURL({ dynamic: true })})

webhook.send( content ).catch(err => { })

    }
});




Solution 1:[1]

You are always creating a new webhook.

First of all, you don't need to find an exact name with author because you can customize webhooks before you sent a message.

let webhooks = await client.channels.cache.get(smchannel[i]).fetchWebhooks();
let webhook = webhooks.first()
if(!webhook){
 // create new webhook if not exists in channel
} else {
 // edit your webhook in here and send!
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Neenhila