npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fast-hook

v2.1.1

Published

Easily create Discord Webhooks & create fallbacks using Discord.js v14.x

Downloads

500

Readme

💨 ・ 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

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()
        }
    ]
})

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"
    }]
})

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
        }]
    }]
})

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,
})

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,
})

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,
})

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
    }
})

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

| Parameter | Type | Optional | Default | Description | |---------------------|--------------------------------|----------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | trigger | textChannel or Webhook URL | false | none | The 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. | | options | Object{} | false | Presented below | Object with options for webhook | | | | | | | | options.webhookName | String | true | Client username | Webhook name in channel interactions tab | | options.reason | String | true | Fast-hook for bot | Reason to guild audit logs for creating webhook | | options.username | String | false | No user provided | Webhook app username | | options.icon | String | true | Client iconURL | Webhook app avatar | | | | | | | | options.mentions | Boolean | true | false | If false webhook will don't ping anyone | | options.silent | Boolean | true | false | If true webhook will sent in silent mode | | | | | | | | options.content | String | false | No content provided | The message of the webhook | | options.embeds | Object[] | true | none | Object with embeds | | options.files | Object[] | true | none | Object with files (attachments) | | options.components | Object[] | true | none | Object with components | | options.poll | Object{} | true | none | Object with poll |


© 2018-2024 Created by @realdarek