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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fastify-discord

v1.1.1

Published

fastify plugin for discord command

Downloads

16

Readme

fastify-discord

Fastify 환경에서 discord command 처리를 위한 라이브러리 입니다.

import discord from 'fastify-discord';

// need ts
declare module 'fastify' {
    interface FastifyInstance {
        interaction: (req: FastifyRequest<{ Body: APIInteraction }>, res: FastifyReply) => Reply;
    }
}

export default fp(async function (fastify, opts) {
    fastify.register(discord, {
        DISCORD_PUBLIC_KEY: process.env.DISCORD_PUBLIC_KEY || '', // Please see the Discord developer page
        decorateKey : 'verifyDiscordKey',
        decorateReply : 'decorateReply', // make interaction event
    });

    // It doesn't fit the format, but... '알잘딱갈센'
    fastify.post<{
        Body: APIInteraction;
    }>(
        '/bot',
        {
            preHandler: [fastify.verifyDiscordKey], // decorateKey
            schema: { // if you use swagger
                // hide: true.
                description: 'bot interaction event',
                summary: 'interaction event',
                tags: ['Util'],
                deprecated: false,
            },
        },
        (req, res) => { // if you need reply message not use async func
            const interaction = fastify.decorateReply(req, res);

            /* Internally, ping is handled. */
            interaction.differ({ ephemeral: true })
                .then(async () => {
                    await sleep(3000);

                    interaction.reply({ // Internally, we change interaction events to message modifications.
                        content : '안녕 이건 응답 대기 메세지 이후 메세지야'
                    })
                })
            // if you need interaction case

            switch (body.type) {
                case InteractionType.ApplicationCommand:
                    // app command 
                    break;
                case InteractionType.MessageComponent:
                    // message
                    break;
                case InteractionType.ModalSubmit:
                    // modal
                    break;
                default: // not work
                    break;
            }
        }
    );
});

fastify - bot commmand post event (interaction)

export default async (fastify: FastifyInstance, opts: any) => {
    fastify.post<{
        Body: APIInteraction;
    }>(
        '/bot',
        {
            preHandler: [fastify.verifyDiscordKey],
            schema: {
                // hide: true,
                description: '봇 인터렉션 이벤트 수신부 - 연결 및 사용 X',
                summary: '인터렉션 이벤트',
                tags: ['Util'],
                deprecated: false,
            },
        },
        (req, res) => { // if you need reply message not use async func
            const interaction = fastify.decorateReply(req, res);

            interaction.differ({ ephemeral: true })
                .then(async () => {
                    await sleep(3000);

                    interaction.reply({ // Internally, we change interaction events to message modifications.
                        content : '안녕 이건 응답 대기 메세지 이후 메세지야'
                    })
                })
            
        }
    );
};

Most forms reference discord.js

model

interaction.model({
    title: 'Modal create',
    custom_id: 'modal create',
    components: [
        {
            type: ComponentType.ActionRow,
            components: [
                {
                    type: ComponentType.TextInput,
                    custom_id : 'text',
                    style : TextInputStyle.Short,
                    label: '이름',
                    placeholder: '이름을 입력해 주세요.',
                    required: true,
                    max_length: 100,
                    min_length: 1,
                },
            ],
        }
    ],
});

follow

interaction.follow({
    ephemeral: true, // Only visible to me
    embeds: [
        {
            title: '타이틀',
            description: `후앵😂 메세지`,
            color: 0x00ff00,
            image: {
                url: 'https://cdn.orefinger.click/post/466950273928134666/d2d0cc31-a00e-414a-aee9-60b2227ce42c.png',
            },
        },
    ],
});

auto

interaction.auto({
    choices : [
        {
            name : '응애',
            value : '응애 나는 아기 개발자',
        }
    ]
});

UPDATE

1.0.4

  • init

1.1.0

  • interaction 객체 내부에 데이터 첨가
  • 인증시 핑처리를 해줍니다.
  • 각 인터렉션별로 별도로 정의하였습니다. MessageInteraction AppInteraction AppAutocompleteInteraction ModelInteraction

AppChatInputInteraction AppContextMenuInteraction MessageButtonInteraction MessageMenuInteraction

1.1.1

  • interaction 생성객체 (타입 치환용)