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

eris-giveaways

v2.0.1

Published

A framework to facilitate the creation of giveaways using Eris

Downloads

3

Readme

Eris Giveaways

Discord Server GitHub Version

Eris Giveaways is a powerful NodeJS framework that allows you to easily manage giveaways using the Eris library!

Features

  • ⏱️ Easy to use!
  • 🔄 Automatic restart after bot crash!
  • 🇫🇷 Support for translations: adapt the strings for your own language!
  • 📁 Support for all databases! (default is json)
  • ⚙️ Very customizable! (prize, duration, winners, ignored permissions, bonus entries, etc...)
  • 🚀 Super powerful: start, edit, reroll, end, delete and pause giveaways!
  • 💥 Events: giveawayEnded, giveawayRerolled, giveawayEdited, giveawayPaused, giveawayUnpaused, giveawayDeleted, giveawayReactionAdded, giveawayReactionRemoved, endedGiveawayReactionAdded
  • 🕸️ Support for shards!
  • and much more!

Installations

npm install eris-giveaways

Examples

Launch of the Framework

Before launching your bot with Eris Giveaways, here are some information you need to look at:

Required Intents:

Below are the required intents for the framework to run.

  • guilds
  • guildMessageReactions

Optional Intents

This is an optional intents for faster and better performance. You can either choose to enable these intents or not.

  • guildMembers
// Require Libraries
const Eris = require("eris");
const bot = new Eris("Bot TOKEN", { intents: ["guilds", "guildMessageReactions", "guildMembers"] }); // Replace "TOKEN" with your bot's real token
const settings = {
    prefix: "g!"
};

// Requires Manager from eris-giveaways
const { GiveawaysManager } = require("eris-giveaways");
// Create a Giveaways Manager
const manager = new GiveawaysManager(client, {
    storage: "./giveaways.json",
    default: {
        botsCanWin: false,
        embedColor: 0xFF0000,
        embedColorEnd: 0x000000,
        reaction: "🎉"
    }
});

// We can now access the Giveaways Manager everywhere!
client.giveawaysManager = manager;

client.on("ready", () => {
    console.log(`${client.user.username} is Ready!`);
});

// Connect the bot to Discord
client.connect();

After that, giveaways that are not yet completed will start to be updated again and new giveaways can be started.

Start a Giveaway

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

    const ms = require("ms") // npm install ms
    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
    const command = args.shift();

    if (command === "start-giveaways") {
        client.giveawaysManager.start(message.channel, {
            duration: ms(args[0]),
            prize: args.slice(2).join(" "),
            winnerCount: parseInt(args[1])
        });
    }
});

This allows you to start a new giveaway. Once the start() function is called, the giveaway starts, and you only have to observe the result, the library does the rest!

⚠ ATTENTION!

The command examples below (reroll, edit delete, end) can be executed on any server your bot is a member of if a person has the prize or the messageIDof a giveaway. To prevent abuse we recommend to check if the prize or the messageID that was provided by the command user is for a giveaway on the same server, if it is not, then cancel the command execution.

let giveaway = client.giveawaysManager.giveaways.find((g) => g.guildID === message.channel.guild.id && g.prize === args.join(" ")) || client.giveawaysManager.giveaways.find((g) => g.guildID === message.channel.guild.id && g.messageID ==== args[0]);

if (!giveaway) return message.channel.createMessage(`Unable to find giveaway for \`${args.join(" ")}\``);

Reroll a Giveaway


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

    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
    const command = args.shift();

    if (command === "reroll") {
        const messageID = args[0];

        client.giveawaysManager.reroll(messageID).then(() => {
            message.channel.createMessage("Giveaway successfully rerolled!");
        }).catch(() => {
            message.channel.createMessage(`No giveaway found for \`${messageID}\`, please check and retry`); 
        });
    }
});

Edit a Giveaway


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

    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g);
    const command = args.shift();

    if (command === "edit") {
        const messageID = args[0];

        client.giveawaysManager.edit(messageID, {
            addTime: 5000, // Add another 5 seconds to the giveaway length
            newWinnerCount: 3, // Set the new winner count to 3
            newPrize: "New Prize!" // Set the new prize
        }).then(() => {
            message.channel.createMessage(`Giveaway successfully edited!`);
        }).catch(() => {
            message.channel.createMessage(`An error has occured, please check and retry`);
        });
    }
});

Coming Soon Features

Here's the current planned list of upcoming and new features which will be release in Eris Giveaways.

  • Support for buttons