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

discord-giveaway-easy

v3.3.0

Published

A module allowing the simple creation of a discord giveaway with your bot supported by Discord.js^14.0.0

Downloads

28

Readme

Discord-Giveaway

  • A module allowing the simple creation of a discord giveaway with your client supported by Discord.js^14.0.0
  • The easiest to use giveaway module.

News

  • The finish and stop functionalities have been added directly to the buttons.
  • No need to manage the message, it is sent automatically with the manager.start().
  • Data modification features (emoji, color etc) have been added and are supported if you follow the detailed instructions below.

Installation

npm

NPM

Create a Giveaway.

const discord_giveaway = require("discord-giveaway");
const Discord = require("discord.js");
const intents = new Discord.IntentsBitField(3276799);
const client = new Discord.Client({intents});

client.on("ready", () => {
    console.log("I'm login !")
});

client.on("interactionCreate", async (interaction) => {

    let guild = interaction.guild
    let channel = interaction.channel

      if (interaction.isChatInputCommand() && interaction.commandName === 'giveaway') {

        const time = interaction.options.getString("time")
        const prize = interaction.options.getString("prize")
        const winnerNumber = interaction.options.getNumber("winner_number")

        let manager = new discord_giveaway.giveawaysManager(client);

        manager.start(message.channel, {
        time: time,
        prize: prize,
        winnerNumber: winnerNumber,
        interaction: message,
        buttonType: Discord.ButtonStyle.Primary,
        })
    
    }
});

Show data of the giveaway (panel)

The "private" parameter represents the argument that will be responsible for putting the message in ephemaral or not (optional)

const discord_giveaway = require("discord-giveaway");
const Discord = require("discord.js");
const intents = new Discord.IntentsBitField(3276799);
const client = new Discord.Client({intents});
  

client.giveawayPanelManager = new discord_giveaway.giveawaysPanel(bot) // ⚠️ don't forget so that the system works


client.on("ready", () => {
    console.log("I'm login !")
});

client.on("interactionCreate", async (interaction) => {

     if (interaction.isChatInputCommand() && interaction.commandName === 'gpanel') {
     
      let private = interaction.options.getBoolean("private")

      client.giveawayPanelManager.panel(message, private)
    
    }
});

Set new value to existing parameter (emoji, color)

The "newEmoji" and "newColor" parameters represent the arguments that will be responsible for replacing the other already existing parameters.

const discord_giveaway = require("discord-giveaway");
const Discord = require("discord.js");
const intents = new Discord.IntentsBitField(3276799);
const client = new Discord.Client({intents});
  

client.giveawayPanelManager = new discord_giveaway.giveawaysPanel(bot) // ⚠️ don't forget so that the system works


client.on("ready", () => {
    console.log("I'm login !")
});

client.on("messageCreate", async message => {

    if(message.content === "!giveaway setConfig") {

      let newEmoji = "✅"
      let newColor = "#ffffff"

      client.giveawayPanelManager.setConfig(message, {
      emoji: newEmoji,
      color: newColor
    })
    
    }
});

client.on("interactionCreate", async (interaction) => {

     if (interaction.isChatInputCommand() && interaction.commandName === 'gconfig') {
     
      let newEmoji = interaction.options.getString("emoji")
      let newColor = interaction.options.getString("color")
      let newGiveawayEnable = interaction.options.getString("enable")
      let newLanguage = interaction.options.getString("language")

     client.giveawayPanelManager.setConfig(message, {
          emoji: newEmoji,
          color: newColor,
          giveawayEnable: newGiveawayEnable,
          language: newLanguage
        })
    
    }
});

Image

Start Giveaway

img

Stop Giveaway

img

Reroll Giveaway and end giveaway

img img

Concrete example

The system below is compatible with the discord.js guide!

giveaway commands

const Discord = require('discord.js')
const discord_giveaway = require("discord-giveaway-easy")

module.exports = {

  data: new Discord.SlashCommandBuilder()
    .setName("giveaway")
    .setDescription("The manager of the giveaway")
    .setDMPermission(false)
    .setDefaultMemberPermissions(Discord.PermissionFlagsBits.ManageMessages)
    .addSubcommand(subcommand => 
      subcommand
      .setName('start')
			.setDescription('Start a giveaway')
			.addStringOption(option => 
        option.setName("titre")
        .setDescription("Title of giveaway")
        .setRequired(true)
        .setAutocomplete(false)
        )
      .addStringOption(option => 
        option.setName("time")
        .setDescription("Time of giveaway")
        .setRequired(true)
        .setAutocomplete(false)
        )
      .addNumberOption(option => 
        option.setName("winner_number")
        .setDescription("The number of the giveaway winner")
        .setRequired(true)
        .setAutocomplete(false)
        ),
      )
      .addSubcommand( subCommand =>
        subCommand
        .setName('set')
        .setDescription('Edit the current data.')
        .addStringOption(option => 
          option.setName("emoji")
          .setDescription("The new Emoji")
          .setRequired(false)
          .setAutocomplete(false)
          )
        .addStringOption(option => 
          option.setName("color")
          .setDescription("The new color")
          .setRequired(false)
          .setAutocomplete(false)
          )
        .addBooleanOption(option => 
          option.setName("enable")
          .setDescription("Disable giveaway system")
          .setRequired(false)
          )
        .addStringOption(option => 
          option.setName("language")
           .setDescription("New language")
           .setRequired(false)
           .setAutocomplete(false)
          ),
      )
      .addSubcommand( subCommand =>
        subCommand
        .setName('info')
        .setDescription('Give current data of the module')
        .addBooleanOption(option => 
          option.setName("priver")
          .setDescription("Choice to send privately or to everyone")
          .setRequired(false)
          ),
      ),
      
    

  async run(bot, message, args) {

    
      if (args.getSubcommand() === "start") {

        let title = args.getString("titre")
        let time = args.getString("time")
        let winnerNumber = args.getNumber("winner_number")
    
        let manager = new discord_giveaway.giveawaysManager(bot)
        
    
        manager.start(message.channel, {
          time: time,
          prize: title,
          winnerNumber: winnerNumber,
          buttonType: Discord.ButtonStyle.Primary,
          interaction: message
        })
      }



      if (args.getSubcommand() === "set") {

        let newEmoji = args.getString("emoji")
        let newColor = args.getString("color")
        let newGiveawayEnable = args.getBoolean("enable")
        let newLanguage = args.getString("language")
        
        bot.giveawayPanelManager.setConfig(message, {
          emoji: newEmoji,
          color: newColor,
          giveawayEnable: newGiveawayEnable,
          language: newLanguage
        })
      }



      if (args.getSubcommand() === "info") {

        let private = args.getBoolean("priver")
        bot.giveawayPanelManager.panel(message, private)
      }
    
    

  
  }


}

Other

To contact the owner of this module, you can join his discord server and ask him a question.
For anything else, ditto, join his discord server.

(careful, this discord server is on french!)