├── award.png
├── .env.example
├── src
├── handlers
│ ├── antiCrash.js
│ ├── clientEvents.js
│ ├── mongoose.js
│ └── slashCommands.js
├── commands
│ ├── Information
│ │ ├── ping.js
│ │ ├── help.js
│ │ ├── uptime.js
│ │ ├── invite.js
│ │ └── botinfo.js
│ └── Giveaways
│ │ ├── delete.js
│ │ ├── resume.js
│ │ ├── end.js
│ │ ├── pause.js
│ │ ├── reroll.js
│ │ ├── drop.js
│ │ ├── create.js
│ │ └── edit.js
├── config.js
├── events
│ └── client
│ │ ├── messageCreate.js
│ │ ├── guildDelete.js
│ │ ├── guildCreate.js
│ │ ├── ready.js
│ │ └── interactionCreate.js
├── utils
│ └── messages.js
├── Schema
│ └── giveaway.js
└── bot.js
├── package.json
├── LICENSE
├── index.js
└── README.md
/award.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unf6/award-bot/HEAD/award.png
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | TOKEN=
2 | CLIENT_ID=
3 | OWNERS=
4 | MONGO=
5 | COLOR=
6 | LOGS=
7 | everyoneMention=
8 |
--------------------------------------------------------------------------------
/src/handlers/antiCrash.js:
--------------------------------------------------------------------------------
1 | module.exports = (client) => {
2 | process.on("unhandledRejection", (reason, p) => {
3 | console.log(reason, p);
4 | });
5 | process.on("uncaughtException", (err, origin) => {
6 | console.log(err, origin);
7 | });
8 | process.on("uncaughtExceptionMonitor", (err, origin) => {
9 | console.log(err, origin);
10 | });
11 | };
--------------------------------------------------------------------------------
/src/handlers/clientEvents.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require("fs");
2 | const { Client } = require("discord.js");
3 | /**
4 | * @param {Client} client
5 | */
6 | module.exports = (client) => {
7 | readdirSync("./src/events/client/").forEach((file) => {
8 | const event = require(`../events/client/${file}`);
9 | client.on(event.name, (...args) => event.run(client, ...args));
10 | });
11 | };
--------------------------------------------------------------------------------
/src/commands/Information/ping.js:
--------------------------------------------------------------------------------
1 | const { EmbedBuilder } = require("discord.js");
2 |
3 | module.exports = {
4 | name: 'ping',
5 | description: 'Displays the bot ping',
6 | botPerms: [''],
7 | userPerms: [''],
8 | owner: false,
9 |
10 | run: async (client, interaction, args ) => {
11 |
12 | const embed = new EmbedBuilder()
13 | .setDescription(`${client.ws.ping} Ms`)
14 |
15 | interaction.followUp({ embeds: [embed] });
16 |
17 | }
18 | }
--------------------------------------------------------------------------------
/src/config.js:
--------------------------------------------------------------------------------
1 | require("dotenv").config();
2 |
3 | module.exports = {
4 | token: process.env.TOKEN || "", // your bot token
5 | clientID: process.env.CLIENT_ID || "", // your bot client id
6 | owners: process.env.OWNERS || "", // your account id
7 | mongourl: process.env.MONGO || "", //MongoDb Url
8 | embedcolor: process.env.COLOR || 0x303236, // embed colour
9 | logs: process.env.LOGS || "", // channel id for guild create and delete logs
10 | everyoneMention: process.env.everyoneMention || false,
11 |
12 | }
--------------------------------------------------------------------------------
/src/events/client/messageCreate.js:
--------------------------------------------------------------------------------
1 | const { EmbedBuilder, Message } = require("discord.js");
2 |
3 | module.exports = {
4 | name: "messageCreate",
5 | run: async (client, message) => {
6 | if (
7 | message.content === `<@${client.user.id}>` ||
8 | message.content === `<@!${client.user.id}>`
9 | )
10 | return message.reply({
11 | content: `**› Hi ${message.author} I'm **${client.user.username}**\nA Powerful Slash Giveaway Discord Bot**`,
12 | });
13 |
14 | },
15 | };
16 |
--------------------------------------------------------------------------------
/src/events/client/guildDelete.js:
--------------------------------------------------------------------------------
1 | const { EmbedBuilder } = require("discord.js");
2 |
3 | module.exports = {
4 | name: "guildDelete",
5 | run: async (client, guild) => {
6 | let channel = client.channels.cache.get(client.config.logs);
7 | let embed = new EmbedBuilder()
8 | .setAuthor({ name: `${client.user.username}#${client.user.discriminator} | ${client.user.id}`, iconURL: client.user.displayAvatarURL() })
9 | .setDescription(`left this ${guild.name}!`)
10 | .setColor("800080")
11 | channel.send({ embeds: [embed] })
12 | },
13 | };
14 |
--------------------------------------------------------------------------------
/src/utils/messages.js:
--------------------------------------------------------------------------------
1 | const config = require("../config")
2 |
3 | module.exports = {
4 |
5 | giveaway:
6 | (config.everyoneMention ? "@everyone\n\n" : "") +
7 | "🎉 **GIVEAWAY** 🎉",
8 | giveawayEnded:
9 | (config.everyoneMention ? "@everyone\n\n" : "") +
10 | "🎉 **GIVEAWAY ENDED** 🎉",
11 | inviteToParticipate: "React with 🎉 to participate!",
12 | dropMessage: "Be the first to react with 🎉 !",
13 | drawing: "Drawing: {timestamp}",
14 | winMessage: "Congratulations, {winners}! You won **{this.prize}**!",
15 | embedFooter: "Giveaways",
16 | noWinner: "Giveaway cancelled, no valid participations.",
17 | hostedBy: "Hosted by: {this.hostedBy}",
18 | winners: "winner(s)",
19 | endedAt: "Ended at",
20 |
21 | };
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Award-Bot",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1",
8 | "start": "node index.js"
9 | },
10 | "keywords": [],
11 | "author": "Rama 🐉'#9901",
12 | "license": "MIT",
13 | "dependencies": {
14 | "@discordjs/rest": "^1.2.0",
15 | "ascii-table": "^0.0.9",
16 | "chalk": "^4.1.2",
17 | "colors": "^1.4.0",
18 | "discord-giveaways": "^6.0.1",
19 | "discord-hybrid-sharding": "^1.7.4",
20 | "discord.js": "^14.5.0",
21 | "dotenv": "^16.0.3",
22 | "fs": "^0.0.1-security",
23 | "moment": "^2.29.4",
24 | "moment-duration-format": "^2.3.2",
25 | "mongoose": "^6.6.4",
26 | "ms": "^2.1.3",
27 | "os": "^0.1.2"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/events/client/guildCreate.js:
--------------------------------------------------------------------------------
1 | const { EmbedBuilder } = require("discord.js");
2 |
3 | module.exports = {
4 | name: "guildCreate",
5 | run: async (client, guild) => {
6 | const channel = await client.channels.fetch(client.config.logs);
7 | const embed = new EmbedBuilder()
8 | .setAuthor({ name: `${client.user.username}#${client.user.discriminator} | ${client.user.id}`, iconURL: client.user.displayAvatarURL() })
9 | .setDescription(`joined this ${guild.name}!`)
10 | .addFields(
11 | { name: 'GuildID', value: `\`${guild.id}\``, inline: true },
12 | { name: 'GuildOwner', value: `<@${guild.ownerId}> (\`${guild.ownerId}\`)`, inline: true },
13 | { name: "Guild Member Count", value: `${guild.memberCount}`, inline: true },
14 | )
15 | .setColor("800080")
16 | await channel.send({ embeds: [embed] })
17 | },
18 | };
19 |
--------------------------------------------------------------------------------
/src/commands/Information/help.js:
--------------------------------------------------------------------------------
1 | const { EmbedBuilder, Client } = require("discord.js");
2 |
3 | module.exports = {
4 | name: "help",
5 | description: "Shows a list of all commands",
6 |
7 | run: async (client, interaction) => {
8 |
9 | const embed = new EmbedBuilder()
10 |
11 | .setAuthor({ name: `${interaction.user.username}!`, iconURL: interaction.user.displayAvatarURL() })
12 | .setTitle(`${client.user.username} Help Menu`)
13 | .setDescription(`• Total Commands: **13**`)
14 | .addFields(
15 |
16 | { name: '❔ Information', value: `\`help,invite,ping,botinfo,uptime\``, inline: true },
17 | { name: '🎉 Giveaways', value: `\`create,delete,drop,edit,end,pause,reroll,resume\``, inline: true },
18 |
19 | )
20 |
21 | interaction.followUp({ embeds: [embed] });
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/commands/Giveaways/delete.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "delete",
3 | description: "Delete a giveaway.",
4 | options: [
5 | {
6 | name: "message_id",
7 | description: "Message id for giveaway to delete",
8 | type: 3,
9 | required: true
10 | }
11 | ],
12 |
13 | run: async(client, interaction) => {
14 | const giveawayId = interaction.options.getString('message_id');
15 | const fetchGiveaway = client.giveawaysManager.giveaways.find(r => r.messageId === giveawayId);
16 | if (!fetchGiveaway) {
17 | return interaction.followUp({ content: `Unable to find giveaway \`${giveawayId}\``, ephemeral: true });
18 | }
19 | await client.giveawaysManager.delete(giveawayId);
20 | interaction.followUp({ content: `✅ Successfully deleted giveaway with id \`${giveawayId}\`` })
21 | }
22 | }
--------------------------------------------------------------------------------
/src/events/client/ready.js:
--------------------------------------------------------------------------------
1 | const { Activity } = require("discord.js");
2 | const fs = require("fs");
3 | const chalk = require("chalk");
4 |
5 | module.exports = {
6 | name: "ready",
7 | run: async (client) => {
8 |
9 | console.log(`${client.user.username} online!`, "ready");
10 |
11 | const activities = [
12 | { name: `/help | ${client.guilds.cache.size} Guilds`, type: 3 }, // WATCHING
13 | { name: `Discord.js v14 by Liaam#9901 `, type: 3 }, // WATCHING
14 | ];
15 | const status = ["online"];
16 | let i = 0;
17 | setInterval(() => {
18 | if (i >= activities.length) i = 0;
19 | client.user.setActivity(activities[i]);
20 | i++;
21 | }, 5000);
22 |
23 | let s = 0;
24 | setInterval(() => {
25 | if (s >= activities.length) s = 0;
26 | client.user.setStatus(status[s]);
27 | s++;
28 | }, 30000);
29 | },
30 | };
31 |
--------------------------------------------------------------------------------
/src/handlers/mongoose.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 | const { Client } = require("discord.js");
3 | const chalk = require("chalk");
4 | const config = require("../config");
5 |
6 | /**
7 | * @param {Client} client
8 | */
9 | module.exports = (client) => {
10 | const dbOptions = {
11 | useNewUrlParser: true,
12 | autoIndex: false,
13 | connectTimeoutMS: 10000,
14 | family: 4,
15 | useUnifiedTopology: true,
16 | };
17 | mongoose.connect(process.env.MONGO || client.config.mongourl, dbOptions);
18 | mongoose.Promise = global.Promise;
19 | mongoose.connection.on("connected", () => {
20 | console.log(console.log(`${chalk.grey.bold('[INFO] ')}${chalk.green.bold('Connected to the database!')}`));
21 | });
22 | mongoose.connection.on("err", (err) => {
23 | console.log(`Mongoose connection error: \n ${err.stack}`, "error");
24 | });
25 | mongoose.connection.on("disconnected", () => {
26 | console.log("Mongoose disconnected");
27 | });
28 | };
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Liaam
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/commands/Information/uptime.js:
--------------------------------------------------------------------------------
1 | const { Client, EmbedBuilder } = require("discord.js");
2 | const moment = require("moment");
3 |
4 | module.exports = {
5 | name: "uptime",
6 | description: "Display client uptime",
7 | /**
8 | *
9 | * @param {Client} client
10 | * @param {CommandInteraction} interaction
11 | */
12 | run: async (client, interaction) => {
13 | const d = moment.duration(interaction.client.uptime);
14 | const days = d.days() == 1 ? `${d.days()} day` : `${d.days()} days`;
15 | const hours = d.hours() == 1 ? `${d.hours()} hour` : `${d.hours()} hours`;
16 | const minutes =
17 | d.minutes() == 1 ? `${d.minutes()} minute` : `${d.minutes()} minutes`;
18 | const seconds =
19 | d.seconds() == 1 ? `${d.seconds()} second` : `${d.seconds()} seconds`;
20 | const date = moment().subtract(d, "ms").format("dddd, MMMM Do YYYY");
21 |
22 | const replyEmbed = new EmbedBuilder()
23 | .setTitle(`${client.user.username} Uptime`)
24 | .setDescription(
25 | `\`\`\`prolog\n${days}, ${hours}, ${minutes}, and ${seconds}\`\`\``
26 | )
27 | .setTimestamp()
28 | .setColor("Blue");
29 |
30 | interaction.followUp({ embeds: [replyEmbed] });
31 | },
32 | };
--------------------------------------------------------------------------------
/src/commands/Giveaways/resume.js:
--------------------------------------------------------------------------------
1 | const { Client, ApplicationCommandOptionType } = require("discord.js");
2 |
3 | module.exports = {
4 | name: "resume",
5 | description: "resume a giveaway",
6 | options: [
7 | {
8 | name: "giveaway",
9 | description: "The giveaway to resume (message ID)",
10 | type: ApplicationCommandOptionType.String,
11 | required: true,
12 | },
13 | ],
14 |
15 | run: async (client, interaction, args) => {
16 | const giveaway = interaction.options.getString("giveaway");
17 |
18 | const giveawaysObj =
19 |
20 | client.giveawaysManager.giveaways.find(
21 | (g) => g.messageId === giveaway && g.guildId === interaction.guild.id
22 | );
23 |
24 | if (!giveawaysObj) {
25 | interaction.followUp("Giveaway not found.");
26 | return;
27 | }
28 | if (!giveawaysObj.pauseOptions.isPaused) {
29 | interaction.followUp("Giveaway is already paused.");
30 | return;
31 | }
32 | client.giveawaysManager.unpause(giveawaysObj.messageId).then(() => {
33 | return interaction.followUp("Giveaway paused.");
34 | });
35 | },
36 | };
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const Cluster = require('discord-hybrid-sharding');
2 |
3 | const manager = new Cluster.Manager(`./src/bot.js`, {
4 | totalShards: 1,
5 | shardsPerClusters: 1,
6 | totalClusters: 1,
7 | mode: "process",
8 | token: process.env.TOKEN,
9 | });
10 |
11 | manager.extend(
12 | new Cluster.HeartbeatManager({
13 | interval: 2000,
14 | maxMissedHeartbeats: 5,
15 | })
16 | );
17 |
18 | manager.on("clusterCreate", (cluster) => {
19 | console.log(`Launched Cluster ${cluster.id}`);
20 |
21 | cluster.on("ready", () => {
22 | console.log(`Cluster ${cluster.id} seems ready`);
23 | });
24 |
25 | cluster.on("reconnecting", () => {
26 | console.log(`Cluster ${cluster.id} is reconnecting`);
27 | });
28 |
29 | cluster.on("disconnect", async () => {
30 | console.log(`Cluster ${cluster.id} disconnected`);
31 | });
32 |
33 | cluster.on("death", () => {
34 | console.log(`Cluster ${cluster.id} died`);
35 | });
36 |
37 | cluster.on("error", () => {
38 | console.log(`Cluster ${cluster.id} errored`);
39 | });
40 |
41 | cluster.on("spawn", () => {
42 | console.log(`Cluster ${cluster.id} has spawned`);
43 | });
44 | });
45 | manager.spawn({ timeout: -1 });
46 |
--------------------------------------------------------------------------------
/src/commands/Giveaways/end.js:
--------------------------------------------------------------------------------
1 | const { Client, ApplicationCommandOptionType } = require("discord.js");
2 |
3 | module.exports = {
4 | name: "end",
5 | description: "end a giveaway",
6 | userPerms: ['ManageGuild'],
7 | botPerms: ['ManageGuild'],
8 | owner: false,
9 |
10 | options: [
11 | {
12 | name: "giveaway",
13 | description: "The giveaway to end (message ID)",
14 | type: ApplicationCommandOptionType.String,
15 | required: true,
16 | },
17 | ],
18 |
19 | run: async (client, interaction, args) => {
20 |
21 | const giveaway = interaction.options.getString("giveaway");
22 |
23 | client.giveawaysManager.giveaways.find(
24 | (g) => g.messageId === giveaway && g.guildId === interaction.guild.id
25 | );
26 |
27 | if (!giveawaysObj) {
28 | interaction.followUp("Giveaway not found.");
29 | return;
30 | }
31 | if (giveawaysObj.ended) {
32 | interaction.followUp("Giveaway already ended.");
33 | return;
34 | }
35 | client.giveawaysManager.end(giveawaysObj.messageId).then(() => {
36 | return interaction.followUp("Giveaway ended.");
37 | });
38 | },
39 | };
--------------------------------------------------------------------------------
/src/commands/Giveaways/pause.js:
--------------------------------------------------------------------------------
1 | const { Client, ApplicationCommandOptionType } = require("discord.js");
2 |
3 | module.exports = {
4 | name: "pause",
5 | description: "pause a giveaway",
6 | userPerms: ['ManageGuild'],
7 | botPerms: ['ManageGuild'],
8 | owner: false,
9 |
10 | options: [
11 | {
12 | name: "giveaway",
13 | description: "The giveaway to pause (message ID)",
14 | type: ApplicationCommandOptionType.String,
15 | required: true,
16 | },
17 | ],
18 |
19 | run: async (client, interaction, args) => {
20 |
21 | const giveaway = interaction.options.getString("giveaway");
22 |
23 | client.giveawaysManager.giveaways.find(
24 | (g) => g.messageId === giveaway && g.guildId === interaction.guild.id
25 | );
26 |
27 | if (!giveawaysObj) {
28 | interaction.followUp("Giveaway not found.");
29 | return;
30 | }
31 | if (giveawaysObj.pauseOptions.isPaused) {
32 | interaction.followUp("Giveaway is already paused.");
33 | return;
34 | }
35 | client.giveawaysManager.pause(giveawaysObj.messageId).then(() => {
36 | return interaction.followUp("Giveaway paused.");
37 | });
38 | },
39 | };
--------------------------------------------------------------------------------
/src/commands/Giveaways/reroll.js:
--------------------------------------------------------------------------------
1 | const { Client, ApplicationCommandOptionType } = require("discord.js");
2 |
3 | module.exports = {
4 | name: "reroll",
5 | description: "reroll a giveaway",
6 | userPerms: ['ManageGuild'],
7 | botPerms: ['ManageGuild'],
8 | owner: false,
9 |
10 | options: [
11 | {
12 | name: "giveaway",
13 | description: "The giveaway to reroll (message ID)",
14 | type: ApplicationCommandOptionType.String,
15 | required: true,
16 | },
17 | ],
18 |
19 | run: async (client, interaction, args) => {
20 |
21 | const giveaway = interaction.options.getString("giveaway");
22 |
23 | const giveawaysObj =
24 |
25 | client.giveawaysManager.giveaways.find(
26 | (g) => g.messageId === giveaway && g.guildId === interaction.guild.id
27 | );
28 |
29 | if (!giveawaysObj) {
30 | interaction.followUp("Giveaway not found.");
31 | return;
32 | }
33 | if (!giveawaysObj.ended) {
34 | interaction.followUp("Giveaway hasnt ended yet.");
35 | return;
36 | }
37 | client.giveawaysManager.reroll(giveawaysObj.messageId).then(() => {
38 | return interaction.followUp("Giveaway ended.");
39 | });
40 | },
41 | };
--------------------------------------------------------------------------------
/src/commands/Information/invite.js:
--------------------------------------------------------------------------------
1 | const {
2 | Client,
3 | EmbedBuilder,
4 | ActionRowBuilder,
5 | ButtonBuilder,
6 | ButtonStyle
7 | } = require("discord.js");
8 |
9 | module.exports = {
10 | name: "invite",
11 | description: "Get the bot's invite link.",
12 | run: async (client, interaction, args) => {
13 |
14 | const emb = new EmbedBuilder()
15 | .setColor("Blue")
16 | .setTitle(`Invite ${client.user.username}`)
17 | .setDescription(
18 | `**${client.user.username}**,Thank you for choosing me to use you can click the button below to invite me!`
19 | )
20 | .setThumbnail(client.user.displayAvatarURL({ dynamic: true }))
21 | .setFooter({ text: `Award-bot - Made By ❤️ Liaam` });
22 |
23 | const row = new ActionRowBuilder().addComponents(
24 | new ButtonBuilder()
25 | .setURL(
26 | `https://discord.com/api/oauth2/authorize?client_id=${client.user.id}&permissions=36768832&scope=applications.commands%20bot`
27 | )
28 | .setLabel("Invite")
29 | .setStyle(ButtonStyle.Link),
30 |
31 | new ButtonBuilder()
32 | .setLabel("Github")
33 | .setStyle(ButtonStyle.Link)
34 | .setURL("https://github.com/liaam-dev/award-bot"),
35 |
36 | new ButtonBuilder()
37 | .setURL(
38 | `https://discord.gg/PeV2Qj5SHD`
39 | )
40 | .setLabel("Support")
41 | .setStyle(ButtonStyle.Link)
42 |
43 | );
44 |
45 | interaction.followUp({ content: ` `, embeds: [emb], components: [row] });
46 | },
47 | };
--------------------------------------------------------------------------------
/src/commands/Giveaways/drop.js:
--------------------------------------------------------------------------------
1 | const { Client, ApplicationCommandOptionType, ChannelType } = require("discord.js");
2 | const ms = require("ms");
3 | const messages = require("../../utils/messages");
4 | module.exports = {
5 | name: "drop",
6 | description: "start a giveaway",
7 | userPerms: ['ManageGuild'],
8 | botPerms: ['ManageGuild'],
9 | owner: false,
10 |
11 | options: [
12 | {
13 | name: "winners",
14 | description: "How many winners the drop should have",
15 | type: ApplicationCommandOptionType.Number,
16 | required: true,
17 | },
18 | {
19 | name: "prize",
20 | description: "What the prize of the drop should be",
21 | type: ApplicationCommandOptionType.String,
22 | required: true,
23 | },
24 | {
25 | name: "channel",
26 | description: "The channel to start the drop in",
27 | type: ApplicationCommandOptionType.Channel,
28 | ChannelTypes: ['GUILD_TEXT'],
29 | required: true,
30 | },
31 | ],
32 |
33 | run: async (client, interaction, args) => {
34 |
35 | const winners = interaction.options.getNumber("winners");
36 | const prize = interaction.options.getString("prize");
37 | const channel = interaction.options.getChannel("channel");
38 |
39 | client.giveawaysManager.start(channel, {
40 | isDrop: true,
41 | winnerCount: winners,
42 | prize,
43 | hostedBy: interaction.member,
44 | messages,
45 | });
46 |
47 | return interaction.followUp("Drop started!");
48 | },
49 | };
--------------------------------------------------------------------------------
/src/Schema/giveaway.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | const giveawaySchema = new mongoose.Schema(
4 | {
5 | messageId: String,
6 | channelId: String,
7 | guildId: String,
8 | startAt: Number,
9 | endAt: Number,
10 | ended: Boolean,
11 | winnerCount: Number,
12 | prize: String,
13 | messages: {
14 | giveaway: String,
15 | giveawayEnded: String,
16 | inviteToParticipate: String,
17 | drawing: String,
18 | dropMessage: String,
19 | winMessage: mongoose.Mixed,
20 | embedFooter: mongoose.Mixed,
21 | noWinner: String,
22 | winners: String,
23 | endedAt: String,
24 | hostedBy: String,
25 | },
26 | thumbnail: String,
27 | hostedBy: String,
28 | winnerIds: { type: [String], default: undefined },
29 | reaction: mongoose.Mixed,
30 | botsCanWin: Boolean,
31 | embedColor: mongoose.Mixed,
32 | embedColorEnd: mongoose.Mixed,
33 | exemptPermissions: { type: [], default: undefined },
34 | exemptMembers: String,
35 | bonusEntries: String,
36 | extraData: mongoose.Mixed,
37 | lastChance: {
38 | enabled: Boolean,
39 | content: String,
40 | threshold: Number,
41 | embedColor: mongoose.Mixed,
42 | },
43 | pauseOptions: {
44 | isPaused: Boolean,
45 | content: String,
46 | unPauseAfter: Number,
47 | embedColor: mongoose.Mixed,
48 | durationAfterPause: Number,
49 | },
50 | isDrop: Boolean,
51 | allowedMentions: {
52 | parse: { type: [String], default: undefined },
53 | users: { type: [String], default: undefined },
54 | roles: { type: [String], default: undefined },
55 | },
56 | },
57 | { id: false }
58 | );
59 |
60 | module.exports = mongoose.model("giveaways", giveawaySchema);
--------------------------------------------------------------------------------
/src/handlers/slashCommands.js:
--------------------------------------------------------------------------------
1 | const { readdirSync } = require('fs');
2 | const { PermissionsBitField, Routes, Client } = require('discord.js');
3 | const { REST } = require('@discordjs/rest');
4 | /**
5 | * @param {Client} client
6 | */
7 | module.exports = (client) => {
8 | const data = [];
9 | let count = 0;
10 | readdirSync("./src/commands/").forEach((dir) => {
11 | const slashCommandFile = readdirSync(`./src/commands/${dir}/`).filter((files) => files.endsWith(".js"));
12 |
13 | for (const file of slashCommandFile) {
14 | const slashCommand = require(`../commands/${dir}/${file}`);
15 | if (!slashCommand.name) return console.error(`slashCommandNameError: ${slashCommand.split(".")[0]} application command name is required.`);
16 | if (!slashCommand.description) return console.error(`slashCommandDescriptionError: ${slashCommand.split(".")[0]} application command description is required.`);
17 | client.slashCommands.set(slashCommand.name, slashCommand);
18 |
19 | data.push({
20 | name: slashCommand.name,
21 | description: slashCommand.description,
22 | type: slashCommand.type,
23 | options: slashCommand.options ? slashCommand.options : null,
24 | default_member_permissions: slashCommand.default_member_permissions ? PermissionsBitField.resolve(slashCommand.default_member_permissions).toString() : null
25 | });
26 | count++;
27 | }
28 | });
29 | console.log(`Loaded: ${count} SlashCommands (/)`);
30 | const rest = new REST({ version: '10' }).setToken(client.config.token);
31 | (async () => {
32 | try {
33 | console.log('Started refreshing application (/) commands.');
34 | await rest.put(Routes.applicationCommands(client.config.clientID), { body: data });
35 | console.log('Successfully reloaded application (/) commands.');
36 | } catch (error) {
37 | console.error(error);
38 | }
39 | })();
40 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 | A feature-rich Giveaway Bot For Discord Written In Discord.js v14. Ft. Slash Commands. Make Giveaways and more..!
11 |
12 |
13 |
14 | [](https://repl.it/github/unf6/award-bot)
15 | [](https://glitch.com/edit/#!/import/github/unf6/award-bot)
16 |
17 | 
18 | 
19 | 
20 | 
21 | 
22 |
23 | ### Installation
24 |
25 | 1. Get a BOT_TOKEN at [Discord Developer Portal](https://discord.com/developers/applications)
26 |
27 | 2. Clone the repo
28 |
29 | ```sh
30 | git clone https://github.com/liaam-dev/award-bot.git
31 | ```
32 |
33 | 3. Install NPM packages
34 |
35 | ```sh
36 | npm install
37 | ```
38 |
39 | 4. Enter your BOT_TOKEN in `config.js`
40 |
41 | 5. Run Bot: node index.js
42 |
43 | ## Intents
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |