Compare commits

...

2 commits

Author SHA1 Message Date
14f7ba48e8
Updated README.md 2023-11-26 22:41:03 +13:00
45fe6df464
Updated a lot of things 2023-11-26 22:26:08 +13:00
66 changed files with 2609 additions and 5587 deletions

View file

@ -1,18 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
open-pull-requests-limit: 5
reviewers:
- EmotionChild
target-branch: "development"
labels:
- "npm"
- "dependencies"

3
.gitignore vendored
View file

@ -1,4 +1,3 @@
node_modules node_modules
giveaways.js giveaways.js
config.json config.json
giveaways.json

View file

@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier same "printed page" as the copyright notice for easier
identification within third-party archives. identification within third-party archives.
Copyright 2023 EmotionChild Copyright 2023 Toastie_t0ast
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View file

@ -1,38 +1,46 @@
# Giveaway-Child # Holana
## Updates
- Update discord.js version to v13.
- Format the code looks more cleaner.
- Minor bot fixes and improvements.
## Requirements ## Requirements
- Nodejs v16 - Bot needs v16 of nodejs to work
- Invite your bot with bot and applications scope - Invite your bot with `bot` and `applications.commands` scope
- Bot only uses slash commands, message content no longer exists.
- Bot currently supports v14 of discord.js.
## Features ## Features
- Fast giveaways created using the best databases, like: mongodb, quick.db, .etc - Lightning fast giveaways created using best databases, like: mongodb, quick.db, etc.
- LAST CHANCE TO ENTER warning when a giveaway is about to end. - LAST CHANCE TO ENTER warning when giveaway is about to end.
- Slash commands for faster giveaway creating. - Slash commands for faster and simpler giveaway creating.
Drop giveaway ability, drop giveaways anytime in your server with the drop command. - Drop giveaway ability, drop giveaway anytime in your server with drop command.
- Pause and un-pause giveaway feature. - Pause and un-pause giveaways.
## Links ## Links
- 🔗 [Invite Link](https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=8&scope=bot) - 🔗 [Invite Link](https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=8&scope=bot)
- [Support Server Link](https://discord.gg/SVQVzJq) - [Support Server Link](https://discord.gg/etQdZxSyEH)
- 📑 [Commands](https://docs.elliebot.net/Giveaway-Child/Commands/) - 📑 [Commands](https://docs.elliebot.net/Giveaway-child/Commands)
- 🌐 [Website](https://docs.elliebot.net/coming_soon) - 🌐 [Website](https://docs.elliebot.net/category/holana)
## Custom/External Database setup
- Read the [README](Database%20Examples/README.md) file and you are good to go to use custom db's.
## Setup ## Setup
- `npm i` ## Custom/External Database setup
- Pick a database from the Database Examples folder.
- Just copy and paste it into the [index file](index.js) - Check the example folder to get the custom database examples
- Fill out the [config file](config.example.json) and save it as config.js.
- Then run the bot with `npm run start` ## Manual setup on local machine
- Run command `npm i`
- Pick a database from `Database Examples` folder and copy it to `index.js` file.
- Fill the configurations.
- Run command `npm run start`
## Credits ## Credits
**Thanks to [Androz](https://github.com/Androz2091) for his package which make this bot possible [discord-giveaways](https://www.npmjs.com/package/discord-giveaways) give him a star for his work.** **Thanks to [Androz](https://github.com/Androz2091) for his package which make this bot possible [discord-giveaways](https://www.npmjs.com/package/discord-giveaways) give him a star for his work.**

68
commands/drop.js Normal file
View file

@ -0,0 +1,68 @@
const Discord = require("discord.js");
const messages = require("../utils/messages.js");
module.exports = {
description: "Create a drop giveaway",
options: [
{
name: "winners",
description: "How many winners the giveaway should have",
type: Discord.ApplicationCommandOptionType.Integer,
required: true,
},
{
name: "prize",
description: "What the prize of the giveaway should be",
type: Discord.ApplicationCommandOptionType.String,
required: true,
},
{
name: "channel",
description: "The channel to start the giveaway in",
type: Discord.ApplicationCommandOptionType.Channel,
required: true,
},
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (
!interaction.member.permissions.has("MANAGE_MESSAGES") &&
!interaction.member.roles.cache.some((r) => r.name === "Giveaways")
) {
return interaction.reply({
content:
":x: You need to have the manage messages permissions to start giveaways.",
ephemeral: true,
});
}
const giveawayChannel = interaction.options.getChannel("channel");
const giveawayWinnerCount = interaction.options.getInteger("winners");
const giveawayPrize = interaction.options.getString("prize");
if (!giveawayChannel.isTextBased()) {
return interaction.reply({
content: ":x: Selected channel is not text-based.",
ephemeral: true,
});
}
// Start the giveaway
client.giveawaysManager.start(giveawayChannel, {
// The number of winners for this drop
winnerCount: giveawayWinnerCount,
// The prize of the giveaway
prize: giveawayPrize,
// Who hosts this giveaway
hostedBy: client.config.hostedBy ? interaction.user : null,
// specify drop
isDrop: true,
// Messages
messages,
});
interaction.reply(`Giveaway started in ${giveawayChannel}!`);
},
};

71
commands/end.js Normal file
View file

@ -0,0 +1,71 @@
const Discord = require("discord.js");
module.exports = {
description: "End a giveaway",
options: [
{
name: "giveaway",
description: "The giveaway to end (message ID or giveaway prize)",
type: Discord.ApplicationCommandOptionType.String,
required: true,
},
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (
!interaction.member.permissions.has("MANAGE_MESSAGES") &&
!interaction.member.roles.cache.some((r) => r.name === "Giveaways")
) {
return interaction.reply({
content:
":x: You need to have the manage messages permissions to end giveaways.",
ephemeral: true,
});
}
const query = interaction.options.getString("giveaway");
// try to found the giveaway with prize then with ID
const giveaway =
// Search with giveaway prize
client.giveawaysManager.giveaways.find(
(g) => g.prize === query && g.guildId === interaction.guild.id
) ||
// Search with giveaway ID
client.giveawaysManager.giveaways.find(
(g) => g.messageId === query && g.guildId === interaction.guild.id
);
// If no giveaway was found
if (!giveaway) {
return interaction.reply({
content: "Unable to find a giveaway for `" + query + "`.",
ephemeral: true,
});
}
if (giveaway.ended) {
return interaction.reply({
content: "This giveaway is already ended.",
ephemeral: true,
});
}
// Edit the giveaway
client.giveawaysManager
.end(giveaway.messageId)
// Success message
.then(() => {
// Success message
interaction.reply("Giveaway ended!");
})
.catch((e) => {
interaction.reply({
content: e,
ephemeral: true,
});
});
},
};

44
commands/help.js Normal file
View file

@ -0,0 +1,44 @@
const messages = require("../utils/messages");
const {
EmbedBuilder,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
} = require("discord.js");
module.exports = {
name: "help",
description: "Get all Bot Commands",
run: async (client, interaction) => {
let helpembed = new EmbedBuilder();
helpembed.setAuthor({ name: `Commands of ${client.user.username}` });
helpembed.setColor("#2f3136");
helpembed.setThumbnail(
"https://cdn.discordapp.com/attachments/765441543100170271/837111290265993246/196270_IDaqfU3u.png"
);
client.commands.map((cmd) => {
helpembed.addFields({
name: `\`${cmd.name}\``,
value: `${cmd.description}`,
});
});
helpembed.setTimestamp();
helpembed.setFooter({ text: `© Holana | Have a nice day!` });
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setEmoji("865572290065072128")
.setLabel(`Invite ${client.user.username}`)
.setURL(
`https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=8&scope=bot%20applications.commands`
)
.setStyle(ButtonStyle.Link)
);
await interaction.reply({
embeds: [helpembed],
components: [row],
ephemeral: true,
});
},
};

35
commands/invite.js Normal file
View file

@ -0,0 +1,35 @@
const messages = require("../utils/messages");
const {
EmbedBuilder,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
} = require("discord.js");
module.exports = {
name: "invite",
description: "Get Invite Link for Holana",
run: async (client, interaction) => {
let invite = new EmbedBuilder()
.setTitle(`${interaction.user.tag}`)
.setDescription("You can invite the bot by clicking on the below button.")
.setColor("#2f3136")
.setFooter({ text: `© Holana | Have a nice day!` });
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setEmoji("865572290065072128")
.setLabel(`Invite ${client.user.username}`)
.setURL(
`https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=8&scope=bot%20applications.commands`
)
.setStyle(ButtonStyle.Link)
);
await interaction.reply({
embeds: [invite],
components: [row],
ephemeral: true,
});
},
};

71
commands/pause.js Normal file
View file

@ -0,0 +1,71 @@
const Discord = require("discord.js");
module.exports = {
description: "Pause a giveaway",
options: [
{
name: "giveaway",
description: "The giveaway to pause (message ID or giveaway prize)",
type: Discord.ApplicationCommandOptionType.String,
required: true,
},
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (
!interaction.member.permissions.has("MANAGE_MESSAGES") &&
!interaction.member.roles.cache.some((r) => r.name === "Giveaways")
) {
return interaction.reply({
content:
":x: You need to have the manage messages permissions to pause giveaways.",
ephemeral: true,
});
}
const query = interaction.options.getString("giveaway");
// try to found the giveaway with prize then with ID
const giveaway =
// Search with giveaway prize
client.giveawaysManager.giveaways.find(
(g) => g.prize === query && g.guildId === interaction.guild.id
) ||
// Search with giveaway ID
client.giveawaysManager.giveaways.find(
(g) => g.messageId === query && g.guildId === interaction.guild.id
);
// If no giveaway was found
if (!giveaway) {
return interaction.reply({
content: "Unable to find a giveaway for `" + query + "`.",
ephemeral: true,
});
}
if (giveaway.pauseOptions.isPaused) {
return interaction.reply({
content: "This giveaway is already paused.",
ephemeral: true,
});
}
// Edit the giveaway
client.giveawaysManager
.pause(giveaway.messageId)
// Success message
.then(() => {
// Success message
interaction.reply("Giveaway paused!");
})
.catch((e) => {
interaction.reply({
content: e,
ephemeral: true,
});
});
},
};

39
commands/ping.js Normal file
View file

@ -0,0 +1,39 @@
const messages = require("../utils/messages");
const { EmbedBuilder } = require("discord.js");
module.exports = {
name: "ping",
description: "Tells a bot latency,",
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (!interaction.member.permissions.has("SEND_MESSAGES")) {
return interaction.reply({
content:
":x: You need to have the manage messages permissions to start giveaways.",
ephemeral: true,
});
}
let circles = {
green: "<:online:903711513183940669>",
yellow: "<:idle:903711513490112512> ",
red: "<:dnd:903711513066487851>",
};
let botping = new EmbedBuilder()
.setTitle(`${client.user.username} Ping`)
.setColor("2f3136")
.addFields({
name: "<:connection2:896715171454677013> Bot Ping:",
value: `${
client.ws?.ping <= 200
? circles.green
: client.ws?.ping <= 400
? circles.yellow
: circles.red
} ${client.ws?.ping}ms`,
})
.setTimestamp();
await interaction.reply({ embeds: [botping] });
},
};

70
commands/reroll.js Normal file
View file

@ -0,0 +1,70 @@
const Discord = require("discord.js");
module.exports = {
description: "Reroll a giveaway",
options: [
{
name: "giveaway",
description: "The giveaway to reroll (message ID or prize)",
type: Discord.ApplicationCommandOptionType.String,
required: true,
},
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (
!interaction.member.permissions.has("MANAGE_MESSAGES") &&
!interaction.member.roles.cache.some((r) => r.name === "Giveaways")
) {
return interaction.reply({
content:
":x: You need to have the manage messages permissions to reroll giveaways.",
ephemeral: true,
});
}
const query = interaction.options.getString("giveaway");
// try to found the giveaway with prize then with ID
const giveaway =
// Search with giveaway prize
client.giveawaysManager.giveaways.find(
(g) => g.prize === query && g.guildId === interaction.guild.id
) ||
// Search with giveaway ID
client.giveawaysManager.giveaways.find(
(g) => g.messageId === query && g.guildId === interaction.guild.id
);
// If no giveaway was found
if (!giveaway) {
return interaction.reply({
content: "Unable to find a giveaway for `" + query + "`.",
ephemeral: true,
});
}
if (!giveaway.ended) {
return interaction.reply({
content: "The giveaway is not ended yet.",
ephemeral: true,
});
}
// Reroll the giveaway
client.giveawaysManager
.reroll(giveaway.messageId)
.then(() => {
// Success message
interaction.reply("Giveaway rerolled!");
})
.catch((e) => {
interaction.reply({
content: e,
ephemeral: true,
});
});
},
};

77
commands/start.js Normal file
View file

@ -0,0 +1,77 @@
const Discord = require("discord.js");
const ms = require("ms");
const messages = require("../utils/messages");
module.exports = {
description: "Start a giveaway",
options: [
{
name: "duration",
description:
"How long the giveaway should last for. Example values: 1m, 1h, 1d",
type: Discord.ApplicationCommandOptionType.String,
required: true,
},
{
name: "winners",
description: "How many winners the giveaway should have",
type: Discord.ApplicationCommandOptionType.Integer,
required: true,
},
{
name: "prize",
description: "What the prize of the giveaway should be",
type: Discord.ApplicationCommandOptionType.String,
required: true,
},
{
name: "channel",
description: "The channel to start the giveaway in",
type: Discord.ApplicationCommandOptionType.Channel,
required: true,
},
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (
!interaction.member.permissions.has("MANAGE_MESSAGES") &&
!interaction.member.roles.cache.some((r) => r.name === "Giveaways")
) {
return interaction.reply({
content:
":x: You need to have the manage messages permissions to start giveaways.",
ephemeral: true,
});
}
const giveawayChannel = interaction.options.getChannel("channel");
const giveawayDuration = interaction.options.getString("duration");
const giveawayWinnerCount = interaction.options.getInteger("winners");
const giveawayPrize = interaction.options.getString("prize");
if (!giveawayChannel.isTextBased()) {
return interaction.reply({
content: ":x: Selected channel is not text-based.",
ephemeral: true,
});
}
// Start the giveaway
client.giveawaysManager.start(giveawayChannel, {
// The giveaway duration
duration: ms(giveawayDuration),
// The giveaway prize
prize: giveawayPrize,
// The giveaway winner count
winnerCount: giveawayWinnerCount,
// Who hosts this giveaway
hostedBy: client.config.hostedBy ? interaction.user : null,
// Messages
messages,
});
interaction.reply(`Giveaway started in ${giveawayChannel}!`);
},
};

87
commands/stats.js Normal file
View file

@ -0,0 +1,87 @@
const os = require("os");
const { EmbedBuilder } = require("discord.js");
const feroms = require("fero-ms");
module.exports = {
name: "stats",
description: "Sends bot physical statistics",
run: async (client, interaction) => {
let uptime = client.uptime;
let shortUptime = feroms.ms(uptime);
let model = os.cpus()[0].model;
let cores = os.cpus().length;
let platform = os.platform();
let nodejs = process.version;
let djs = require("discord.js").version;
let botversion = require("../package.json").version;
let server = client.guilds.cache.size;
let user = client.users.cache.size;
let channel = client.channels.cache.size;
let statsembed = new EmbedBuilder()
.addFields(
{
name: "<:live2:896715171882500106> I have been online for?",
value: `\`\`\`${shortUptime}\`\`\``,
},
{
name: "<:globe:896718155416760340> Guilds",
value: `\`${server}\``,
inline: true,
},
{
name: "<:mention:896718358672707584> Users",
value: `\`${user}\``,
inline: true,
},
{
name: "<:channel:896717996326809641> Channels",
value: `\`${channel}\``,
inline: true,
},
{
name: "Bot Version",
value: `\`v${botversion}\``,
inline: true,
},
{
name: "<:prime:896718399776886816> Arch",
value: `\`${os.arch()}\``,
inline: true,
},
{
name: "<:info:896718244461826140> Platform",
value: `\`${platform}\``,
inline: true,
},
{
name: "<:desktop:896718080821047346> Cores",
value: `\`${cores}\``,
inline: true,
},
{
name: "<a:Discord:896723328277024819> Discord.js Version",
value: `\`v${djs}\``,
inline: true,
},
{
name: "<:jss:896718571491704852> Node.js Version",
value: `\`${nodejs}\``,
inline: true,
},
{
name: "<:ram:896715172029276180> Ram Usage",
value: `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(
2
)}MB/ ${(os.totalmem() / 1024 / 1024).toFixed(2)}MB\``,
inline: true,
},
{
name: "<:desktop:896718080821047346> CPU Model",
value: `\`\`\`${model}\`\`\``,
}
)
.setTimestamp();
await interaction.reply({ embeds: [statsembed] });
},
};

71
commands/unpause.js Normal file
View file

@ -0,0 +1,71 @@
const Discord = require("discord.js");
module.exports = {
description: "Unpause a giveaway",
options: [
{
name: "giveaway",
description: "The giveaway to unpause (message ID or giveaway prize)",
type: Discord.ApplicationCommandOptionType.String,
required: true,
},
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (
!interaction.member.permissions.has("MANAGE_MESSAGES") &&
!interaction.member.roles.cache.some((r) => r.name === "Giveaways")
) {
return interaction.reply({
content:
":x: You need to have the manage messages permissions to unpause giveaways.",
ephemeral: true,
});
}
const query = interaction.options.getString("giveaway");
// try to found the giveaway with prize then with ID
const giveaway =
// Search with giveaway prize
client.giveawaysManager.giveaways.find(
(g) => g.prize === query && g.guildId === interaction.guild.id
) ||
// Search with giveaway ID
client.giveawaysManager.giveaways.find(
(g) => g.messageId === query && g.guildId === interaction.guild.id
);
// If no giveaway was found
if (!giveaway) {
return interaction.reply({
content: "Unable to find a giveaway for `" + query + "`.",
ephemeral: true,
});
}
if (!giveaway.pauseOptions.isPaused) {
return interaction.reply({
content: "This giveaway is not paused.",
ephemeral: true,
});
}
// Edit the giveaway
client.giveawaysManager
.unpause(giveaway.messageId)
// Success message
.then(() => {
// Success message
interaction.reply("Giveaway unpaused!");
})
.catch((e) => {
interaction.reply({
content: e,
ephemeral: true,
});
});
},
};

View file

@ -1,9 +0,0 @@
{
"token": "",
"prefix": "!",
"everyoneMention": false,
"copyright": "Holana",
"hostedBy": false,
"MONGODB_URI": "",
"privateMessageInformation": true
}

View file

@ -1,15 +0,0 @@
module.exports = (client, interaction) => {
// Check if our interaction is a slash command
if (interaction.isCommand()) {
// Get the command from our slash command collection
const command = client.interactions.get(interaction.commandName);
// If command does not exist return an error message
if (!command) return interaction.reply({
content: "Something Went Wrong | Perhaps command not registered?",
ephemeral: true
});
command.run(client, interaction);
}
}

View file

@ -1,20 +0,0 @@
module.exports = (client, message) => {
// return if author is a bot
if (message.author.bot) return;
// return if message does not match prefix (in command)
if (message.content.indexOf(client.config.prefix) !== 0) return;
// Defining what are arguments and commands
const args = message.content.slice(client.config.prefix.length).trim().split(/ +/g);
const command = args.shift().toLowerCase();
// Get the command data from the client.commands Enmap
const cmd = client.commands.get(command);
// If command does not exist return
if (!cmd) return;
// Run the command
cmd.run(client, message, args);
};

View file

@ -1,53 +0,0 @@
const register = require('../../utils/slashsync');
const { ActivityType } = require('discord.js');
module.exports = async (client) => {
await register(client, client.register_arr.map((command) => ({
name: command.name,
description: command.description,
options: command.options,
type: '1'
})), {
debug: true
});
console.log(`[ / | Slash Command ] - ✅ Loaded all slash commands!`)
console.log(`[STATUS] ${client.user.tag} is now online!`);
const activities = [
'Your Giveaways',
'/help',
'www.elliebot.net'
]
setInterval(() => {
const status = activities[Math.floor(Math.random() * activities.length)];
client.user.setActivity({ name: `${status}`, type: ActivityType.Watching })
}, 5000);
};
// Do this one if you want the streaming Status //
/*
const register = require('../../utils/slashsync');
const { ActivityType } = require('discord.js');
module.exports = async (client) => {
await register(client, client.register_arr.map((command) => ({
name: command.name,
description: command.description,
options: command.options,
type: '1'
})), {
debug: true
});
console.log(`[ / | Slash Command ] - ✅ Loaded all slash commands!`)
console.log(`[STATUS] ${client.user.tag} is now online!`);
client.user.setActivity({ name: `Your Giveaways`, type: ActivityType.Streaming, url: 'https://youtube.com/' })
};*/

View file

@ -1,14 +0,0 @@
const Discord = require('discord.js');
module.exports = {
async execute(giveaway, member, reaction) {
reaction.users.remove(member.user);
member.send({
embeds: [
new Discord.EmbedBuilder()
.setColor("#2F3136")
.setDescription("<:cross:885049515323846696> **Oops! Looks Like that giveaway has already ended!** <:ended:1033984179672727553>"),
],
})
.catch((e) => {});
},
};

View file

@ -1,34 +0,0 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
async execute(giveaway, winners) {
winners.forEach((member) => {
member.send({
components: [new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel("Jump to the Giveaway")
.setStyle(ButtonStyle.Link)
.setURL(`https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId}`)
.setEmoji('973495590921043968'),
new ButtonBuilder()
.setLabel("Invite Me")
.setStyle(ButtonStyle.Link)
.setURL("https://discord.com/api/oauth2/authorize?client_id=726333575091454002permissions=406881561681&scope=bot%20applications.commands")
.setEmoji('984296691794583582'))],
embeds: [new EmbedBuilder()
.setAuthor({name: "Congratulations!", iconURL: "https://ellie.gcoms.xyz/Ellise.png"})
.setColor("#2F3136")
.setThumbnail('https://ellie.gcoms.xyz/Ellise.png')
.setDescription(`<:DotYellow:1002212470812852245> Hello there ${member.user}\n <:DotBlue:1002212466480128032> Congrats!! you have won **${giveaway.prize}!**\n <:DotBlue:1002212466480128032> DM ${giveaway.hostedBy} to claim your prize!`)
.setImage('https://ellie.gcoms.xyz/Ellise.png')
.setTimestamp()
.setFooter({
text: `©️ Holana`,
iconURL: ('https://ellie.gcoms.xyz/Ellise.png')
})
]
}).catch(e => {})
});
}
}

View file

@ -1,64 +0,0 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
async execute(giveaway, reactor, messageReaction) {
const noice = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel("Invite Me")
.setStyle(ButtonStyle.Link)
.setURL("https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=406881561681&scope=bot%20applications.commands")
.setEmoji('984296691794583582'),
);
let approved = new EmbedBuilder()
.setTimestamp()
.setColor("#2F3136")
.setAuthor({name: "Entry Confirmed!", iconURL: "https://ellie.gcoms.xyz/Ellise.png"})
.setDescription(
`<:DotGreen:1002212464345239643> Your entry to **${giveaway.prize}** on [This Server](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId}) has been approved! \n<:DotGreen:1002212464345239643> Earn extra points by **Voting**. \n<:DotPink:1002212468870877304> Hosted By: ${giveaway.hostedBy}`
)
.setFooter({ text: "©️ Holana", iconURL: ('https://ellie.gcoms.xyz/Ellise.png') })
.setTimestamp()
const lol = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel("Invite Me")
.setStyle(ButtonStyle.Link)
.setURL("https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=406881561681&scope=bot%20applications.commands")
.setEmoji('984296691794583582'),
);
let denied = new EmbedBuilder()
.setTimestamp()
.setColor("#2F3136")
.setAuthor({name: "Entry Denied!", iconURL: "https://ellie.gcoms.xyz/Ellise.png"})
.setDescription(
`<:DotPink:1002212468870877304> Your entry to **${giveaway.prize}** on [This Server](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId}) has been denied! \n<:DotPink:1002212468870877304> Please review the requirements to enter the giveaway properly. \n<:DotPink:1002212468870877304> Hosted By: ${giveaway.hostedBy}`
)
.setFooter({ text: "©️ Holana", iconURL: ('https://ellie.gcoms.xyz/Ellise.png') })
let client = messageReaction.message.client
if (reactor.user.bot) return;
if(giveaway.extraData) {
if (giveaway.extraData.role !== "null" && !reactor.roles.cache.get(giveaway.extraData.role)){
messageReaction.users.remove(reactor.user);
return reactor.send({
embeds: [denied],
components: [lol]
}).catch(e => {})
}
return reactor.send({
embeds: [approved],
components: [noice]
}).catch(e => {})
} else {
return reactor.send({
embeds: [approved]
}).catch(e => {})
}
}
}

View file

@ -1,27 +0,0 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
async execute(giveaway, member) {
return member.send({
components: [new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel("Jump to the Giveaway")
.setStyle(ButtonStyle.Link)
.setURL(`https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId}`)
.setEmoji('973495590921043968'))],
embeds: [new EmbedBuilder()
.setTimestamp()
.setAuthor({ name: "Reaction Removed!", iconURL: "https://ellie.gcoms.xyz/Ellise.png" })
.setTitle('Did You Just Remove a Reaction From A Giveaway?')
.setColor("#2F3136")
.setDescription(
`<:DotPink:1002212468870877304> Your entery to **${giveaway.prize}** on [This Server](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId}) have been removed!\n <:DotPink:1002212468870877304> This means you're removed as a valid giveaway participant.\n <:DotGreen:1002212464345239643> Think It was a mistake? **Go react again!**`
)
.setFooter({ text: "©️ Holana", iconURL: ('https://ellie.gcoms.xyz/Ellise.png') })
]
}).catch(e => {})
}
}

View file

@ -1,36 +0,0 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
async execute(giveaway, winners) {
winners.forEach((member) => {
member.send({
components: [new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel("Jump to the Giveaway")
.setStyle(ButtonStyle.Link)
.setURL(`https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId}`)
.setEmoji('973495590921043968'),
new ButtonBuilder()
.setLabel("Invite Me")
.setStyle(ButtonStyle.Link)
.setURL("https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=406881561681&scope=bot%20applications.commands")
.setEmoji('984296691794583582'))],
embeds: [new EmbedBuilder()
.setAuthor({name: "Congratulations!", iconURL: ('https://ellie.gcoms.xyz/Ellise.png')})
.setThumbnail('https://ellie.gcoms.xyz/Ellise.png')
.setColor("#2F3136")
.setDescription(`<:DotYellow:1002212470812852245> Hello there ${member.user}\n<:DotGreen:1002212464345239643> Host of the giveaway rerolled and you won the Giveaway!\n<:DotGreen:1002212464345239643> Good Job On Winning **${giveaway.prize}!** <:confetti:984296694357319730><:confetti:984296694357319730>\n<:DotGreen:1002212464345239643> DM ${giveaway.hostedBy} to claim your prize!!`)
.setImage('https://ellie.gcoms.xyz/Ellise.png')
.setTimestamp()
.setFooter({
text: "©️ Holana",
iconURL: ('https://ellie.gcoms.xyz/Ellise.png')
})
]
}).catch(e => {})
});
}
}

View file

@ -0,0 +1,13 @@
module.exports = (client, interaction) => {
if (!interaction.isChatInputCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command)
return void interaction.reply({
content: `Command \`${interaction.commandName}\` not found.`,
ephemeral: true,
});
command.run(client, interaction);
}

View file

@ -1,8 +0,0 @@
const chalk = require('chalk');
module.exports = {
name: "connected",
execute() {
console.log(chalk.greenBright("[MONGO DB]: Connected to MongoDB!"));
},
};

View file

@ -1,8 +0,0 @@
const chalk = require('chalk');
module.exports = {
name: "connecting",
execute() {
console.log(chalk.cyan("[MONGO DB]: Connecting to MongoDB..."));
},
};

View file

@ -1,8 +0,0 @@
const chalk = require('chalk');
module.exports = {
name: 'disconnected',
execute(client) {
console.log(chalk.red("[MONGO DB]: Disconnected from MongoDB!"));
},
};

View file

@ -1,8 +0,0 @@
const chalk = require('chalk');
module.exports = {
name: "err",
execute(err) {
console.log(chalk.red("[MONGO DB]: Error: " + err + ""));
},
};

21
events/ready.js Normal file
View file

@ -0,0 +1,21 @@
const { ActivityType } = require("discord.js");
module.exports = (client) => {
console.log(
`Ready to serve in ${client.channels.cache.size} channels on ${client.guilds.cache.size} servers, for a total of ${client.users.cache.size} users.`
);
const activities = [
`Giveaways in ${client.guilds.cache.size} guilds`,
"/help",
`over ${client.users.cache.size} users!`,
`${
client.giveawaysManager.giveaways.filter((g) => !g.ended).length
} active giveaways!`,
];
setInterval(() => {
let activity = activities[Math.floor(Math.random() * activities.length)];
client.user.setActivity(activity, { type: ActivityType.Watching });
}, 20000);
};

5
example.config.json Normal file
View file

@ -0,0 +1,5 @@
{
"token": "Discord Bot Token",
"everyoneMention": false,
"hostedBy": true
}

View file

@ -0,0 +1,5 @@
{
"rules": {
"no-restricted-globals": "off"
}
}

View file

@ -0,0 +1,64 @@
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [
Discord.IntentsBitField.Flags.Guilds,
Discord.IntentsBitField.Flags.GuildMessageReactions,
],
});
// Load Enmap
const Enmap = require("enmap");
// Create giveaways table
const giveawayDB = new Enmap({ name: "giveaways" });
const { GiveawaysManager } = require("discord-giveaways");
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when the manager needs to get all giveaways which are stored in the database.
async getAllGiveaways() {
// Get all giveaways from the database
return giveawayDB.fetchEverything().array();
}
// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
giveawayDB.set(messageId, giveawayData);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageId, giveawayData) {
// Replace the unedited giveaway with the edited giveaway
giveawayDB.set(messageId, giveawayData);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageId) {
// Remove the giveaway from the database
giveawayDB.delete(messageId);
// Don't forget to return something!
return true;
}
};
// Create a new instance of your new class
const manager = new GiveawayManagerWithOwnDatabase(client, {
default: {
botsCanWin: false,
embedColor: "#FF0000",
embedColorEnd: "#000000",
reaction: "🎉",
},
});
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.on("ready", () => {
console.log("Bot is ready!");
});
client.login(process.env.DISCORD_BOT_TOKEN);

View file

@ -0,0 +1,133 @@
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [
Discord.IntentsBitField.Flags.Guilds,
Discord.IntentsBitField.Flags.GuildMessageReactions,
],
});
// Connect to the database
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/database");
const db = mongoose.connection;
// Check the connection
db.on("error", console.error.bind(console, "Connection error:"));
db.once("open", () => {
console.log("Connected to MongoDB.");
});
// Create the schema for giveaways
const giveawaySchema = new mongoose.Schema(
{
messageId: String,
channelId: String,
guildId: String,
startAt: Number,
endAt: Number,
ended: Boolean,
winnerCount: Number,
prize: String,
messages: {
giveaway: String,
giveawayEnded: String,
title: String,
inviteToParticipate: String,
drawing: String,
dropMessage: String,
winMessage: mongoose.Mixed,
embedFooter: mongoose.Mixed,
noWinner: String,
winners: String,
endedAt: String,
hostedBy: String,
},
thumbnail: String,
image: String,
hostedBy: String,
winnerIds: { type: [String], default: undefined },
reaction: mongoose.Mixed,
botsCanWin: Boolean,
embedColor: mongoose.Mixed,
embedColorEnd: mongoose.Mixed,
exemptPermissions: { type: [], default: undefined },
exemptMembers: String,
bonusEntries: String,
extraData: mongoose.Mixed,
lastChance: {
enabled: Boolean,
content: String,
threshold: Number,
embedColor: mongoose.Mixed,
},
pauseOptions: {
isPaused: Boolean,
content: String,
unPauseAfter: Number,
embedColor: mongoose.Mixed,
durationAfterPause: Number,
infiniteDurationText: String,
},
isDrop: Boolean,
allowedMentions: {
parse: { type: [String], default: undefined },
users: { type: [String], default: undefined },
roles: { type: [String], default: undefined },
},
},
{ id: false }
);
// Create the model
const giveawayModel = mongoose.model("giveaways", giveawaySchema);
const { GiveawaysManager } = require("discord-giveaways");
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when the manager needs to get all giveaways which are stored in the database.
async getAllGiveaways() {
// Get all giveaways from the database. We fetch all documents by passing an empty condition.
return await giveawayModel.find().lean().exec();
}
// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
await giveawayModel.create(giveawayData);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageId, giveawayData) {
// Find by messageId and update it
await giveawayModel.updateOne({ messageId }, giveawayData).exec();
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageId) {
// Find by messageId and delete it
await giveawayModel.deleteOne({ messageId }).exec();
// Don't forget to return something!
return true;
}
};
// Create a new instance of your new class
const manager = new GiveawayManagerWithOwnDatabase(client, {
default: {
botsCanWin: false,
embedColor: "#FF0000",
embedColorEnd: "#000000",
reaction: "🎉",
},
});
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.on("ready", () => {
console.log("Bot is ready!");
});
client.login(process.env.DISCORD_BOT_TOKEN);

View file

@ -0,0 +1,144 @@
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [
Discord.IntentsBitField.Flags.Guilds,
Discord.IntentsBitField.Flags.GuildMessageReactions,
],
});
// Load mysql
const MySQL = require("mysql");
const sql = MySQL.createConnection({
host: "localhost",
user: "Your MySQL user",
password: "Your MySQL password",
database: "Your MySQL database name",
charset: "utf8mb4", // In order to save emojis correctly
});
sql.connect((err) => {
if (err) {
// Stop the process if we can't connect to the MySQL server
throw new Error("Impossible to connect to MySQL server. Code: " + err.code);
} else {
console.log(
"[SQL] Connected to the MySQL server! Connection ID: " + sql.threadId
);
}
});
// Create giveaways table
sql.query(
`
CREATE TABLE IF NOT EXISTS \`giveaways\`
(
\`id\` INT(1) NOT NULL AUTO_INCREMENT,
\`message_id\` VARCHAR(20) NOT NULL,
\`data\` JSON NOT NULL,
PRIMARY KEY (\`id\`)
);
`,
(err) => {
if (err) console.error(err);
console.log("[SQL] Created table `giveaways`");
}
);
const { GiveawaysManager } = require("discord-giveaways");
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when the manager needs to get all giveaways which are stored in the database.
async getAllGiveaways() {
return new Promise((resolve, reject) => {
sql.query("SELECT `data` FROM `giveaways`", (err, res) => {
if (err) {
console.error(err);
return reject(err);
}
const giveaways = res.map((row) =>
JSON.parse(row.data, (_, v) =>
typeof v === "string" && /BigInt\("(-?\d+)"\)/.test(v) ? eval(v) : v
)
);
resolve(giveaways);
});
});
}
// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageId, giveawayData) {
return new Promise((resolve, reject) => {
sql.query(
"INSERT INTO `giveaways` (`message_id`, `data`) VALUES (?,?)",
[
messageId,
JSON.stringify(giveawayData, (_, v) =>
typeof v === "bigint" ? `BigInt("${v}")` : v
),
],
(err, res) => {
if (err) {
console.error(err);
return reject(err);
}
resolve(true);
}
);
});
}
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageId, giveawayData) {
return new Promise((resolve, reject) => {
sql.query(
"UPDATE `giveaways` SET `data` = ? WHERE `message_id` = ?",
[
JSON.stringify(giveawayData, (_, v) =>
typeof v === "bigint" ? `BigInt("${v}")` : v
),
messageId,
],
(err, res) => {
if (err) {
console.error(err);
return reject(err);
}
resolve(true);
}
);
});
}
// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageId) {
return new Promise((resolve, reject) => {
sql.query(
"DELETE FROM `giveaways` WHERE `message_id` = ?",
messageId,
(err, res) => {
if (err) {
console.error(err);
return reject(err);
}
resolve(true);
}
);
});
}
};
// Create a new instance of your new class
const manager = new GiveawayManagerWithOwnDatabase(client, {
default: {
botsCanWin: false,
embedColor: "#FF0000",
embedColorEnd: "#000000",
reaction: "🎉",
},
});
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.on("ready", () => {
console.log("Bot is ready!");
});
client.login(process.env.DISCORD_BOT_TOKEN);

View file

@ -0,0 +1,81 @@
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [
Discord.IntentsBitField.Flags.Guilds,
Discord.IntentsBitField.Flags.GuildMessageReactions,
],
});
// Load nano
const nano = require("nano")("http://admin:mypassword@localhost:5984");
let giveawayDB;
// Check the DB
(async () => {
if (!(await nano.db.list()).includes("giveaways"))
await nano.db.create("giveaways");
giveawayDB = nano.use("giveaways");
// Start the manager only after the DB got checked to prevent an error
client.giveawaysManager._init();
})();
const { GiveawaysManager } = require("discord-giveaways");
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when the manager needs to get all giveaways which are stored in the database.
async getAllGiveaways() {
// Get all giveaways from the database
return (await giveawayDB.list({ include_docs: true })).rows.map(
(r) => r.doc
);
}
// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
await giveawayDB.insert(giveawayData, messageId);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageId, giveawayData) {
// Get the unedited giveaway from the database
const giveaway = await giveawayDB.get(messageId);
// Edit the giveaway
await giveawayDB.insert({ ...giveaway, ...giveawayData });
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageId) {
// Get the giveaway from the database
const giveaway = await giveawayDB.get(messageId);
// Remove the giveaway from the database
await giveawayDB.destroy(messageId, giveaway._rev);
// Don't forget to return something!
return true;
}
};
// Create a new instance of your new class
const manager = new GiveawayManagerWithOwnDatabase(
client,
{
default: {
botsCanWin: false,
embedColor: "#FF0000",
embedColorEnd: "#000000",
reaction: "🎉",
},
},
false
); // ATTENTION: Add "false" in order to not start the manager until the DB got checked, see below
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.on("ready", () => {
console.log("Bot is ready!");
});
client.login(process.env.DISCORD_BOT_TOKEN);

View file

@ -0,0 +1,76 @@
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [
Discord.IntentsBitField.Flags.Guilds,
Discord.IntentsBitField.Flags.GuildMessageReactions,
],
});
// Load quick.db
const db = require("quick.db");
if (!Array.isArray(db.get("giveaways"))) db.set("giveaways", []);
const { GiveawaysManager } = require("discord-giveaways");
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when the manager needs to get all giveaways which are stored in the database.
async getAllGiveaways() {
// Get all giveaways from the database
return db.get("giveaways");
}
// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
db.push("giveaways", giveawayData);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageId, giveawayData) {
// Get all giveaways from the database
const giveaways = db.get("giveaways");
// Remove the unedited giveaway from the array
const newGiveawaysArray = giveaways.filter(
(giveaway) => giveaway.messageId !== messageId
);
// Push the edited giveaway into the array
newGiveawaysArray.push(giveawayData);
// Save the updated array
db.set("giveaways", newGiveawaysArray);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageId) {
// Get all giveaways from the database
const giveaways = db.get("giveaways");
// Remove the giveaway from the array
const newGiveawaysArray = giveaways.filter(
(giveaway) => giveaway.messageId !== messageId
);
// Save the updated array
db.set("giveaways", newGiveawaysArray);
// Don't forget to return something!
return true;
}
};
// Create a new instance of your new class
const manager = new GiveawayManagerWithOwnDatabase(client, {
default: {
botsCanWin: false,
embedColor: "#FF0000",
embedColorEnd: "#000000",
reaction: "🎉",
},
});
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.on("ready", () => {
console.log("Bot is ready!");
});
client.login(process.env.DISCORD_BOT_TOKEN);

View file

@ -0,0 +1,87 @@
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [
Discord.IntentsBitField.Flags.Guilds,
Discord.IntentsBitField.Flags.GuildMessageReactions,
],
});
// Load quick.replit
const { Database } = require("quick.replit");
const db = new Database();
// Check the DB when it is ready
db.once("ready", async () => {
if (!Array.isArray(await db.get("giveaways"))) await db.set("giveaways", []);
// Start the manager only after the DB got checked to prevent an error
client.giveawaysManager._init();
});
const { GiveawaysManager } = require("discord-giveaways");
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when the manager needs to get all giveaways which are stored in the database.
async getAllGiveaways() {
// Get all giveaways from the database
return await db.get("giveaways");
}
// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
await db.push("giveaways", giveawayData);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageId, giveawayData) {
// Get all giveaways from the database
const giveaways = await db.get("giveaways");
// Remove the unedited giveaway from the array
const newGiveawaysArray = giveaways.filter(
(giveaway) => giveaway.messageId !== messageId
);
// Push the edited giveaway into the array
newGiveawaysArray.push(giveawayData);
// Save the updated array
await db.set("giveaways", newGiveawaysArray);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageId) {
// Get all giveaways from the database
const giveaways = await db.get("giveaways");
// Remove the giveaway from the array
const newGiveawaysArray = giveaways.filter(
(giveaway) => giveaway.messageId !== messageId
);
// Save the updated array
await db.set("giveaways", newGiveawaysArray);
// Don't forget to return something!
return true;
}
};
// Create a new instance of your new class
const manager = new GiveawayManagerWithOwnDatabase(
client,
{
default: {
botsCanWin: false,
embedColor: "#FF0000",
embedColorEnd: "#000000",
reaction: "🎉",
},
},
false
); // ATTENTION: Add "false" in order to not start the manager until the DB got checked, see below
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.on("ready", () => {
console.log("Bot is ready!");
});
client.login(process.env.DISCORD_BOT_TOKEN);

View file

@ -0,0 +1,71 @@
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [
Discord.IntentsBitField.Flags.Guilds,
Discord.IntentsBitField.Flags.GuildMessageReactions,
],
});
// Load quickmongo
const { Database } = require("quickmongo");
const giveawayDB = new Database("mongodb://localhost/database", {
collectionName: "giveaways",
});
// Start the manager only after the DB turned ready to prevent an error
giveawayDB.once("ready", () => client.giveawaysManager._init());
const { GiveawaysManager } = require("discord-giveaways");
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when the manager needs to get all giveaways which are stored in the database.
async getAllGiveaways() {
// Get all giveaways from the database
return (await giveawayDB.all()).map((element) => element.data);
}
// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageId, giveawayData) {
// Add the new giveaway to the database
await giveawayDB.set(messageId, giveawayData);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageId, giveawayData) {
// Replace the unedited giveaway with the edited giveaway
await giveawayDB.set(messageId, giveawayData);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageId) {
// Remove the giveaway from the database
await giveawayDB.delete(messageId);
// Don't forget to return something!
return true;
}
};
// Create a new instance of your new class
const manager = new GiveawayManagerWithOwnDatabase(
client,
{
default: {
botsCanWin: false,
embedColor: "#FF0000",
embedColorEnd: "#000000",
reaction: "🎉",
},
},
false
); // ATTENTION: Add "false" in order to not start the manager until the DB got checked, see below
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.on("ready", () => {
console.log("Bot is ready!");
});
client.login(process.env.DISCORD_BOT_TOKEN);

View file

@ -0,0 +1,83 @@
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [
Discord.IntentsBitField.Flags.Guilds,
Discord.IntentsBitField.Flags.GuildMessageReactions,
],
});
// Load Replit Database
const Database = require("@replit/database");
const db = new Database();
(async () => {
if (!Array.isArray(await db.get("giveaways"))) await db.set("giveaways", []);
})();
const { GiveawaysManager } = require("discord-giveaways");
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when the manager needs to get all giveaways which are stored in the database.
async getAllGiveaways() {
// Get all giveaways from the database
return await db.get("giveaways");
}
// This function is called when a giveaway needs to be saved in the database.
async saveGiveaway(messageId, giveawayData) {
// Get all giveaways from the database
const giveawaysArray = await db.get("giveaways");
// Push the new giveaway into the array
giveawaysArray.push(giveawayData);
// Save the updated array
await db.set("giveaways", giveawaysArray);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageId, giveawayData) {
// Get all giveaways from the database
const giveaways = await db.get("giveaways");
// Remove the unedited giveaway from the array
const newGiveawaysArray = giveaways.filter(
(giveaway) => giveaway.messageId !== messageId
);
// Push the edited giveaway into the array
newGiveawaysArray.push(giveawayData);
// Save the updated array
await db.set("giveaways", newGiveawaysArray);
// Don't forget to return something!
return true;
}
// This function is called when a giveaway needs to be deleted from the database.
async deleteGiveaway(messageId) {
// Get all giveaways from the database
const giveaways = await db.get("giveaways");
// Remove the giveaway from the array
const newGiveawaysArray = giveaways.filter(
(giveaway) => giveaway.messageId !== messageId
);
// Save the updated array
await db.set("giveaways", newGiveawaysArray);
// Don't forget to return something!
return true;
}
};
// Create a new instance of your new class
const manager = new GiveawayManagerWithOwnDatabase(client, {
default: {
botsCanWin: false,
embedColor: "#FF0000",
embedColorEnd: "#000000",
reaction: "🎉",
},
});
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.on("ready", () => {
console.log("Bot is ready!");
});
client.login(process.env.DISCORD_BOT_TOKEN);

1
examples/simple.js Normal file
View file

@ -0,0 +1 @@
// Example bot available on https://toastielab.dev/toastie_t0ast/Holana

View file

@ -1,41 +0,0 @@
const { GiveawaysManager } = require("discord-giveaways");
const giveawayModel = require('./schemas/giveawaysSchema');
module.exports = (client) =>{
class GiveawayManagerCustom extends GiveawaysManager {
async getAllGiveaways() {
return await giveawayModel.find().lean().exec();
}
async saveGiveaway(messageId, giveawayData) {
await giveawayModel.create(giveawayData);
return true;
}
async editGiveaway(messageId, giveawayData) {
await giveawayModel.updateOne({ messageId }, giveawayData, { omitUndefined: true }).exec();
return true;
}
async deleteGiveaway(messageId) {
await giveawayModel.deleteOne({ messageId }).exec();
return true;
}
};
const manager = new GiveawayManagerCustom(client, {
storage: false,
updateCountdownEvery: 10000,
default: {
botsCanWin: false,
exemptPermissions: [],
embedColor: "#FF0000",
reaction: "🎉"
}
});
client.giveawaysManager = manager
}

1
giveaways.json Normal file
View file

@ -0,0 +1 @@
[{"messageId":"1178260749441830943","channelId":"553759294953357314","guildId":"553759294953357312","startAt":1700989652527,"endAt":1700989652557,"ended":true,"winnerCount":1,"prize":"test","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"🎉🎉 **GIVEAWAY ENDED** 🎉🎉","title":"{this.prize}","inviteToParticipate":"React with 🎉 to participate!","winMessage":"Congratulations, {winners}! You won **{this.prize}**!","drawing":"Drawing: {timestamp}","dropMessage":"Be the first to react with 🎉 !","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {this.hostedBy}"},"hostedBy":"<@234542843732033537>"},{"messageId":"1178260884200620084","channelId":"553759294953357314","guildId":"553759294953357312","startAt":1700989684632,"endAt":1700989724632,"ended":true,"winnerCount":1,"prize":"test","messages":{"giveaway":"🎉🎉 **GIVEAWAY** 🎉🎉","giveawayEnded":"🎉🎉 **GIVEAWAY ENDED** 🎉🎉","title":"{this.prize}","inviteToParticipate":"React with 🎉 to participate!","winMessage":"Congratulations, {winners}! You won **{this.prize}**!","drawing":"Drawing: {timestamp}","dropMessage":"Be the first to react with 🎉 !","embedFooter":"Giveaways","noWinner":"Giveaway cancelled, no valid participations.","winners":"winner(s)","endedAt":"Ended at","hostedBy":"Hosted by: {this.hostedBy}"},"hostedBy":"<@234542843732033537>","winnerIds":["234542843732033537"]}]

View file

@ -1,7 +0,0 @@
// const express = require('express');
// const app = express();
// const port = 3000;
// app.listen(port, () => console.log(`Bot running on http://127.0.0.1:${port}`));
const http = require("http");
http.createServer((_, res) => res.end("Holana online")).listen(8080)

181
index.js
View file

@ -1,114 +1,103 @@
process.title = 'Giveaway Child'; process.title = 'Holana';
const Discord = require("discord.js");
const { Client, GatewayIntentBits, Partials } = require("discord.js");
const chalk = require("chalk");
const config = require("./config.json");
const Handler = require("discord-handlers");
const handler = new Handler();
const { connect } = require("mongoose");
const GiveawaysManager = require("./giveawayInit");
const client = new Client({
partials: [
Partials.Channel, // for text channel
Partials.GuildMember, // for guild member
Partials.Reaction, // for message reaction
],
intents: [
GatewayIntentBits.Guilds, // for guild related things
GatewayIntentBits.GuildMessages, // for guild messages things
GatewayIntentBits.GuildMessageReactions, // for message reactions things
],
});
const fs = require("fs"); const fs = require("fs");
const Discord = require("discord.js");
const client = new Discord.Client({
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildMessageReactions,
],
});
const config = require("./config.json");
client.config = config; client.config = config;
(async () => { const synchronizeSlashCommands = require("discord-sync-commands");
await connect(config.MONGODB_URI).catch((err) =>
console.log(chalk.red(`[MONGO DB]: Error: ${err}`)) // Init discord giveaways
const { GiveawaysManager } = require("discord-giveaways");
client.giveawaysManager = new GiveawaysManager(client, {
storage: "./giveaways.json",
default: {
botsCanWin: false,
embedColor: "#FF0000",
reaction: "🎉",
lastChance: {
enabled: true,
content: "⚠️ **LAST CHANCE TO ENTER !** ⚠️",
threshold: 10000,
embedColor: "#FF0000",
},
},
});
// We now have a client.giveawaysManager property to manage our giveaways!
client.giveawaysManager.on(
"giveawayReactionAdded",
(giveaway, member, reaction) => {
console.log(
`${member.user.tag} entered giveaway #${giveaway.messageId} (${reaction.emoji.name})`
);
}
);
client.giveawaysManager.on(
"giveawayReactionRemoved",
(giveaway, member, reaction) => {
console.log(
`${member.user.tag} unreact to giveaway #${giveaway.messageId} (${reaction.emoji.name})`
);
}
);
client.giveawaysManager.on("giveawayEnded", (giveaway, winners) => {
console.log(
`Giveaway #${giveaway.messageId} ended! Winners: ${winners
.map((member) => member.user.username)
.join(", ")}`
); );
})();
handler.handleMongoEvents("./events/mongo", client);
// Initialise discord giveaways
GiveawaysManager(client);
//<:confetti:984296694357319730>
//<:warning:984663315412303922>
/* Load all events (discord based) */
fs.readdir("./events/discord", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
const event = require(`./events/discord/${file}`);
let eventName = file.split(".")[0];
console.log(`[Event] ✅ Loaded: ${eventName}`);
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/discord/${file}`)];
});
}); });
/* Load all events (giveaways based) */ /* Load all commands */
client.commands = new Discord.Collection();
fs.readdir("./events/giveaways", (_err, files) => { fs.readdir("./commands/", (_err, files) => {
files.forEach((file) => { files.forEach((file) => {
if (!file.endsWith(".js")) return; if (!file.endsWith(".js")) return;
const event = require(`./events/giveaways/${file}`); let props = require(`./commands/${file}`);
let eventName = file.split(".")[0];
console.log(`[Event] 🎉 Loaded: ${eventName}`);
client.giveawaysManager.on(eventName, (...file) =>
event.execute(...file, client)
),
delete require.cache[require.resolve(`./events/giveaways/${file}`)];
});
});
// if(config.privateMessageInformation === true) {
// fs.readdirSync('./events/giveaways').forEach(async (dir) => {
// const events = fs.readdirSync(`./events/giveaways/${dir}`).filter(file => file.endsWith('.js'));
// for(const file of events) {
// const event = require(`./events/giveaways/${dir}/${file}`);
// if(event.name) {
// // console.log(`[GIVEAWAYS EVENTS]` + ` Event ${file.split(".")[0]} loaded!`);
// client.giveawaysManager.on(event.name, (...args) => event.execute(...args, client))
// delete require.cache[require.resolve(`./events/giveaways/${dir}/${file}`)];
// } else {
// console.log(`[GIVEAWAYS EVENTS]` + ` Failed to load event: ${file.split('.')[0]}!`);
// continue;
// }
// }
// });
// } else {
// return console.log(`[WARNING]`.yellow + ` Private Message Information is disabled!`);
// }
/* Load all events (mongo based) */
// let interactions be a new collection ( slash commands )
client.interactions = new Discord.Collection();
// creating an empty array for registering slash commands
client.register_arr = [];
/* Load all slash commands */
fs.readdir("./slash/", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`./slash/${file}`);
let commandName = file.split(".")[0]; let commandName = file.split(".")[0];
client.interactions.set(commandName, { client.commands.set(commandName, {
name: commandName, name: commandName,
...props, ...props,
}); });
client.register_arr.push(props); console.log(`👌 Command loaded: ${commandName}`);
});
synchronizeSlashCommands(
client,
client.commands.map((c) => ({
name: c.name,
description: c.description,
options: c.options,
type: Discord.ApplicationCommandType.ChatInput,
})),
{
debug: true,
}
);
});
/* Load all events */
fs.readdir("./events/", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
console.log(`👌 Event loaded: ${eventName}`);
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/${file}`)];
}); });
}); });
// Login through the client // Login
client.login(config.token); client.login(config.token);

3842
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -4,37 +4,30 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js" "start": "node index.js",
}, "dev": "nodemon index.js"
"engines": {
"node": "16.x"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/EmotionChild/Giveaway-Child.git" "url": "git+https://toastielab.dev/toastie_t0ast/Holana.git"
}, },
"author": "EmotionChild", "author": "Toastie",
"license": "Apache-2.0", "license": "Apache-2.0",
"bugs": { "bugs": {
"url": "https://github.com/EmotionChild/Giveaway-Child/issues" "url": "https://toastielab.dev/toastie_t0ast/Holana/issues"
}, },
"homepage": "https://github.com/EmotionChild/Giveaway-Child#readme", "homepage": "https://toastielab.dev/toastie_t0ast/Holana#readme",
"dependencies": { "dependencies": {
"axios": "^0.27.2", "beautify": "0.0.8",
"chalk": "^4.1.2",
"discord-giveaways": "^6.0.1", "discord-giveaways": "^6.0.1",
"discord-handlers": "^0.0.1", "discord-sync-commands": "0.3.0",
"discord.js": "^14.6.0", "discord.js": "^14.9.0",
"dotenv": "^16.0.3", "fero-ms": "^2.0.7",
"japi.rest": "^1.0.1", "ms": "^2.1.3",
"moment": "^2.29.4", "quickdb": "1.0.5",
"mongoose": "^6.9.0", "quickmongo": "4.0.0"
"ms": "^3.0.0-canary.1",
"node-fetch": "^3.3.0",
"parsec": "^2.0.2",
"quickmongo": "^4.0.0"
}, },
"devDependencies": { "devDependencies": {
"node": "^16.9.1" "nodemon": "^2.0.22"
} }
} }

1060
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,60 +0,0 @@
const mongoose = require('mongoose');
const giveawaySchema = new mongoose.Schema({
messageId: String,
channelId: String,
guildId: String,
startAt: Number,
endAt: Number,
ended: Boolean,
winnerCount: Number,
prize: String,
messages: {
giveaway: String,
giveawayEnded: String,
inviteToParticipate: String,
drawing: String,
dropMessage: String,
winMessage: mongoose.Mixed,
embedFooter: mongoose.Mixed,
noWinner: String,
winners: String,
endedAt: String,
hostedBy: String
},
thumbnail: String,
hostedBy: String,
winnerIds: { type: [String], default: undefined },
reaction: mongoose.Mixed,
botsCanWin: Boolean,
embedColor: mongoose.Mixed,
embedColorEnd: mongoose.Mixed,
exemptPermissions: { type: [], default: undefined },
exemptMembers: String,
bonusEntries: String,
extraData: mongoose.Mixed,
lastChance: {
enabled: Boolean,
content: String,
threshold: Number,
embedColor: mongoose.Mixed
},
pauseOptions: {
isPaused: Boolean,
content: String,
unpauseAfter: Number,
embedColor: mongoose.Mixed,
durationAfterPause: Number,
infiniteDurationText: String
},
isDrop: Boolean,
allowedMentions: {
parse: { type: [String], default: undefined },
users: { type: [String], default: undefined },
roles: { type: [String], default: undefined }
}
}, { id: false });
const giveawayModel = mongoose.model('giveaways', giveawaySchema);
module.exports = giveawayModel;

View file

@ -1,9 +0,0 @@
const { Schema, model } = require('mongoose');
const guildSchema = new Schema({
_id: Schema.Types.ObjectId,
guildId: String,
guildName: String,
});
module.exports = model("Guild", guildSchema, "guilds");

View file

@ -1,29 +0,0 @@
const { ApplicationCommandOptionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, } = require('discord.js');
module.exports = {
name: 'avatar',
description: 'Shows User Avatar',
options: [{
name: 'user',
type: ApplicationCommandOptionType.User,
description: 'Select a user',
required: false,
}],
run: async (client, interaction) => {
const user = interaction.options.getUser('user') || interaction.user
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel(`Avatar URL`)
.setStyle(ButtonStyle.Link)
.setURL(`${user.displayAvatarURL({ dynamic: false, format: 'png', size: 1024 })}`))
const embed = new EmbedBuilder()
.setTitle(`${user.username}'s Avatar`)
.setColor('#2F3136')
.setFooter({ text: `Requested by: ${interaction.user.username}`, iconURL: interaction.user.displayAvatarURL({ dynamic: true }) })
.setImage(user.displayAvatarURL({ dynamic: true, size: 1024 }))
interaction.reply({ embeds: [embed], components: [row] });
}
}

