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

@zibot/giveaway

v0.0.3

Published

Giveaway for discord bot

Downloads

9

Readme

@zibot/giveaway

A simple and efficient giveaway management system for Discord bots using discord.js. This package allows you to create, manage, pause, resume, and end giveaways with ease.

Installation

npm install @zibot/giveaway

Features

  • 🎉 Create giveaways with customizable duration and prizes

  • ✋ Pause and resume giveaways

  • 🏆 Automatically pick winners when the giveaway ends

  • 📋 Fetch active giveaways

  • 🎭 Role-based participation

  • 🟦 Button-based interaction

Usage

Importing the Module

const { Client, GatewayIntentBits } = require("discord.js");
const { Giveaways } = require("@zibot/giveaway");

const client = new Client({
	intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
});

const giveaways = new Giveaways(client, {
	store: "./giveaways.json",
	updateInterval: 60000, // 1 minute
});

client.once("ready", () => {
	console.log(`Logged in as ${client.user.tag}`);
	giveaways.init();
});

client.login("YOUR_BOT_TOKEN");

Creating a Giveaway

giveaways.createGiveaway(
	"channel", // The channel where the giveaway will be posted
	"Free Nitro", // Prize name
	60000, // Duration in milliseconds (1 minute)
	1, // Number of winners
	{ content: "🎉 Giveaway Started! 🎉" }, // Optional custom message
);

Editing a Giveaway

const messageId = "123456789012345678"; // ID of message giveaway

giveaways.editGiveaway(messageId, {
  prize: "New Awesome Prize", // Prize name
  duration: 300000, // Duration in milliseconds  (5 minute)
  winnerCount: 2 // Number of winners
});

console.log("Giveaway updated!");

Joining a Giveaway

const res = giveaways.joinGiveaway("message-id", "user-id", "role");
/* res:
-2: requiredRole
-1: 404 or paused
 0: already joined
 1: join ok
*/

Leave a Giveaway

giveaways.leaveGiveaway("message-id", "user-id");

Ending a Giveaway

giveaways.endGiveaway("message-id");

Pausing a Giveaway

giveaways.pauseGiveaway("message-id");

Resuming a Giveaway

giveaways.unpauseGiveaway("message-id");

Fetching Active Giveaways

const activeGiveaways = giveaways.fetchGiveaways();
console.log(activeGiveaways);

Use Button Interaction

Creating a Giveaway

const { EmbedBuilder, ButtonBuilder, ActionRowBuilder, ButtonStyle } = require("discord.js");

async function startGiveaway(channel) {
  const embed = new EmbedBuilder()
    .setTitle("🎉 Giveaway!")
    .setDescription("Click the button below to enter!")
    .setColor("Gold");

  const button = new ButtonBuilder()
    .setCustomId("join_giveaway")
    .setLabel("Join Giveaway")
    .setStyle(ButtonStyle.Primary);

  const row = new ActionRowBuilder().addComponents(button);

  const message = await channel.send({ embeds: [embed], components: [row] });

  giveaways.createGiveaway(channel.id, "Awesome Prize", 60000, 1, message);
}

Handling Button Interaction

client.on("interactionCreate", async (interaction) => {
  if (!interaction.isButton()) return;

  if (interaction.customId === "join_giveaway") {
    const joined = giveaways.joinGiveaway(interaction.message.id, interaction.user.id);
    
    if (joined) {
      await interaction.reply({ content: "You have joined the giveaway!", ephemeral: true });
    } else {
      await interaction.reply({ content: "You are already in the giveaway!", ephemeral: true });
    }
  }
});

Events

You can listen to various events for better control over the giveaway process:

giveaways.on("giveawayCreated", (client, giveaway) => {
	console.log(`Giveaway started: ${giveaway.prize} in ${giveaway.channelId}`);
});
giveaways.on("giveawayEdited", (giveaway) => {
	console.log(`Giveaway edited: ${giveaway.prize} in ${giveaway.channelId}`);
});
giveaways.on("giveawayEnded", (giveaway, winners) => {
	console.log(`Giveaway ended: ${giveaway.prize} in ${giveaway.channelId} with winners: ${winners.join(", ")}`);
});
giveaways.on("userJoined", (giveaway, userId) => {
	console.log(`User ${userId} joined giveaway: ${giveaway.prize}`);
});
giveaways.on("userLeft", (giveaway, userId) => {
	console.log(`User ${userId} left giveaway: ${giveaway.prize}`);
});
giveaways.on("giveawayPaused", (giveaway) => {
	console.log(`Giveaway paused: ${giveaway.prize} in ${giveaway.channelId}`);
});
giveaways.on("giveawayUnpaused", (giveaway) => {
	console.log(`Giveaway resumed: ${giveaway.prize} in ${giveaway.channelId}`);
});
giveaways.on("giveawaysSaved", (allgiveaway) => {
	console.log(`${allgiveaway.length} Giveaway Saved`);
});
giveaways.on("debug", (d) => {
	console.log(d);
});

example bot: GA bot

License

MIT License

Contributors

  • Ziji - Creator & Maintainer

Support

For any issues or feature requests, please create an issue on the GitHub repository.