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

gifts-manager

v1.0.0-Nya

Published

A simple gift manager utility.

Downloads

7

Readme

GitHub package.json version GitHub npm

Gift Manager

Gift Manager é uma biblioteca Node.js abrangente projetada para simplificar o gerenciamento de presentes. Seja para construir um sistema de recompensas, organizar eventos especiais ou implementar campanhas promocionais, o Gift Manager garante um manuseio eficiente e organizado de presentes.

📑 Índice

🚀 Instalação

Instale o Gift Manager via npm:

npm install gifts-manager

📦 Uso

Inicialização

Comece importando a classe GiftManager:

const { GiftManager } = require('gifts-manager');

Em seguida, instancie o GiftManager:

const gm = new GiftManager();

Resgatar um Presente

(
    async () => {
        const giftId = 'seu_id_de_presente_aqui';
        const redeemResult = await gm.redeem(giftId);
        if (redeemResult.success) {
            console.log(`Presente resgatado com sucesso! Prêmio: ${redeemResult.amount} ${redeemResult.type}`);
        } else {
            console.log('Presente já foi resgatado ou é inválido.');
        }
    }
)();

Visualizar um Presente

(
    async () => {
        const giftId = 'seu_id_de_presente_aqui';
        const viewResult = await gm.view(giftId);
        if (viewResult.valid) {
            console.log(`Prêmio: ${viewResult.amount} ${viewResult.type}`);
        } else {
            console.log('ID de presente inválido.');
        }
    }
)();

Gerar um Presente

Para gerar um presente, você pode optar por valores predefinidos ou definidos pelo usuário:

// Gerar um presente com valores predefinidos
const giftId1 = await gm.generate();
console.log(`Gift ID gerado: ${giftId1}`);

// Gerar um presente com valores definidos pelo usuário
const giftId3 = await gm.generate({
    type: 'diamonds',
    amount: 100,
});
console.log(`Gift ID gerado: ${giftId3}`); 

Integração com Discord.js

Aqui está um exemplo simplificado demonstrando a integração do GiftManager com um bot Discord.js:

const Discord = require('discord.js');
const client = new Discord.Client();
const { GiftManager } = require('gifts-manager');
const gm = new GiftManager();
const { prefix } = require('./config.json') || '-';

client.once('ready', () => {
    console.log('Bot está operacional.');
});

client.on('messageCreate', async (message) => {
    if (message.author.bot) return;

    if (message.content.startsWith(prefix+'generate')) {
        const amount = Math.floor(
            Math.random() * (10000 - 1000 + 1)
            ) + 1000;
        const giftId = await gm.generate({
            type: 'daily',
            amount: amount,
        });
        message.channel.send(`Presente gerado! ID: ${giftId}`);
    }

    if (message.content.startsWith(prefix+'redeem')) {
        const giftId = message.content.split(' ')[1];
        const result = await gm.redeem(giftId);
        result.success ? message.channel.send(`Presente resgatado! Prêmio: ${result.amount} ${result.type}`) : message.channel.send('Presente já foi resgatado ou é inválido.');
    }

    if (message.content.startsWith(prefix+'view')) {
        const giftId = message.content.split(' ')[1];
        const result = await gm.view(giftId);
        result.valid ? message.channel.send(`Prêmio: ${result.amount} ${result.type}`) : message.channel.send('ID de presente inválido.');
    }
});

client.login('SEU_TOKEN_DO_DISCORD_BOT');

📜 Documentação

Para documentação detalhada, visite link_para_documentação.

🤝 Contribuições

Contribuições são bem-vindas! Consulte CONTRIBUTING.md para diretrizes.

📝 Licença

Este projeto está licenciado sob a Licença ISC.

📊 Status do Projeto

  • Status: Ativo
  • Última Atualização: Abril de 2024

Para perguntas, suporte ou feedback: