Go back

A webhook is something like this. It's a bot taking someone else avatar/name and posting a message in a channel.


Using discohook, you can create your webhook online (or learn how a webhook is made), then in JavaScript

// fetch channel webhooks
const webhooks = await channel.fetchWebhooks();
let hook = webhooks.first();
// check if there isn't an existing webhook
if (hook === undefined) {
    await channel.createWebhook(
        // avatar is the url to an avatar
        Config.hook_name, {avatar: avatar})
        .then(webhook => { hook = webhook; })

// params is the JSON you generated with discohook
// for instance
// let params = {username: name, avatarURL: avatar, content: message};
await hook.send(params);

Here the bot will create a webhook (if there isn't already one) for the channel, then it will send a message using the webhook. These created webhooks are in Integrations > [Your bot name] and not in the Webhook menu.

You may check out for a fully explained guide.