https://github.com/kabirjaipal/real-giveaways
An advanced Discord Giveaway System with button interactions.
https://github.com/kabirjaipal/real-giveaways
btn-giveaway discord discord-bot discord-buttons discord-giveaways discord-js giveawaybot giveaways giveaways-button npm
Last synced: 6 months ago
JSON representation
An advanced Discord Giveaway System with button interactions.
- Host: GitHub
- URL: https://github.com/kabirjaipal/real-giveaways
- Owner: kabirjaipal
- License: mit
- Created: 2022-12-31T10:28:35.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-03T08:30:12.000Z (over 1 year ago)
- Last Synced: 2025-05-05T04:47:45.923Z (6 months ago)
- Topics: btn-giveaway, discord, discord-bot, discord-buttons, discord-giveaways, discord-js, giveawaybot, giveaways, giveaways-button, npm
- Language: JavaScript
- Homepage:
- Size: 78.1 KB
- Stars: 14
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Real-Giveaway
Advance discord giveaways system with Support Slash/Message support
# Download
```cli
npm i real-giveaways
------ or ---------------------
yarn add real-giveaways
```
# Example
**_
[](https://discord.gg/PcUVWApWN3)
_**
# Setting up
### Client values
```js
const { Client, GatewayIntentBits, Colors } = require("discord.js");
const { Manager } = require("real-giveaways");
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.MessageContent,
],
});
const manager = new Manager(client, {
embedColor: Colors.Blurple,
pingEveryone: false,
emoji: "🎁",
});
client.on("ready", () => {
console.log(`Bot is Running`);
manager.connect("Mongo_Uri");
});
```
### For custom embed
```js
// for custom embed
class CustomManager extends Manager {
GiveawayStartEmbed(giveaway) {
let embed = new EmbedBuilder().setTitle(`Giveway Started`);
return embed;
}
GiveawayEndNoWinnerEmbed(giveaway) {
let embed = new EmbedBuilder().setTitle(`Giveway Ended No Winner`);
return embed;
}
GiveawayEndWinnerEmbed(giveaway) {
let embed = new EmbedBuilder().setTitle(`Giveway Ended Winners`);
return embed;
}
}
const manager = new CustomManager(client, {
embedColor: Colors.Blurple,
pingEveryone: false,
emoji: "🎁",
});
```
### Commands
```js
client.on("interactionCreate", async (interaction) => {
await interaction.deferReply({ ephemeral: true }).catch((e) => {});
if (interaction.isChatInputCommand()) {
// code
const cmdName = interaction.commandName;
switch (cmdName) {
case "start":
{
const channel = interaction.options.getChannel("channel");
const prize = interaction.options.getString("prize");
const winnerCount = interaction.options.getNumber("winnercount");
const duration = interaction.options.getString("duration");
interaction.followUp({
content: `Giveaway Started`,
ephemeral: true,
});
manager
.start(interaction, {
channel: channel,
duration: duration,
prize: prize,
winnerCount: winnerCount,
})
.catch((e) => {
console.log(e);
});
}
break;
case "deleteall":
{
const data = await manager.deleteall(interaction.guildId);
interaction.followUp({
content: `${data?.deleted} Giveaways Deleted`,
});
}
break;
case "delete":
{
let messageId = interaction.options.getString("messageid", true);
let deleted = await manager.deleteGiveaway(messageId);
interaction.followUp({
content: `Giveaway ${deleted ? "Deleted" : "Not Deleted"}`,
});
}
break;
case "edit":
{
let messageId = interaction.options.getString("messageid", true);
let prize = interaction.options.getString("prize", true);
let wincount = interaction.options.getString("wincount", true);
let edited = await manager.editGiveaway(messageId, {
prize: prize,
winCount: wincount,
});
if (edited) {
interaction.followUp({
content: `Giveaway Edited`,
});
} else {
interaction.followUp({
content: `Invalid Giveaway`,
});
}
}
break;
case "reroll":
{
let messageId = interaction.options.getString("messageid", true);
let rerolled = await manager.rerollGiveaway(messageId);
if (rerolled) {
interaction.followUp({
content: `Giveaway Rerolled`,
});
} else {
interaction.followUp({
content: `Invalid Giveaway`,
});
}
}
break;
case "end":
{
let messageId = interaction.options.getString("messageid", true);
let ended = await manager.endGiveaway(messageId);
if (ended) {
interaction.followUp({
content: `Giveaway Ended`,
});
} else {
interaction.followUp({
content: `Invalid Giveaway`,
});
}
}
break;
case "ping":
{
return interaction.followUp({
content: `Pong :: \`${client.ws.ping}\``,
ephemeral: true,
});
}
break;
default:
break;
}
}
});
```
### Manager Events
```js
let embed = new EmbedBuilder().setColor("Blurple");
manager.on("GiveawayReady", (name) => {
console.log(`${name} is Ready`);
});
manager.on("GiveawayStarted", (message, giveaway) => {
// console.log("GiveawayStarted");
message.reply({
embeds: [embed.setDescription(`Giveaway Started`)],
});
});
manager.on("GiveawayWinner", (message, giveaway) => {
// console.log("GiveawayWinner");
let Gwinners = giveaway.winners
.map((winner) => `<@${winner.userID}>`)
.join(", ");
message.channel?.send({
content: Gwinners,
embeds: [
embed.setDescription(
`${Gwinners} Won The \`${giveaway.prize}\` Giveaway Prize. Hosted By <@${giveaway.hostedBy}>`
),
],
});
giveaway.winners.map(async (user) => {
const u = await message.guild.members.fetch(user.userID);
u.send({
embeds: [
embed.setDescription(
`You Won The Giveaway [\`Giveaway Link\`](${message.url})`
),
],
});
});
});
manager.on("GiveawayRerolled", (message, giveaway) => {
// console.log("GiveawayRerolled");
message.reply({
embeds: [embed.setDescription(`\`${giveaway.prize}\` Giveaway Rerolled`)],
});
});
manager.on("NoWinner", (message, giveaway) => {
message.reply({
embeds: [embed.setDescription(`No One Won ${giveaway.prize}`)],
});
});
manager.on("InvalidGiveaway", (member, giveaway) => {
member.send({
embeds: [embed.setDescription(`You are Joining in Ended Giveaway`)],
});
});
manager.on("UserJoinGiveaway", (member, giveaway) => {
member.send({
embeds: [embed.setDescription(`You Joined ${giveaway.prize} Giveaway`)],
});
});
manager.on("UserLeftGiveaway", (member, giveaway) => {
member.send({
embeds: [embed.setDescription(`You Left ${giveaway.prize} Giveaway`)],
});
});
```
### Bugs, glitches and issues
If you encounter any problems feel free to open an issue in our GitHub repository or join the [Discord server](https://discord.gg/PcUVWApWN3).