View file

@ -1,74 +0,0 @@
const {
ApplicationCommandOptionType,
EmbedBuilder,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
} = require("discord.js");
module.exports = {
name: "avatar",
description: "Shows User Avatar",
options: [
{
name: "user",
type: ApplicationCommandOptionType.User,
description: "Select a user",
required: false,
},
],
run: async (client, interaction) => {
const user = interaction.options.getUser("user") || interaction.user;
const fetch = require("axios");
let userdata = await fetch.get(
`https://discord.com/api/guilds/${interaction.guild.id}/members/${user.id}`,
{
headers: {
Authorization: `Bot ${client.token}`,
},
}
);
if (userdata.data.avatar !== undefined && userdata.data.avatar !== null) {
let AvatarURL = `https://cdn.discordapp.com/guilds/${interaction.guild.id}/users/${user.id}/avatars/${userdata.data.avatar}.webp?size=1024`;
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setLabel(`Avatar URL`)
.setStyle(ButtonStyle.Link)
.setURL(AvatarURL)
);
const embed = new EmbedBuilder()
.setTitle(`${user.username}'s Avatar`)
.setColor("#2F3136")
.setFooter({
text: `Requested by: ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
})
.setImage(AvatarURL);
interaction.reply({ embeds: [embed], components: [row] });
} else {
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setLabel(`Avatar URL`)
.setStyle(ButtonStyle.Link)
.setURL(
`${user.displayAvatarURL({
dynamic: false,
format: "png",
size: 1024,
})}`
)
);
const embed = new EmbedBuilder()
.setTitle(`${user.username}'s Avatar`)
.setColor("#2F3136")
.setFooter({
text: `Requested by: ${interaction.user.username}`,
iconURL: interaction.user.displayAvatarURL({ dynamic: true }),
})
.setImage(user.displayAvatarURL({ dynamic: true, size: 1024 }));
interaction.reply({ embeds: [embed], components: [row] });
}
},
};

View file

@ -1,72 +0,0 @@
const { ApplicationCommandOptionType } = require('discord.js');
module.exports = {
name: 'edit',
description: '🎉 Edit a giveaway',
options: [
{
name: 'giveaway',
description: 'The giveaway to end (message ID)',
type: ApplicationCommandOptionType.String,
required: true
},
{
name: 'duration',
description: 'Setting time of mentioned giveaway. Eg. 1h sets the current giveaway to end after an hour!',
type: ApplicationCommandOptionType.String,
required: true
},
{
name: 'winners',
description: 'How many winners the giveaway should have',
type: ApplicationCommandOptionType.Integer,
required: true
},
{
name: 'prize',
description: 'What the prize of the giveaway should be',
type: ApplicationCommandOptionType.String,
required: true
}
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (!interaction.member.permissions.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")) {
return interaction.reply({
content: '<:x_:1010816180719722566> You need to have the manage messages permissions to start giveaways.',
ephemeral: true
});
}
const gid = interaction.options.getString('giveaway');
const time = interaction.options.getString('duration');
const winnersCount = interaction.options.getInteger('winners');
const prize = interaction.options.getString('prize');
await interaction.deferReply({
ephemeral: true
})
// Edit the giveaway
try {
await client.giveawaysManager.edit(gid, {
newWinnersCount: winnersCount,
newPrize: prize,
addTime: time
})
} catch(e) {
return interaction.editReply({
content:
`No giveaway found with the given message ID: \`${gid}\``,
ephemeral: true
});
}
interaction.editReply({
content:
`This giveaway has now been edited!`,
ephemeral: true
});
}
};

View file

@ -1,65 +0,0 @@
const { ApplicationCommandOptionType } = require('discord.js');
module.exports = {
name: "end",
description: '🎉 End an already running giveaway',
options: [
{
name: 'giveaway',
description: 'The giveaway to end (message ID or giveaway prize)',
type: ApplicationCommandOptionType.String,
required: true
}
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (!interaction.member.permissions.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")) {
return interaction.reply({
content: '<:x_:1010816180719722566> You need to have the manage messages permissions to end giveaways.',
ephemeral: true
});
}
const query = interaction.options.getString('giveaway');
// fetching the giveaway with message Id or prize
const giveaway =
// Search with giveaway prize
client.giveawaysManager.giveaways.find((g) => g.prize === query && g.guildId === interaction.guild.id) ||
// Search with giveaway Id
client.giveawaysManager.giveaways.find((g) => g.messageId === query && g.guildId === interaction.guild.id);
// If no giveaway was found with the corresponding input
if (!giveaway) {
return interaction.reply({
content: 'Unable to find a giveaway for `' + query + '`.',
ephemeral: true
});
}
if (giveaway.ended) {
return interaction.reply({
content: 'This giveaway has already ended!',
ephemeral: true
});
}
// Edit the giveaway
client.giveawaysManager.end(giveaway.messageId)
// Success message
.then(() => {
// Success message
interaction.reply(`**[This Giveaway](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId})** Has Now Ended!`);
})
.catch((e) => {
interaction.reply({
content: e,
ephemeral: true
});
});
}
};

View file

@ -1,108 +0,0 @@
const { EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder, SelectMenuBuilder, ComponentType } = require('discord.js');
const config = require('../config.json');
module.exports = {
name: 'help',
description: '📜 View all the commands available to the bot!',
run: async (client, interaction) => {
const embed = new EmbedBuilder()
.setTitle(`Commands of ${client.user.username}`)
.setColor('#2F3136')
.setDescription('Please Select a category to view all its commands\n<:invi:1000459192555024404><:next:1000472400049209385> **Giveaway Commands** \n<:invi:1000459192555024404><:next:1000472400049209385> **Configuration Commands**')
.setThumbnail('https://ellie.gcoms.xyz/Ellise.png')
.setTimestamp()
.setFooter({
text: `©️ Holana`,
iconURL: ('https://i.imgur.com/sB02Hbz.png')
});
const giveaway = new EmbedBuilder()
.setTitle("Categories » Giveaway")
.setColor('#2F3136')
.setDescription("<:sort:1003268901360115842> Here are the giveaway commands")
.addFields(
{ name: 'Create / Start' , value: `Start a giveaway in your guild!\n > **Type: \`/start\`**`, inline: true },
{ name: 'Edit' , value: `Edit an already running giveaway!\n > **Type: \`/edit\`**`, inline: true },
{ name: 'End' , value: `End an already running giveaway!\n > **Type: \`/end\`**`, inline: true },
{ name: 'Pause' , value: `Pause an already running giveaway!\n > **Type: \`/pause\`**`, inline: true },
{ name: 'Reroll' , value: `Reroll an ended giveaway!\n > **Type: \`/reroll\`**`, inline: true },
{ name: 'Resume' , value: `Resume a paused giveaway!\n > **Type: \`/resume\`**`, inline: true },
)
.setTimestamp()
.setFooter({
text: `©️ Holana`,
iconURL: ('https://ellie.gcoms.xyz/Ellise.png')
});
const general = new EmbedBuilder()
.setTitle("Categories » Configuration")
.setColor('#2F3136')
.setDescription("<:sort:1003268901360115842> Here are the configuration commands in slash")
.addFields(
{ name: 'Help', value: `Show the help menu.\n > **Type: \`/help\`**`, inline: true },
{ name: 'About', value: `Show Info About Holana.\n > **Type: \`/about\`**`, inline: true },
{ name: 'Server Info', value: `Shows server info.\n > **Type: \`/serverinfo\`**`, inline: true },
{ name: 'Server Icon', value: `Shows server icon.\n > **Type: \`/servericon\`**`, inline: true },
{ name: 'User Info', value: `Shows user info.\n > **Type: \`/userinfo\`**`, inline: true },
{ name: 'User Avatar', value: `Shows user avatar.\n > **Type: \`/avatar\`**`, inline: true },
{ name: 'Invite', value: `Get the bot's invite link.\n > **Type: \`/invite\`**`, inline: true },
{ name: 'Ping', value: `Check the bot's ping!\n > **Type: \`/ping\`**`, inline: true },
{ name: 'System', value: `Check the bot's System info.\n > **Type: \`/info\`**`, inline: true },
)
.setTimestamp()
.setFooter({
text: `©️ Holana`,
iconURL: ('https://ellie.gcoms.xyz/Ellise.png')
});
const components = (state) => [
new ActionRowBuilder().addComponents(
new StringSelectMenuBuilder()
.setCustomId("help-menu")
.setPlaceholder("Please Select a Category")
.setDisabled(state)
.addOptions([{
label: `Giveaways`,
value: `giveaway`,
description: `View all the giveaway based commands!`,
emoji: `<:confetti:984296694357319730>`
},
{
label: `Configuration`,
value: `general`,
description: `View all the general bot commands!`,
emoji: `<:Discord_settings:990669159849414736>`
}
])
),
];
const initialMessage = await interaction.reply({ embeds: [embed], components: components(false) });
const filter = (interaction) => interaction.user.id === interaction.member.id;
const collector = interaction.channel.createMessageComponentCollector(
{
filter,
componentType: ComponentType.SelectMenu,
idle: 300000,
dispose: true,
});
collector.on('collect', (interaction) => {
if (interaction.values[0] === "giveaway") {
interaction.update({ embeds: [giveaway], components: components(false) }).catch((e) => { });
} else if (interaction.values[0] === "general") {
interaction.update({ embeds: [general], components: components(false) }).catch((e) => { });
}
});
collector.on('end', (collected, reason) => {
if (reason == "time") {
initialMessage.edit({
content: "Collector Destroyed, Try Again!",
components: [],
});
}
})
}
}

View file

@ -1,53 +0,0 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
name: 'info',
description: '📚 Check my system info!',
run: async (client, interaction) => {
let ccount = client.channels.cache.size;
let mcount = 0;
client.guilds.cache.forEach((guild) => {
mcount += guild.memberCount
})
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel(`Invite ${client.user.username}`)
.setStyle(ButtonStyle.Link)
.setURL("https://discord.com/api/oauth2/authorize?client_id=973436715819745290&permissions=406881561681&scope=bot%20applications.commands")
.setEmoji('973537545289875486'),
)
let pembed = new EmbedBuilder()
.setAuthor({name: "Holana", iconURL: "https://ellie.gcoms.xyz/Ellise.png" })
.setTitle('Information')
.setColor('#2F3136')
.setTimestamp()
.addFields(
{ name: "\Server", value: `\`\`\`ini\n[ ${client.guilds.cache.size} ]\n\`\`\``, inline: true },
{name: "Users", value: `\`\`\`ini\n[ ${mcount} ]\n\`\`\``, inline: true },
{name: "Channels", value: `\`\`\`ini\n[ ${ccount} ]\n\`\`\``, inline: true}
)
.setDescription(`
**= STATISTICS =**
> ** Discord.js** : v14.7.1
> ** Node** : v18.13.0
**= SYSTEM =**
> ** Hosting** : -
> ** Platform** : Windows
**= CPU =**
> ** Model** : -
> ** Speed** : -
> ** Cores** : -`)
.setFooter({
text: `©️ IVON`,
iconURL: ('https://ellie.gcoms.xyz/Ellise.png')
})
interaction.reply({
embeds: [pembed], components: [row]
});
},
};

View file

@ -1,33 +0,0 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
const config = require('../config.json');
module.exports = {
name: 'invite',
description: ' Invite the bot to your server!',
run: async (client, interaction) => {
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel(`Invite ${client.user.username}`)
.setStyle(ButtonStyle.Link)
.setEmoji('973537545289875486')
.setURL(`https://discord.com/api/oauth2/authorize?client_id=726333575091454002&permissions=406881561681&scope=bot%20applications.commands`),
)
let invite = new EmbedBuilder()
.setAuthor({
name: `Invite ${client.user.username}`,
iconURL: client.user.displayAvatarURL()
})
.setTitle("Invite & Support Link!")
.setDescription(`I'm A Giveaway bot to host Giveaways easily on your server with multiple options, Including role requirements, bonus roles, bonus points and server joinings. Get started with Holana today!`)
.setColor('#2F3136')
.setTimestamp()
.setThumbnail('https://ellie.gcoms.xyz/Ellise.png')
.setFooter({
text: `©️ Holana`,
iconURL: ('https://ellie.gcoms.xyz/Ellise.png')
})
interaction.reply({ embeds: [invite], components: [row]});
}
}

