@hiratanagis/awardify
v0.0.7
Published
A Advance Discord Giveaway System
Maintainers
Readme
@hiratanagis/awardify
Advanced discord giveaways system with Support for Slash/Message commands and Discord Button interactions.
Installation
npm i @hiratanagis/awardify
------ or ---------------------
yarn add @hiratanagis/awardify
------ or ---------------------
pnpm add @hiratanagis/awardifyButton Support Documentation
awardify natively supports Discord Buttons (ButtonBuilder) instead of traditional emoji reactions for giveaway registration. This provides a cleaner and more interactive user experience.
Buttons Configuration Schema
When starting a giveaway or defining default settings in GiveawaysManagerOptions, you can supply a buttons object inside the default settings or GiveawayStartOptions:
| Property | Type | Description |
|---|---|---|
| join | ButtonBuilder | Required. The button displayed to join the giveaway. |
| leave | ButtonBuilder | Optional. The button displayed to leave the giveaway (typically sent ephemerally when a user tries to rejoin). |
| participants | ButtonBuilder | Optional. The button displayed to view participants next to the join button. |
| joinReply | string | MessageObject | Optional. Ephemeral message content or object sent to the user upon joining. |
| leaveReply | string | MessageObject | Optional. Ephemeral message content or object sent to the user upon leaving. |
Quick Start Example
Here is how you can configure and initialize the GiveawaysManager with buttons in your bot:
const { Client, GatewayIntentBits, ButtonBuilder, ButtonStyle } = require('discord.js');
const { GiveawaysManager } = require('@hiratanagis/awardify');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions
]
});
const manager = new GiveawaysManager(client, {
storage: './giveaways.json',
default: {
botsCanWin: false,
embedColor: '#FF0000',
embedColorEnd: '#000000',
reaction: null, // Set to null to use buttons instead of reaction emojis
buttons: {
join: new ButtonBuilder()
.setCustomId('join_giveaway')
.setEmoji('🎉')
.setLabel('{this.entrantIds.length}') // Displays dynamic participant count
.setStyle(ButtonStyle.Primary),
leave: new ButtonBuilder()
.setLabel('Leave Giveaway')
.setStyle(ButtonStyle.Danger),
participants: new ButtonBuilder()
.setCustomId('participants_giveaway')
.setLabel('Participants')
.setEmoji('👥')
.setStyle(ButtonStyle.Secondary),
joinReply: '✅ You have successfully entered the giveaway!',
leaveReply: '❌ You have left the giveaway.',
notAllowedToJoinReply: '❌ You are not allowed to join this giveaway'
}
}
});
client.on('ready', () => {
console.log('Bot is ready!');
});
client.login('YOUR_BOT_TOKEN');Dynamic Templates Evaluation
Any text provided to button labels, custom IDs, URLs, or replies can include bracketed template strings that will be dynamically evaluated in the context of the Giveaway instance.
Some useful template variables you can use:
{this.entrantIds.length}- The current count of participants in the giveaway.{this.prize}- The prize of the giveaway.{this.winnerCount}- The number of winners to be picked.{this.messageURL}- The Discord message URL of the giveaway.
For example, setting the join button's label to "{this.entrantIds.length}" will automatically update the button label dynamically on Discord whenever a user joins or leaves the giveaway.
Credits
- It is an edited fork of package
discord-giveawayswith button support.
