Skip to content

Commit 6b99cc4

Browse files
committed
Discord.js v13 Handler Template Open Source
Discord.js v13 handler Template Open Source, with slashCommands, with Mongoose Database
1 parent 333b674 commit 6b99cc4

33 files changed

+2430
-0
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TOKEN=
2+
MONGO_URI=

commands/❓ Info/ping.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//=====================================| Import the Module |=====================================\\
2+
3+
const { MessageEmbed } = require('discord.js');
4+
const { authoricon } = require(`${process.cwd()}/settings/embed.json`);
5+
const ms = require('ms');
6+
const { name, author, version } = require(`${process.cwd()}/package.json`);
7+
8+
//=====================================| Code |=====================================\\
9+
10+
module.exports = {
11+
name: 'ping',
12+
cooldown: 5,
13+
aliases: ['pong', 'latency'],
14+
description: 'Ping the bot',
15+
16+
async execute(message, args, client, prefix, Discord) {
17+
// First
18+
const msgembed = new MessageEmbed()
19+
.setAuthor('Pinging...', authoricon)
20+
.setColor('YELLOW');
21+
const msg = await message.channel.send({embeds: [msgembed]})
22+
setTimeout(() => {
23+
// Second
24+
let embed = new MessageEmbed()
25+
.setTitle(`Returns Latency And API Ping`)
26+
.addField('⌛ Websocket Latency', `\`${Math.floor(msg.createdAt - message.createdAt)}ms\``)
27+
.addField('📡 API Latency', `\`${Math.round(client.ws.ping)}ms\``)
28+
.setColor("GREEN")
29+
.setFooter(`Requested by: ${message.author.tag} | © ${author} - ${name} v${version}`, message.author.avatarURL())
30+
31+
message.reply({embeds: [embed], allowedMentions: { repliedUser: false } }).then(m => setTimeout(() => m.delete(), 15000));
32+
msg.delete();
33+
}, 1500)
34+
}
35+
}
36+
37+
38+
/**
39+
/////////////////////////////////////////////////////////////////////
40+
//// ////
41+
\\\\ Bot Coded by GalaXd#9165 \\\\
42+
//// ////
43+
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
44+
//// ////
45+
\\\\ All Right Reserved! \\\\
46+
//// ////
47+
/////////////////////////////////////////////////////////////////////
48+
*/