View file

@ -1,63 +0,0 @@
const { ApplicationCommandOptionType } = require('discord.js');
module.exports = {
name: "pause",
description: '⏸ Pause a giveaway',
options: [
{
name: 'giveaway',
description: 'The giveaway to pause (message ID)',
type: ApplicationCommandOptionType.String,
required: true
}
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (!interaction.member.permissions.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")) {
return interaction.reply({
content: '<:x_:1010816180719722566> You need to have the manage messages permissions to pause giveaways.',
ephemeral: true
});
}
const query = interaction.options.getString('giveaway');
// try to find the giveaway with prize alternatively with ID
const giveaway =
// Search with giveaway ID
client.giveawaysManager.giveaways.find((g) => g.messageId === query && g.guildId === interaction.guild.id);
// If no giveaway was found
if (!giveaway) {
return interaction.reply({
content: 'Unable to find a giveaway for `' + query + '`.',
ephemeral: true
});
}
if (giveaway.pauseOptions.isPaused) {
return interaction.reply({
content: `**[This giveaway](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId})** is already paused.`,
ephemeral: true
});
}
// Edit the giveaway
client.giveawaysManager.pause(giveaway.messageId)
// Success message
.then(() => {
// Success message
interaction.reply(`**[This giveaway](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId})** has now been paused!`);
})
.catch((e) => {
interaction.reply({
content: e,
ephemeral: true
});
});
}
};

View file

@ -1,22 +0,0 @@
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: 'ping',
description: '🏓Check my ping!',
run: async (client, interaction) => {
let pembed = new EmbedBuilder()
.setTitle("Pong!")
.setColor('#2F3136')
.setThumbnail('https://ellie.gcoms.xyz/Ellise.png')
.addFields({name: '**Latency**', value: `\`\`\`ini\n[ ${Date.now() - interaction.createdTimestamp}ms ]\n\`\`\``, inline: true},
{name: '**API Latency**', value: `\`\`\`ini\n[ ${Math.round(client.ws.ping)}ms ]\n\`\`\``, inline: true})
.setTimestamp()
.setFooter({
text: `©️ Holana`,
iconURL: ('https://ellie.gcoms.xyz/Ellise.png')
})
interaction.reply({
embeds: [pembed]
});
},
};

View file

@ -1,62 +0,0 @@
const { ApplicationCommandOptionType } = require('discord.js');
module.exports = {
name: "reroll",
description: '🎉 Reroll a giveaway',
options: [
{
name: 'giveaway',
description: 'The giveaway to reroll (message ID)',
type: ApplicationCommandOptionType.String,
required: true
}
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (!interaction.member.permissions.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")) {
return interaction.reply({
content: '<:x_:1010816180719722566> You need to have the manage messages permission to reroll giveaways.',
ephemeral: true
});
}
const query = interaction.options.getString('giveaway');
// try to find the giveaway with the provided prize OR with the ID
const giveaway =
// Search with giveaway ID
client.giveawaysManager.giveaways.find((g) => g.messageId === query && g.guildId === interaction.guild.id);
// If no giveaway was found
if (!giveaway) {
return interaction.reply({
content: 'Unable to find a giveaway for `' + query + '`.',
ephemeral: true
});
}
if (!giveaway.ended) {
return interaction.reply({
content: `[This Giveaway](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId}) has not been ended yet`,
ephemeral: true
});
}
// Reroll the giveaway
client.giveawaysManager.reroll(giveaway.messageId)
.then(() => {
// Success message
interaction.reply(`Rerolled **[this giveaway](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId})!**`);
})
.catch((e) => {
interaction.reply({
content: e,
ephemeral: true
});
});
}
};

View file

@ -1,63 +0,0 @@
const { ApplicationCommandOptionType } = require('discord.js');
module.exports = {
name: "resume",
description: '▶ Resume a paused giveaway',
options: [
{
name: 'giveaway',
description: 'The giveaway to resume (message ID)',
type: ApplicationCommandOptionType.String,
required: true
}
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (!interaction.member.permissions.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")) {
return interaction.reply({
content: '<:x_:1010816180719722566> You need to have the manage messages permissions to pause giveaways.',
ephemeral: true
});
}
const query = interaction.options.getString('giveaway');
// try to find the giveaway with prize alternatively with ID
const giveaway =
// Search with giveaway ID
client.giveawaysManager.giveaways.find((g) => g.messageId === query && g.guildId === interaction.guild.id);
// If no giveaway was found
if (!giveaway) {
return interaction.reply({
content: 'Unable to find a giveaway for `' + query + '`.',
ephemeral: true
});
}
if (!giveaway.pauseOptions.isPaused) {
return interaction.reply({
content: `**[This giveaway](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId})** is not paused!`,
ephemeral: true
});
}
// Edit the giveaway
client.giveawaysManager.unpause(giveaway.messageId)
// Success message
.then(() => {
// Success message
interaction.reply(`**[This giveaway](https://discord.com/channels/${giveaway.guildId}/${giveaway.channelId}/${giveaway.messageId})** has been successfully resumed!`);
})
.catch((e) => {
interaction.reply({
content: e,
ephemeral: true
});
});
}
};

View file

@ -1,26 +0,0 @@
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
module.exports = {
name: 'servericon',
description: 'sends the Server Icon',
run: async (client, interaction) => {
const row = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setLabel(`Server Icon URL`)
.setStyle(ButtonStyle.Link)
.setURL(`${interaction.guild.iconURL()}?size=1024`))
let embed = new EmbedBuilder()
.setAuthor({ name: interaction.guild.name })
.setImage(interaction.guild.iconURL({ dynamic: true, size: 1024 }))
.setColor('#2F3136')
.setFooter({
text: `©️ Holana`,
iconURL: ('https://ellie.gcoms.xyz/Ellise')
})
interaction.reply({embeds: [embed], components: [row]});
}
}

View file

@ -1,41 +0,0 @@
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: 'serverinfo',
description: 'sends the serverinfo',
run: async (client, interaction) => {
const guild = client.guilds.resolve(interaction.guildId)
const voicechannels = await guild.channels.cache.filter(
(ch) => ch.type === ChannelType.GuildVoice
).size
const textchannels = await guild.channels.cache.filter(
(ch) => ch.type === ChannelType.GuildText
).size
let embed = new EmbedBuilder()
.setTitle("**Server Information**")
.setColor('#2F3136')
.setThumbnail(interaction.guild.iconURL({ dynamic: true }))
.setDescription(`
<:profile:1000770439406157904> **Name:** \`${interaction.guild.name}\`
<:invi:1000459192555024404><:next:1000472400049209385> **Server ID:** ${interaction.guild.id}
<:vip:990606565344182302> **Owner:** <@${(interaction.guild.ownerId)}>
<:invi:1000459192555024404><:next:1000472400049209385> **Owner ID:** ${(await interaction.guild.ownerId)}\n
<:birthday:1000469205520502935> **Created At: ** <t:${parseInt(interaction.guild.createdTimestamp / 1000)}:R>
<:member:1000768159952949258> **Members:** \`${interaction.guild.memberCount}\`
<:role:1000449831157907556> **Roles:** \`${interaction.guild.roles.cache.size}\`
<:boost:990601774438166609> **Emojis:** \`${interaction.guild.emojis.cache.size}\`
<a:nitro:990601542463807528> **Animated Emojis:** \`${interaction.guild.emojis.cache.filter(emoji => emoji.animated).size}\`
<:channel:990666581493284915> **Text Channels:** \`${textchannels}\`
<:voice:990666579182223431> **Voice Channels:** \`${voicechannels}\`\n\n
**Boost Information**\n
<:boosters:1000708963626668052> **Total Boosts:** \`${interaction.guild.premiumSubscriptionCount}\`
<:boost:984643370511118378> **Boost Level:** \`${interaction.guild.premiumTier}\``)
.setAuthor({ name: interaction.guild.name })
.setFooter({
text: `©️ Holana`,
iconURL: ('https://ellie.gcoms.xyz/Ellise')
})
interaction.reply({embeds: [embed]});
}
}

View file

