3.3.0 • Published 11 months ago

discord-giveaway-easy v3.3.0

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

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!)

3.2.2

11 months ago

3.3.0

11 months ago

3.2.1

11 months ago

3.2.0

11 months ago

3.2.3

11 months ago

3.1.9

1 year ago

3.1.8

1 year ago

3.1.7

2 years ago

3.1.6

2 years ago

3.1.5

2 years ago

3.0.0

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.10

2 years ago

2.1.9

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago