2.1.1 • Published 8 months ago

fast-hook v2.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

💨 ・ fast-hook ・ 💨


The package is a module that makes it easy to work with webhooks (discord.js). With fast-hook, you can enter only the required variables and the webhook will be sent quickly.

downloadsBadge versionBadge discordBadge

Next update: soon

DBIT SUPPORT

Instalation

$ npm install --save fast-hook

Usage

import fhook from 'fast-hook';

// or

const fhook = require("fast-hook");

fhook.send(trigger, options = {});

Check the documentation table to understand what the trigger and options are.

Example with normal message

import fhook from 'fast-hook';

await fhook.send(trigger, {
    username: "Settings",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/KfGlCvl.png",

    content: "Current settings... <:boosting_9:1272525921747734538>",
});

Rest of examples:

Click to show content

npm.io

import Discord from 'discord.js';

const verificationEmbed = new Discord.EmbedBuilder()
    .setTitle("Verification code")
    .setDescription("Please type this code to this <#1296927000836968571> channel!")
    .setImage(`https://i.imgur.com/SByNj7t.png`)
    .setColor("#6f7174")
    .setTimestamp(Date.now())


await fhook.send(trigger, {
    username: "Verification",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/ROVjINf.png",

    content: "Please, verify yourself",
    embeds: [verificationEmbed]
})

Recommended:

await fhook.send(triggee, {
    username: "Verification",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/ROVjINf.png",

    content: "Please, verify yourself",
    embeds: [
        {
            title: "Verification code",
            description: "Please type this code to this <#1296927000836968571> channel!",
            image: {
                url: "https://i.imgur.com/SByNj7t.png",
            },
            color: 0x6f7174,
            timestamp: new Date().toISOString()
        }
    ]
})

npm.io

import Discord from 'discord.js';

const imageFile = new Discord.AttachmentBuilder()
    .setFile("https://i.imgur.com/SByNj7t.png")
    .setName("Image.png")
    .setDescription("Simple image")


await fhook.send(trigger, {
    username: "Files bot",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/GG84X9q.png",

    content: "Check this file!",
    files: [imageFile]
})

Recommended:

await fhook.send(trigger, {
    username: "Files bot",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/GG84X9q.png",

    content: "Check this file!",
    files: [{
        attachment: "https://i.imgur.com/LAfRcD1.png",
        name: "Image.png",
        description: "Simple image"
    }]
})

npm.io

import Discord from 'discord.js';

const Button = new Discord.ButtonBuilder()
    .setLabel("Button")
    .setCustomId("CustomButton")
    .setStyle(Discord.ButtonStyle.Secondary)

const ButtonRow = new Discord.ActionRowBuilder()
    .addComponents([
        Button
    ])

await fhook.send(trigger, {
    username: "Simple button",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/ZjzaujP.png",

    content: "Hmmmm if you boring, click button",
    components: [
        ButtonRow
    ]
})

Recommended:

import Discord from 'discord.js';

await fhook.send(trigger, {
    username: "Simple button",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/ZjzaujP.png",

    content: "Hmmmm if you boring, click button",
    components: [{
        type: Discord.ComponentType.ActionRow,
        components: [{
            type: Discord.ComponentType.Button,
            label: 'Button',
            custom_id: 'CustomButton',
            style: Discord.ButtonStyle.Secondary
        }]
    }]
})

npm.io

await fhook.send(trigger, {
    username: "Who are there?",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/WN2Exdv.png",

    content: "Shhhhhhhh this is silent message",
    silent: true,
})

npm.io

await fhook.send(trigger, {
    username: "Activity bot",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/SX1s9RZ.png",

    content: "<@586132986756333568> Are you here?",
    mentions: true,
})

npm.io

await fhook.send(trigger, {
    username: "Activity bot",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/SX1s9RZ.png",

    content: "<@586132986756333568> Are you here?",
    mentions: false,
})

npm.io

import Discord from 'discord.js';

await fhook.send(trigger, {
    username: "Polls man",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/4aoh5Dn.png",

    poll: {
        allowMultiple: true,
        question: {
            text: "What would you want to choose?"
        },
        layoutType: Discord.PollLayoutType.Default,
        answers: [
            {
                emoji: "❌",
                text: "First answer"
            },
            {
                emoji: "❤️",
                text: "Second answer"
            }
        ],
        duration: 30
    }
})

npm.io

Contains everything except surveys because a survey can be sent without any other components

import Discord from 'discord.js';

await fhook.send(trigger, {
    username: "All utility",
    webhookName: "my best bot webhook",
    icon: "https://i.imgur.com/shCopCz.png",

    content: "Look at this <@586132986756333568>",
    silent: true,
    mentions: true,
    embeds: [
        {
            title: "Verification code",
            description: "Please type this code to this <#1296927000836968571> channel!",
            image: {
                url: "https://i.imgur.com/SByNj7t.png",
            },
            color: 0x6f7174,
            timestamp: new Date().toISOString()
        }
    ],
    files: [{
        attachment: "https://i.imgur.com/LAfRcD1.png",
        name: "Image.png",
        description: "Simple image"
    }],
    components: [{
        type: Discord.ComponentType.ActionRow,
        components: [{
            type: Discord.ComponentType.Button,
            label: 'Button',
            custom_id: 'CustomButton',
            style: Discord.ButtonStyle.Secondary
        }]
    }]
})

Documentation table

ParameterTypeOptionalDefaultDescription
triggertextChannel or Webhook URLfalsenoneThe trigger is a guild channel object or webhook url. If you specify a channel, the package searches for a webhook created by the bot on that channel and uses it (if it doesn't have one, it creates one). If you specify a webhook url, the package will search for it and, if it can, send a message there.
optionsObject{}falsePresented belowObject with options for webhook
options.webhookNameStringtrueClient usernameWebhook name in channel interactions tab
options.reasonStringtrueFast-hook for botReason to guild audit logs for creating webhook
options.usernameStringfalseNo user providedWebhook app username
options.iconStringtrueClient iconURLWebhook app avatar
options.mentionsBooleantruefalseIf false webhook will don't ping anyone
options.silentBooleantruefalseIf true webhook will sent in silent mode
options.contentStringfalseNo content providedThe message of the webhook
options.embedsObject[]truenoneObject with embeds
options.filesObject[]truenoneObject with files (attachments)
options.componentsObject[]truenoneObject with components
options.pollObject{}truenoneObject with poll

© 2018-2024 Created by @realdarek

3.0.0-beta.1

8 months ago

3.0.0-beta.3

8 months ago

3.0.0-beta.2

8 months ago

3.0.0-beta

8 months ago

3.0.0-dev.2

8 months ago

2.1.1

8 months ago

2.1.0

8 months ago

2.0.2

8 months ago

2.0.1

8 months ago

2.0.0

8 months ago

1.3.2

3 years ago

1.4.0

3 years ago

1.3.1

3 years ago

1.3.0

4 years ago