@ -1,164 +0,0 @@
const Discord = require("discord.js")
const { ApplicationCommandOptionType, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
const messages = require("../utils/message");
const ms = require("ms")
module.exports = {
name: 'start',
description: '🎉 Start a giveaway',
options: [
{
name: 'duration',
description: 'How long the giveaway should last for. Example values: 1m, 1h, 1d',
type: ApplicationCommandOptionType.String,
required: true
},
{
name: 'winners',
description: 'How many winners the giveaway should have',
type: ApplicationCommandOptionType.Integer,
required: true
},
{
name: 'prize',
description: 'What the prize of the giveaway should be',
type: ApplicationCommandOptionType.String,
required: true
},
{
name: 'channel',
description: 'The channel to start the giveaway in',
type: ApplicationCommandOptionType.Channel,
required: true
},
{
name: 'bonusrole',
description: 'Role which would recieve bonus entries',
type: ApplicationCommandOptionType.Role,
required: false
},
{
name: 'bonusamount',
description: 'The amount of bonus entries the role will recieve',
type: ApplicationCommandOptionType.Integer,
required: false
},
{
name: 'description',
description: 'Add more details about your giveaway',
type: ApplicationCommandOptionType.String,
required: false
},
{
name: 'role',
description: 'Role you want to add as giveaway joining requirement',
type: ApplicationCommandOptionType.Role,
required: false
},
],
run: async (client, interaction) => {
// If the member doesn't have enough permissions
if (!interaction.member.permissions.has('MANAGE_MESSAGES') && !interaction.member.roles.cache.some((r) => r.name === "Giveaways")) {
return interaction.reply({
content: ':x: You need to have the manage messages permissions to start giveaways.',
ephemeral: true
});
}
const giveawayChannel = interaction.options.getChannel('channel');
const giveawayDuration = interaction.options.getString('duration');
const giveawayWinnerCount = interaction.options.getInteger('winners');
const giveawayPrize = interaction.options.getString('prize');
if (!giveawayChannel.isTextBased()) {
return interaction.reply({
content: ':x: Please select a text channel!',
ephemeral: true
});
}
if(isNaN(ms(giveawayDuration))) {
return interaction.reply({
content: ':x: Please select a valid duration!',
ephemeral: true
});
}
if (giveawayWinnerCount < 1) {
return interaction.reply({
content: ':x: Please select a valid winner count! greater or equal to one.',
})
}
const bonusRole = interaction.options.getRole('bonusrole')
const bonusEntries = interaction.options.getInteger('bonusamount')
let rolereq = interaction.options.getRole('role')
let invite = interaction.options.getString('description')
if (bonusRole) {
if (!bonusEntries) {
return interaction.reply({
content: `:x: You must specify how many bonus entries would ${bonusRole} recieve!`,
ephemeral: true
});
}
}
await interaction.deferReply({ ephemeral: true })
if (rolereq) {
messages.inviteToParticipate = `**React with <:confetti:984296694357319730> to participate!**\n>>> - Only members having ${rolereq} are allowed to participate in this giveaway!`
}
if (rolereq && invite) {
messages.inviteToParticipate = `**React with <:confetti:984296694357319730> to participate!**\n>>> - Only members having ${rolereq} are allowed to participate in this giveaway!`
}
if (!rolereq && invite) {
messages.inviteToParticipate = `**React with <:confetti:984296694357319730> to participate!**\n>>> Read more details about this giveaway down below!`
}
// start giveaway
await client.giveawaysManager.start(giveawayChannel, {
// The giveaway duration
duration: ms(giveawayDuration),
// The giveaway prize
prize: giveawayPrize,
// The giveaway Host
hostedBy: `<@${interaction.user.id}>`,
// The giveaway winner count
winnerCount: parseInt(giveawayWinnerCount),
// BonusEntries If Provided
bonusEntries: [
{
// Members who have the role which is assigned to "rolename" get the amount of bonus entries which are assigned to "BonusEntries"
bonus: new Function('member', `return member.roles.cache.some((r) => r.name === \'${bonusRole ?.name}\') ? ${bonusEntries} : null`),
cumulative: false
}
],
// Messages
messages,
extraData: {
role: rolereq == null ? "null" : rolereq.id,
}
});
interaction.editReply({
content:
`Giveaway started in ${giveawayChannel}!`,
ephemeral: true
})
if (bonusRole) {
let giveaway = new Discord.EmbedBuilder()
.setAuthor({ name: `Bonus Entries Alert!` })
.setDescription(
`**${bonusRole}** Has **${bonusEntries}** Extra Entries in this giveaway!`
)
.setColor("#2F3136")
.setTimestamp();
giveawayChannel.send({ embeds: [giveaway] });
}
}
};

View file

@ -1,234 +0,0 @@
const {
EmbedBuilder,
ActionRowBuilder,
ApplicationCommandOptionType,
AttachmentBuilder,
} = require("discord.js");
const moment = require("moment");
const japiRestPkg = require("japi.rest");
const japiRest = new japiRestPkg('API Key'); // Get ur japi key from https://key.japi.rest
module.exports = {
name: "userinfo",
description: "Gives information about a user or server",
UserPerms: ["MANAGE_MESSAGES"],
BotPerms: ["EMBED_LINKS"],
options: [
{
name: "member",
description:
"Please select a server member of whose information you want",
type: ApplicationCommandOptionType.User,
required: false,
},
],
/**
* @param {Client} client
* @param {CommandInteraction} interaction
* @param {String[]} args
*/
run: async (client, interaction, args) => {
const flags = {
DISCORD_EMPLOYEE: "<:BadgeStaff:990666549163610252>", //Replace your emoji here
DISCORD_PARTNER: "<:Partner:990667758654091274>", //Replace your emoji here
BUGHUNTER_LEVEL_1: "<:bughunterlv1:990666534609354843>", //Replace your emoji here
BUGHUNTER_LEVEL_2: "<:bughunterlv2:990666595795873832>", //Replace your emoji here
HYPESQUAD_EVENTS: "<:discord_serveur:990666593455452200>", //Replace your emoji here
HOUSE_BRAVERY: "<:bravery:990666567593373736>", //Replace your emoji here
HOUSE_BRILLIANCE: "<:brillance:990666570013479042>", //Replace your emoji here
HOUSE_BALANCE: "<:balance:990666565273911427>", //Replace your emoji here
EARLY_SUPPORTER: "<:earlysupporter:990666536802992188>", //Replace your emoji here
SYSTEM: "<:developer:974687011040526376>", //Replace your emoji here
VERIFIED_BOT: "<:gg:991441731163803799><:ggg:991441739590156290>", //Replace your emoji here
VERIFIED_DEVELOPER: "<:developersofDiscord:990666539218899004>", //Replace your emoji here
ACTIVE_DEVELOPER: "<:active_developer:1040582016112013382>",
NITRO: "<:DiscordNitro:990666558235877396>", //Replace your emoji here
BOOSTER_1: "<:1m:991804502455885824>", //Replace your emoji here
BOOSTER_2: "<:2m:991804500388102305>", //Replace your emoji here
BOOSTER_3: "<:3m:991804504678867026>", //Replace your emoji here
BOOSTER_4: "<:6m:991804497384972490>", //Replace your emoji here
BOOSTER_5: "<:9m:991804517706375278>", //Replace your emoji here
BOOSTER_6: "<:12m:991804515198193674>", //Replace your emoji here
BOOSTER_7: "<:15m:991804512434147418>", //Replace your emoji here
BOOSTER_8: "<:18m:991804509766557767>", //Replace your emoji here
BOOSTER_9: "<:24m:991804507308707850>", //Replace your emoji here
};
//badge system
const { options } = interaction;
const user = (await options.getUser("member")) || interaction.user;
const member = await interaction.guild.members.fetch(user);
const owner = await interaction.guild.fetchOwner();
const avpng = member.user.displayAvatarURL({
format: "png",
dynamic: true,
});
const joinedServerAt = `${moment(member.joinedTimestamp).format(
"DD/MM/YYYY"
)}`;
const isBot = member.user.bot
? "<:true:990666572366499940>"
: "<:false:990666574295867393>";
let memberPermissons = `${member.permissions
.toArray()
.map((p) => `${p}`)
.join(", ")}`;
if (member.user.id === owner.id) {
memberPermissons = "SERVER_OWNER";
}
const joinedDiscordAt = `${moment(member.user.createdTimestamp).format(
"DD/MM/YYYY"
)}`;
const statuses = {
online: "🟢",
idle: "🌙",
dnd: "⛔",
offline: "⚫️",
};
const status = `${statuses[member.presence?.status]} ${
member.presence?.status
}`;
const activity = member.presence?.activities[0];
var userstatus = "None";
if (activity) {
if (activity.type === "CUSTOM_STATUS") {
let emoji = `${
activity.emoji
? activity.emoji.id
? `<${activity.emoji.animated ? "a" : ""}:${
activity.emoji.name
}:${activity.emoji.id}>`
: activity.emoji.name
: ""
}`;
userstatus = `${emoji} \`${activity.state || "None"}\``;
} else {
userstatus = `\`${
activity.type.toLowerCase().charAt(0).toUpperCase() +
activity.type.toLowerCase().slice(1)
} ${activity.name}\``;
}
}
const totalRoles = await member.roles.cache.size;
const roles = await member.roles;
const highestRole =
member.roles.highest.id === interaction.guild.id
? "None"
: member.roles.highest;
function trimArray(arr, maxLen = 25) {
if (Array.from(arr.values()).length > maxLen) {
const len = Array.from(arr.values()).length - maxLen;
arr = Array.from(arr.values())
.sort((a, b) => b.rawPosition - a.rawPosition)
.slice(0, maxLen);
arr.map((role) => `<@&${role.id}>`);
arr.push(`${len} more...`);
}
return arr.join(", ");
}
const Roles =
(await member.roles.cache.size) < 25
? Array.from(roles.cache.values())
.sort((a, b) => b.rawPosition - a.rawPosition)
.map((role) => `<@&${role.id}>`)
.join(", ")
: roles.cache.size > 25
? trimArray(roles.cache)
: "None";
japiRest.discord.getUser(user.id).then((user) => {
data = user.data;
fetch(data);
});
async function fetch(data) {
const badges = data.public_flags_array
? data.public_flags_array.map((flag) => {
return flags[flag];
})
: "No Badges.";
const fetchh = require("axios");
let userdata = await fetchh.get(
`https://discord.com/api/users/${user.id}`,
{
headers: {
Authorization: `Bot ${client.token}`,
},
}
);
let banner = userdata.data.banner;
//if (!banner && !userdata.data.accent_color) banner = "a_" + userdata.data.accent_color.toString(16);
if (banner) {
fileType = banner.startsWith("a_") ? ".gif" : ".png";
const url = `https://cdn.discordapp.com/banners/${user.id}/${banner}${fileType}?size=1024`;
const UserInfoEm = new EmbedBuilder()
.setColor("2f3136")
.setTitle("**WHO THE HELL IS THIS?**")
.setThumbnail(member.user.displayAvatarURL({ dynamic: true }))
.setImage(`${url}`)
.setDescription(
`
**Name:** \`${member.user.username}\`
> Nickname: **${member.nickname == null ? "No nickname set" : member.nickname}**
> Tag: **${member.user.tag}**
> ID: **${member.user.id}**
> Avatar: [PNG](${avpng})\n
**Creation:** <t:${parseInt(
member.user.createdTimestamp / 1000
)}:R>
**Joined:** <t:${parseInt(
member.joinedTimestamp / 1000
)}:R>
**Bot:** ${isBot}
**Discord Badges:** ${badges}\n
**Highest Role:** \n${highestRole}\n
**Roles:** \n${Roles}\n
**Permissions:** \n\`\`\`ini\n[ ${memberPermissons} ]\`\`\``
)
.setFooter({
text: "©️ Holana",
iconURL: "https://ellie.gcoms.xyz/Ellise",
});
await interaction.reply({
content: `Information about **${member.user.tag}**`,
embeds: [UserInfoEm],
});
} else {
const UserInfoEm = new EmbedBuilder()
.setColor("2f3136")
.setTitle("**WHO THE HELL IS THIS?**")
.setThumbnail(member.user.displayAvatarURL({ dynamic: true }))
.setDescription(
`
**Name:** \`${member.user.username}\`
> Nickname: **${member.nickname == null ? "No nickname set" : member.nickname}**
> Tag: **${member.user.tag}**
> ID: **${member.user.id}**
> Avatar: [Click here](${avpng})\n
**Creation:** <t:${parseInt(
member.user.createdTimestamp / 1000
)}:R>
**Joined:** <t:${parseInt(
member.joinedTimestamp / 1000
)}:R>
**Bot:** ${isBot}
**Discord Badges:** ${badges}\n
**Highest Role:** \n${highestRole}\n
**Roles:** \n${Roles}\n
**Permissions:** \n\`\`\`ini\n[ ${memberPermissons} ]\`\`\``
)
.setFooter({
text: "©️ Holana",
iconURL: "https://ellie.gcoms.xyz/Ellise",
});
await interaction.reply({
content: `Information about **${member.user.tag}**`,
embeds: [UserInfoEm],
});
}
}
},
};

View file

@ -1,55 +0,0 @@
const Discord = require('discord.js');
module.exports = async(client, commands, options = {
debug: false,
guildId: null
}) => {
const log = (message) => options.debug && console.log(message);
const ready = client.readyAt ? Promise.resolve() : new Promise(resolve => client.once('ready', resolve));
await ready;
const currentCommands = await client.application.commands.fetch(options.guildId && { guildId: options.guildId });
log(`Synchronizing commands...`);
log(`Currently ${currentCommands.size} commands are registered to the bot.`);
const newCommands = commands.filter((command) => !currentCommands.some((c) => c.name === command.name));
for (let newCommand of newCommands) {
await client.application.commands.create(newCommand, options.guildId);
}
log(`Created ${newCommands.length} commands!`);
const deletedCommands = currentCommands.filter((command) => !commands.some((c) => c.name === command.name)).toJSON();
for (let deletedCommand of deletedCommands) {
await deletedCommand.delete();
}
log(`Deleted ${deletedCommands.length} commands!`);
const updatedCommands = commands.filter((command) => currentCommands.some((c) => c.name === command.name));
let updatedCommandCount = 0;
for (let updatedCommand of updatedCommands) {
const newCommand = updatedCommand;
const previousCommand = currentCommands.find((c) => c.name === updatedCommand.name);
let modified = false;
if (previousCommand.description !== newCommand.description) modified = true;
if (!Discord.ApplicationCommand.optionsEqual(previousCommand.options ?? [], newCommand.options ?? [])) modified = true;
if (modified) {
await previousCommand.edit(newCommand);
updatedCommandCount++;
}
}
log(`Updated ${updatedCommandCount} commands!`);
log(`Commands synchronized!`);
return {
currentCommandCount: currentCommands.size,
newCommandCount: newCommands.length,
deletedCommandCount: deletedCommands.length,
updatedCommandCount
};
}