commands/👑 Owner/eval.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//=====================================| Import the Module |=====================================\\
2+
3+
const { } = require(`${process.cwd()}/settings/config.json`);
4+
const { } = require(`${process.cwd()}/settings/settings.json`);
5+
const { name, author, version } = require(`${process.cwd()}/package.json`);
6+
const { MessageEmbed, MessageAttachment } = require('discord.js');
7+
8+
//=====================================| Code |=====================================\\
9+
10+
module.exports = {
11+
name: 'eval',
12+
cooldown: 5,
13+
category: '👑 Owner',
14+
ownerOnly: true,
15+
description: 'Evaluate code',
16+
botPerms: ['SEND_MESSAGES'],
17+
aliases: ['ev'],
18+
usage: '<code>',
19+
20+
async execute(message, args, client, prefix, Discord) {
21+
if (!args[0]) return message.reply('Please provide some code to evaluate!').then(m => setTimeout(() => m.delete(), 6000));
22+
const code = args.join(' ');
23+
24+
let evaled;
25+
try {
26+
evaled = eval(code);
27+
} catch (err) {
28+
evaled = err;
29+
}
30+
31+
if (typeof evaled !== 'string') evaled = require('util').inspect(evaled);
32+
33+
const embed = new MessageEmbed()
34+
.setColor('RANDOM')
35+
.setTitle('Evaluation')
36+
.setDescription(`\`\`\`js\n${evaled}\n\`\`\``)
37+
.setFooter(${author} - ${name} v${version}`)
38+
message.channel.send({ embeds: [embed] });
39+
}
40+
}
41+
42+
43+
/**
44+
/////////////////////////////////////////////////////////////////////
45+
//// ////
46+
\\\\ Bot Coded by GalaXd#9165 \\\\
47+
//// ////
48+
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
49+
//// ////
50+
\\\\ All Right Reserved! \\\\
51+
//// ////
52+
/////////////////////////////////////////////////////////////////////
53+
*/

commands/📔 Example/test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//=====================================| Import the Module |=====================================\\
2+
3+
const { } = require(`${process.cwd()}/settings/config.json`);
4+
const { } = require(`${process.cwd()}/settings/settings.json`);
5+
const { MessageEmbed, MessageAttachment } = require('discord.js');
6+
7+
//=====================================| Code |=====================================\\
8+
9+
module.exports = {
10+
name: 'test', // put the name of the command here
11+
aliases: ['test'], // put the aliases of the command here
12+
cooldown: 5, // put the cooldown of the command here
13+
category: '📔 Example', // put the category of the command here
14+
ownerOnly: true, // put if the command is owner only here (true/false)
15+
guildOnly: true, // put if the command is guild only here (true/false)
16+
nsfwOnly: false, // put if the command is nsfw only here (true/false)
17+
botPerms: ['SEND_MESSAGES', 'EMBED_LINKS'], // put the bot permissions here
18+
userPerms: ['SEND_MESSAGES'], // put the user permissions here
19+
descriptions: 'Test command.', // put the description of the command here
20+
usage: 'test', // put the usage of the command here
21+
22+
async execute(message, args, client, prefix, Discord) {
23+
const embed = new MessageEmbed()
24+
.setColor('RANDOM')
25+
.setTitle('Test command')
26+
.setDescription('Test command description')
27+
return message.channel.send({ embeds: [embed] });
28+
}
29+
}
30+
31+
32+
/**
33+
/////////////////////////////////////////////////////////////////////
34+
//// ////
35+
\\\\ Bot Coded by GalaXd#9165 \\\\
36+
//// ////
37+
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
38+
//// ////
39+
\\\\ All Right Reserved! \\\\
40+
//// ////
41+
/////////////////////////////////////////////////////////////////////
42+
*/

databases/connect.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//=====================================| Import the Module |=====================================\\
2+
3+
const mongoose = require('mongoose');
4+
5+
//=====================================| Code |=====================================\\
6+
7+
mongoose.connect(process.env.MONGO_URI, {
8+
useNewUrlParser: true,
9+
useUnifiedTopology: true
10+
}).then(() => console.log(`[DATABASE 1] `.bold.green + `Connected to MongoDB!`.yellow)).catch(err => console.log(err));
11+
12+
13+
/**
14+
/////////////////////////////////////////////////////////////////////
15+
//// ////
16+
\\\\ Bot Coded by GalaXd#9165 \\\\
17+
//// ////
18+
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
19+
//// ////
20+
\\\\ All Right Reserved! \\\\
21+
//// ////
22+
/////////////////////////////////////////////////////////////////////
23+
*/

events/client/debug.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//=====================================| Import the Module |=====================================\\
2+
3+
const colors = require('colors');
4+
5+
//=====================================| Code |=====================================\\
6+
7+
module.exports = {
8+
name: 'debug',
9+
once: true,
10+
11+
async execute(client, Discord, info) {
12+
console.log(`[DEBUG] `.bold.green + `${info}`.yellow);
13+
}
14+
}
15+
16+
17+
/**
18+
/////////////////////////////////////////////////////////////////////
19+
//// ////
20+
\\\\ Bot Coded by GalaXd#9165 \\\\
21+
//// ////
22+
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
23+
//// ////
24+
\\\\ All Right Reserved! \\\\
25+
//// ////
26+
/////////////////////////////////////////////////////////////////////
27+
*/

events/client/disconnect.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//=====================================| Import the Module |=====================================\\
2+
3+
const colors = require('colors');
4+
5+
//=====================================| Code |=====================================\\
6+
7+
module.exports = {
8+
name: 'disconnect',
9+
once: true,
10+
11+
async execute(client, Discord) {
12+
console.log(`[DISCONNECT] `.bold.red + `${client.user.tag}`.yellow);
13+
}
14+
}
15+
16+
17+
/**
18+
/////////////////////////////////////////////////////////////////////
19+
//// ////
20+
\\\\ Bot Coded by GalaXd#9165 \\\\
21+
//// ////
22+
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
23+
//// ////
24+
\\\\ All Right Reserved! \\\\
25+
//// ////
26+
/////////////////////////////////////////////////////////////////////
27+
*/

events/client/error.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//=====================================| Import the Module |=====================================\\
2+
3+
const colors = require('colors');
4+
5+
//=====================================| Code |=====================================\\
6+
7+
module.exports = {
8+
name: 'error',
9+
once: true,
10+
11+
async execute(client, Discord, error) {
12+
console.log(`[ERROR] `.bold.red + `${error}`.yellow);
13+
}
14+
}
15+
16+
17+
/**
18+
/////////////////////////////////////////////////////////////////////
19+
//// ////
20+
\\\\ Bot Coded by GalaXd#9165 \\\\
21+
//// ////
22+
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
23+
//// ////
24+
\\\\ All Right Reserved! \\\\
25+
//// ////
26+
/////////////////////////////////////////////////////////////////////
27+
*/

events/client/rateLimit.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//=====================================| Import the Module |=====================================\\
2+
3+
const colors = require('colors');
4+
5+
//=====================================| Code |=====================================\\
6+
7+
module.exports = {
8+
name: 'rateLimit',
9+
once: true,
10+
11+
async execute(client, Discord, rateLimitData) {
12+
console.log(`[RATE LIMIT] `.bold.red + `${rateLimitData.method} ${rateLimitData.path}`.yellow);
13+
}
14+
}
15+
16+
17+
/**
18+
/////////////////////////////////////////////////////////////////////
19+
//// ////
20+
\\\\ Bot Coded by GalaXd#9165 \\\\
21+
//// ////
22+
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
23+
//// ////
24+
\\\\ All Right Reserved! \\\\
25+
//// ////
26+
/////////////////////////////////////////////////////////////////////
27+
*/

events/client/ready.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//=====================================| Import the Module |=====================================\\
2+
3+
const client = require(`${process.cwd()}/index`).client;
4+
const Discord = require('discord.js');
5+
const colors = require('colors');
6+
const dotenv = require('dotenv').config();
7+
const ms = require('ms');
8+
const { PREFIX } = require(`${process.cwd()}/settings/config.json`);
9+
const { author, version } = require(`${process.cwd()}/package.json`);
10+
11+
//=====================================| Code |=====================================\\
12+
13+
module.exports = {
14+
name: 'ready',
15+
once: true,
16+
17+
async execute(client, Discord) {
18+
console.table({
19+
'Name': client.user.tag,
20+
'Author': `${author}`,
21+
'Version': `v${version}`,
22+
'Status': `${client.user.presence.status}`,
23+
'Prefix': PREFIX,
24+
'Discord.js': `v${Discord.version}`,
25+
'Node.js': `${process.version}`,
26+
'Guilds': client.guilds.cache.size,
27+
'Users': client.users.cache.size,
28+
'Channels': client.channels.cache.size,
29+
'Commands': client.commands.size,
30+
'slashCommands': client.slashCommands.size,
31+
'ping': ms(client.uptime),
32+
'Memory Usage': `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB`,
33+
'Platform': process.platform,
34+
'Arch': process.arch,
35+
})
36+
console.log(`[READY] `.bold.green + `${client.user.tag} is online!`.yellow);
37+
38+
// Animated Status Presence
39+
const activities = [
40+
`${PREFIX}help | ${client.guilds.cache.size} Guilds`,
41+
`${PREFIX}help | ${client.users.cache.size} Users`,
42+
`${PREFIX}help | Invite me Now!`
43+
];
44+
setInterval(() => {
45+
let activity = activities[Math.floor(Math.random() * activities.length)];
46+
client.user.setActivity(activity, {
47+
type: "LISTENING", // PLAYING, STREAMING, LISTENING, WATCHING
48+
url: "https://www.twitch.tv/"
49+
});
50+
}, 5000);
51+
}
52+
}
53+
54+
55+
/**
56+
/////////////////////////////////////////////////////////////////////
57+
//// ////
58+
\\\\ Bot Coded by GalaXd#9165 \\\\
59+
//// ////
60+
\\\\ Work for MGalaCyber Development | https://galacyber.xyz \\\\
61+
//// ////
62+
\\\\ All Right Reserved! \\\\
63+
//// ////
64+
/////////////////////////////////////////////////////////////////////
65+
*/

0 commit comments

Comments
 (0)