diff --git a/botconfig/config.json b/botconfig/config.json
new file mode 100644
index 0000000..93decb9
--- /dev/null
+++ b/botconfig/config.json
@@ -0,0 +1,4 @@
+{
+ "token": "PASTE YOUR TOKEN IN HERE",
+ "prefix": "!"
+}
diff --git a/botconfig/embed.json b/botconfig/embed.json
new file mode 100644
index 0000000..3ef472d
--- /dev/null
+++ b/botconfig/embed.json
@@ -0,0 +1,6 @@
+{
+ "color": "#3498db",
+ "wrongcolor": "#e01e01",
+ "footertext": "Your Bot Name | powered by milrato.eu",
+ "footericon": "https://img.icons8.com/color/452/discord-logo.png"
+}
diff --git a/commands/Administration/embed.js b/commands/Administration/embed.js
new file mode 100644
index 0000000..bc236d3
--- /dev/null
+++ b/commands/Administration/embed.js
@@ -0,0 +1,48 @@
+const { MessageEmbed } = require("discord.js");
+const config = require("../../botconfig/config.json");
+const ee = require("../../botconfig/embed.json");
+module.exports = {
+ name: "embed",
+ category: "Administration",
+ aliases: ["say-embed"],
+ cooldown: 2,
+ usage: "embed
++ ",
+ description: "Resends a message from u as an Embed",
+ run: async (client, message, args, user, text, prefix) => {
+ try{
+ if(!args[0])
+ return message.channel.send(new MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`❌ ERROR | You didn't provided a Title, nor a Description`)
+ .setDescription(`Usage: \`${prefix}embed ++ \``)
+ );
+ let userargs = args.join(" ").split("++");
+ let title = userargs[0];
+ let desc = userargs.slice(1).join(" ")
+ message.channel.send(new MessageEmbed()
+ .setColor(ee.color)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(title ? title : "")
+ .setDescription(desc ? desc : "")
+ )
+ } catch (e) {
+ console.log(String(e.stack).bgRed)
+ return message.channel.send(new MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`❌ ERROR | An error occurred`)
+ .setDescription(`\`\`\`${e.stack}\`\`\``)
+ );
+ }
+ }
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/commands/Administration/say.js b/commands/Administration/say.js
new file mode 100644
index 0000000..356cd8f
--- /dev/null
+++ b/commands/Administration/say.js
@@ -0,0 +1,40 @@
+const { MessageEmbed } = require("discord.js");
+const config = require("../../botconfig/config.json");
+const ee = require("../../botconfig/embed.json");
+module.exports = {
+ name: "say",
+ category: "Administration",
+ aliases: [""],
+ cooldown: 2,
+ usage: "say ",
+ description: "Resends your Text",
+ run: async (client, message, args, user, text, prefix) => {
+ try{
+ if(!args[0])
+ return message.channel.send(new MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`❌ ERROR | You didn't provided a Text`)
+ .setDescription(`Usage: \`${prefix}say \``)
+ );
+ message.channel.send(text);
+ } catch (e) {
+ console.log(String(e.stack).bgRed)
+ return message.channel.send(new MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`❌ ERROR | An error occurred`)
+ .setDescription(`\`\`\`${e.stack}\`\`\``)
+ );
+ }
+ }
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/commands/Information/help.js b/commands/Information/help.js
new file mode 100644
index 0000000..7ba9651
--- /dev/null
+++ b/commands/Information/help.js
@@ -0,0 +1,85 @@
+const { MessageEmbed } = require("discord.js");
+const config = require("../../botconfig/config.json");
+const ee = require("../../botconfig/embed.json");
+module.exports = {
+ name: "help",
+ category: "Information",
+ aliases: ["h", "commandinfo", "cmds", "cmd"],
+ cooldown: 4,
+ usage: "help [Command]",
+ description: "Returns all Commmands, or one specific command",
+ run: async (client, message, args, user, text, prefix) => {
+ try{
+ if (args[0]) {
+ const embed = new MessageEmbed();
+ const cmd = client.commands.get(args[0].toLowerCase()) || client.commands.get(client.aliases.get(args[0].toLowerCase()));
+ if (!cmd) {
+ return message.channel.send(embed.setColor(ee.wrongcolor).setDescription(`No Information found for command **${args[0].toLowerCase()}**`));
+ }
+ if (cmd.name) embed.addField("**Command name**", `\`${cmd.name}\``);
+ if (cmd.name) embed.setTitle(`Detailed Information about:\`${cmd.name}\``);
+ if (cmd.description) embed.addField("**Description**", `\`${cmd.description}\``);
+ if (cmd.aliases) embed.addField("**Aliases**", `\`${cmd.aliases.map((a) => `${a}`).join("`, `")}\``);
+ if (cmd.cooldown) embed.addField("**Cooldown**", `\`${cmd.cooldown} Seconds\``);
+ else embed.addField("**Cooldown**", `\`1 Second\``);
+ if (cmd.usage) {
+ embed.addField("**Usage**", `\`${config.prefix}${cmd.usage}\``);
+ embed.setFooter("Syntax: <> = required, [] = optional");
+ }
+ if (cmd.useage) {
+ embed.addField("**Useage**", `\`${config.prefix}${cmd.useage}\``);
+ embed.setFooter("Syntax: <> = required, [] = optional");
+ }
+ return message.channel.send(embed.setColor(ee.main));
+ } else {
+ const embed = new MessageEmbed()
+ .setColor(ee.color)
+ .setThumbnail(client.user.displayAvatarURL())
+ .setTitle("HELP MENU 🔰 Commands")
+ .setFooter(`To see command descriptions and inforamtion, type: ${config.prefix}help [CMD NAME]`, client.user.displayAvatarURL());
+ const commands = (category) => {
+ return client.commands.filter((cmd) => cmd.category === category).map((cmd) => `\`${cmd.name}\``);
+ };
+ try {
+ for (let i = 0; i < client.categories.length; i += 1) {
+ const current = client.categories[i];
+ const items = commands(current);
+ const n = 3;
+ const result = [[], [], []];
+ const wordsPerLine = Math.ceil(items.length / 3);
+ for (let line = 0; line < n; line++) {
+ for (let i = 0; i < wordsPerLine; i++) {
+ const value = items[i + line * wordsPerLine];
+ if (!value) continue;
+ result[line].push(value);
+ }
+ }
+ embed.addField(`**${current.toUpperCase()} [${items.length}]**`, `> ${result[0].join("\n> ")}`, true);
+ embed.addField(`\u200b`, `${result[1].join("\n") ? result[1].join("\n") : "\u200b"}`, true);
+ embed.addField(`\u200b`, `${result[2].join("\n") ? result[2].join("\n") : "\u200b"}`, true);
+ }
+ } catch (e) {
+ console.log(String(e.stack).red);
+ }
+ message.channel.send(embed);
+ }
+ } catch (e) {
+ console.log(String(e.stack).bgRed)
+ return message.channel.send(new MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`❌ ERROR | An error occurred`)
+ .setDescription(`\`\`\`${e.stack}\`\`\``)
+ );
+ }
+ }
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/commands/Information/ping.js b/commands/Information/ping.js
new file mode 100644
index 0000000..29c9fff
--- /dev/null
+++ b/commands/Information/ping.js
@@ -0,0 +1,43 @@
+const { MessageEmbed } = require("discord.js");
+const config = require("../../botconfig/config.json");
+const ee = require("../../botconfig/embed.json");
+module.exports = {
+ name: "ping",
+ category: "Information",
+ aliases: ["latency"],
+ cooldown: 2,
+ usage: "ping",
+ description: "Gives you information on how fast the Bot can respond to you",
+ run: async (client, message, args, user, text, prefix) => {
+ try{
+ message.channel.send(new MessageEmbed()
+ .setColor(ee.color)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`🏓 Pinging....`)
+ ).then(msg=>{
+ msg.edit(new MessageEmbed()
+ .setColor(ee.color)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`🏓 Ping is \`${Math.round(client.ws.ping)}ms\``)
+ );
+ })
+ } catch (e) {
+ console.log(String(e.stack).bgRed)
+ return message.channel.send(new MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`❌ ERROR | An error occurred`)
+ .setDescription(`\`\`\`${e.stack}\`\`\``)
+ );
+ }
+ }
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/commands/Information/uptime.js b/commands/Information/uptime.js
new file mode 100644
index 0000000..0920589
--- /dev/null
+++ b/commands/Information/uptime.js
@@ -0,0 +1,38 @@
+const { MessageEmbed } = require("discord.js");
+const config = require("../../botconfig/config.json");
+const ee = require("../../botconfig/embed.json");
+const { duration } = require("../../handlers/functions")
+module.exports = {
+ name: "uptime",
+ category: "Information",
+ aliases: [""],
+ cooldown: 10,
+ usage: "uptime",
+ description: "Returns the duration on how long the Bot is online",
+ run: async (client, message, args, user, text, prefix) => {
+ try{
+ message.channel.send(new MessageEmbed()
+ .setColor(ee.color)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`:white_check_mark: **${client.user.username}** is since:\n ${duration(client.uptime)} online`)
+ );
+ } catch (e) {
+ console.log(String(e.stack).bgRed)
+ return message.channel.send(new MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`❌ ERROR | An error occurred`)
+ .setDescription(`\`\`\`${e.stack}\`\`\``)
+ );
+ }
+ }
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/events/client/disconnect.js b/events/client/disconnect.js
new file mode 100644
index 0000000..54147cc
--- /dev/null
+++ b/events/client/disconnect.js
@@ -0,0 +1,13 @@
+//here the event starts
+module.exports = client => {
+ console.log(`You have been disconnected at ${new Date()}.`.red)
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/events/client/error.js b/events/client/error.js
new file mode 100644
index 0000000..21a60ff
--- /dev/null
+++ b/events/client/error.js
@@ -0,0 +1,13 @@
+//here the event starts
+module.exports = client => {
+ console.error();
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/events/client/ready.js b/events/client/ready.js
new file mode 100644
index 0000000..bfadc09
--- /dev/null
+++ b/events/client/ready.js
@@ -0,0 +1,37 @@
+//here the event starts
+const config = require("../../botconfig/config.json")
+module.exports = client => {
+ try{
+ const stringlength = 69;
+ console.log("\n")
+ console.log(` ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓`.bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + " ".repeat(-1+stringlength-` ┃ `.length)+ "┃".bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + `Discord Bot is online!`.bold.brightGreen + " ".repeat(-1+stringlength-` ┃ `.length-`Discord Bot is online!`.length)+ "┃".bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + ` /--/ ${client.user.tag} /--/ `.bold.brightGreen+ " ".repeat(-1+stringlength-` ┃ `.length-` /--/ ${client.user.tag} /--/ `.length)+ "┃".bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + " ".repeat(-1+stringlength-` ┃ `.length)+ "┃".bold.brightGreen)
+ console.log(` ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛`.bold.brightGreen)
+ }catch{ /* */ }
+
+ try{
+ client.user.setActivity(client.user.username, { type: "PLAYING" });
+ }catch (e) {
+ console.log(String(e.stack).red);
+ }
+ //Change status each 10 minutes
+ setTimeout(()=>{
+ try{
+ client.user.setActivity(client.user.username, { type: "PLAYING" });
+ }catch (e) {
+ console.log(String(e.stack).red);
+ }
+ }, 10*60*1000)
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/events/client/reconnecting.js b/events/client/reconnecting.js
new file mode 100644
index 0000000..29786c4
--- /dev/null
+++ b/events/client/reconnecting.js
@@ -0,0 +1,14 @@
+//here the event starts
+module.exports = client => {
+ console.log(`Reconnceting at ${new Date()}.`.bgYellow.black)
+}
+
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/events/client/warn.js b/events/client/warn.js
new file mode 100644
index 0000000..7d0e477
--- /dev/null
+++ b/events/client/warn.js
@@ -0,0 +1,13 @@
+//here the event starts
+module.exports = client => {
+ console.warn();
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/events/guild/message.js b/events/guild/message.js
new file mode 100644
index 0000000..d0237c2
--- /dev/null
+++ b/events/guild/message.js
@@ -0,0 +1,120 @@
+/**
+ * @INFO
+ * Loading all needed File Information Parameters
+*/
+const config = require("../../botconfig/config.json"); //loading config file with token and prefix, and settings
+const ee = require("../../botconfig/embed.json"); //Loading all embed settings like color footertext and icon ...
+const Discord = require("discord.js"); //this is the official discord.js wrapper for the Discord Api, which we use!
+const { escapeRegex} = require("../../handlers/functions"); //Loading all needed functions
+//here the event starts
+module.exports = async (client, message) => {
+ try {
+ //if the message is not in a guild (aka in dms), return aka ignore the inputs
+ if (!message.guild) return;
+ // if the message author is a bot, return aka ignore the inputs
+ if (message.author.bot) return;
+ //if the channel is on partial fetch it
+ if (message.channel.partial) await message.channel.fetch();
+ //if the message is on partial fetch it
+ if (message.partial) await message.fetch();
+ //get the current prefix from the botconfig/config.json
+ let prefix = config.prefix
+ //the prefix can be a Mention of the Bot / The defined Prefix of the Bot
+ const prefixRegex = new RegExp(`^(<@!?${client.user.id}>|${escapeRegex(prefix)})\\s*`);
+ //if its not that then return
+ if (!prefixRegex.test(message.content)) return;
+ //now define the right prefix either ping or not ping
+ const [, matchedPrefix] = message.content.match(prefixRegex);
+ //create the arguments with sliceing of of the rightprefix length
+ const args = message.content.slice(matchedPrefix.length).trim().split(/ +/);
+ //creating the cmd argument by shifting the args by 1
+ const cmd = args.shift().toLowerCase();
+ //if no cmd added return error
+ if (cmd.length === 0) return message.channel.send(new Discord.MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`❌ Unkown command, try: **\`${prefix}help\`**`)
+ .setDescription(`To play Music simply type \`${prefix}play \`\n\nTo create a unique Requesting Setup type \`${prefix}setup\``)
+ )
+ //get the command from the collection
+ let command = client.commands.get(cmd);
+ //if the command does not exist, try to get it by his alias
+ if (!command) command = client.commands.get(client.aliases.get(cmd));
+ //if the command is now valid
+ if (command){
+ if (!client.cooldowns.has(command.name)) { //if its not in the cooldown, set it too there
+ client.cooldowns.set(command.name, new Discord.Collection());
+ }
+ const now = Date.now(); //get the current time
+ const timestamps = client.cooldowns.get(command.name); //get the timestamp of the last used commands
+ const cooldownAmount = (command.cooldown || 1.5) * 1000; //get the cooldownamount of the command, if there is no cooldown there will be automatically 1 sec cooldown, so you cannot spam it^^
+ if (timestamps.has(message.author.id)) { //if the user is on cooldown
+ const expirationTime = timestamps.get(message.author.id) + cooldownAmount; //get the amount of time he needs to wait until he can run the cmd again
+ if (now < expirationTime) { //if he is still on cooldonw
+ const timeLeft = (expirationTime - now) / 1000; //get the lefttime
+ return message.channel.send(new Discord.MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext,ee.footericon)
+ .setTitle(`❌ Please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`)
+ ); //send an information message
+ }
+ }
+ timestamps.set(message.author.id, now); //if he is not on cooldown, set it to the cooldown
+ setTimeout(() => timestamps.delete(message.author.id), cooldownAmount); //set a timeout function with the cooldown, so it gets deleted later on again
+ try{
+ //try to delete the message of the user who ran the cmd
+ try{ message.delete(); }catch{}
+ //if Command has specific permission return error
+ if(command.memberpermissions && !message.member.hasPermission(command.memberpermissions)) {
+ return message.channel.send(new Discord.MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle("❌ Error | You are not allowed to run this command!")
+ .setDescription(`You need these Permissions: \`${command.memberpermissions.join("`, ``")}\``)
+ ).then(msg=>msg.delete({timeout: 5000}).catch(e=>console.log("Couldn't Delete --> Ignore".gray)));
+ }
+ //if the Bot has not enough permissions return error
+ if(!message.guild.me.hasPermission("ADMINISTRATOR")){
+ return message.channel.send(new Discord.MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle("❌ Error | I don't have enough Permissions!")
+ .setDescription("Please give me ADMINISTRATOR, because i need it to delete Messages, Create Channel and execute all Admin Commands "))
+ }
+ //run the command with the parameters: client, message, args, user, text, prefix,
+ command.run(client, message, args, message.member, args.join(" "), prefix);
+ }catch (e) {
+ console.log(String(e.stack).red)
+ return message.channel.send(new Discord.MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle("❌ Something went wrong while, running the: `" + command.name + "` command")
+ .setDescription(`\`\`\`${e.message}\`\`\``)
+ ).then(msg=>msg.delete({timeout: 5000}).catch(e=>console.log("Couldn't Delete --> Ignore".gray)));
+ }
+ }
+ else //if the command is not found send an info msg
+ return message.channel.send(new Discord.MessageEmbed()
+ .setColor(ee.wrongcolor)
+ .setFooter(ee.footertext, ee.footericon)
+ .setTitle(`❌ Unkown command, try: **\`${prefix}help\`**`)
+ .setDescription(`To play Music simply type \`${prefix}play \``)
+ ).then(msg=>msg.delete({timeout: 5000}).catch(e=>console.log("Couldn't Delete --> Ignore".gray)));
+ }catch (e){
+ return message.channel.send(
+ new MessageEmbed()
+ .setColor("RED")
+ .setTitle(`❌ ERROR | An error occurred`)
+ .setDescription(`\`\`\`${e.stack}\`\`\``)
+);
+ }
+ /**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+ */
+}
diff --git a/handlers/command.js b/handlers/command.js
new file mode 100644
index 0000000..66ee9b2
--- /dev/null
+++ b/handlers/command.js
@@ -0,0 +1,35 @@
+const { readdirSync } = require("fs");
+const ascii = require("ascii-table");
+let table = new ascii("Commands");
+table.setHeading("Command", "Load status");
+console.log("Welcome to SERVICE HANDLER /--/ By https://milrato.eu /--/ Discord: Tomato#6966".yellow);
+module.exports = (client) => {
+ try{
+ readdirSync("./commands/").forEach((dir) => {
+ const commands = readdirSync(`./commands/${dir}/`).filter((file) => file.endsWith(".js"));
+ for (let file of commands) {
+ let pull = require(`../commands/${dir}/${file}`);
+ if (pull.name) {
+ client.commands.set(pull.name, pull);
+ table.addRow(file, "Ready");
+ } else {
+ table.addRow(file, `error->missing a help.name,or help.name is not a string.`);
+ continue;
+ }
+ if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach((alias) => client.aliases.set(alias, pull.name));
+ }
+ });
+ console.log(table.toString().cyan);
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+};
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/handlers/events.js b/handlers/events.js
new file mode 100644
index 0000000..252f1af
--- /dev/null
+++ b/handlers/events.js
@@ -0,0 +1,59 @@
+const fs = require("fs");
+const ascii = require("ascii-table");
+let table = new ascii("Events");
+table.setHeading("Events", "Load status");
+const allevents = [];
+module.exports = async (client) => {
+ try{
+ const load_dir = (dir) => {
+ const event_files = fs.readdirSync(`./events/${dir}`).filter((file) => file.endsWith(".js"));
+ for (const file of event_files){
+ const event = require(`../events/${dir}/${file}`)
+ let eventName = file.split(".")[0];
+ allevents.push(eventName);
+ client.on(eventName, event.bind(null, client));
+ }
+ }
+ await ["client", "guild"].forEach(e=>load_dir(e));
+ for (let i = 0; i < allevents.length; i++) {
+ try {
+ table.addRow(allevents[i], "Ready");
+ } catch (e) {
+ console.log(String(e.stack).red);
+ }
+ }
+ console.log(table.toString().cyan);
+ try{
+ const stringlength = 69;
+ console.log("\n")
+ console.log(` ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓`.bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + " ".repeat(-1+stringlength-` ┃ `.length)+ "┃".bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + `Welcome to SERVICE HANDLER!`.bold.brightGreen + " ".repeat(-1+stringlength-` ┃ `.length-`Welcome to SERVICE HANDLER!`.length)+ "┃".bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + ` /-/ By https://milrato.eu /-/`.bold.brightGreen + " ".repeat(-1+stringlength-` ┃ `.length-` /-/ By https://milrato.eu /-/`.length)+ "┃".bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + " ".repeat(-1+stringlength-` ┃ `.length)+ "┃".bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + ` /-/ Discord: Tomato#6966 /-/`.bold.brightGreen + " ".repeat(-1+stringlength-` ┃ `.length-` /-/ By Discord: Tomato#6966 /-/`.length)+ " ┃".bold.brightGreen)
+ console.log(` ┃ `.bold.brightGreen + " ".repeat(-1+stringlength-` ┃ `.length)+ "┃".bold.brightGreen)
+ console.log(` ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛`.bold.brightGreen)
+ }catch{ /* */ }
+ try{
+ const stringlength2 = 69;
+ console.log("\n")
+ console.log(` ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓`.bold.yellow)
+ console.log(` ┃ `.bold.yellow + " ".repeat(-1+stringlength2-` ┃ `.length)+ "┃".bold.yellow)
+ console.log(` ┃ `.bold.yellow + `Logging into the BOT...`.bold.yellow + " ".repeat(-1+stringlength2-` ┃ `.length-`Logging into the BOT...`.length)+ "┃".bold.yellow)
+ console.log(` ┃ `.bold.yellow + " ".repeat(-1+stringlength2-` ┃ `.length)+ "┃".bold.yellow)
+ console.log(` ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛`.bold.yellow)
+ }catch{ /* */ }
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+};
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/handlers/functions.js b/handlers/functions.js
new file mode 100644
index 0000000..c644edc
--- /dev/null
+++ b/handlers/functions.js
@@ -0,0 +1,120 @@
+module.exports = {
+ //get a member lol
+ getMember: function(message, toFind = "") {
+ try{
+ toFind = toFind.toLowerCase();
+ let target = message.guild.members.get(toFind);
+ if (!target && message.mentions.members) target = message.mentions.members.first();
+ if (!target && toFind) {
+ target = message.guild.members.find((member) => {
+ return member.displayName.toLowerCase().includes(toFind) || member.user.tag.toLowerCase().includes(toFind);
+ });
+ }
+ if (!target) target = message.member;
+ return target;
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+ },
+ //changeging the duration from ms to a date
+ duration: function(ms) {
+ const sec = Math.floor((ms / 1000) % 60).toString();
+ const min = Math.floor((ms / (60 * 1000)) % 60).toString();
+ const hrs = Math.floor((ms / (60 * 60 * 1000)) % 60).toString();
+ const days = Math.floor((ms / (24 * 60 * 60 * 1000)) % 60).toString();
+ return `\`${days}Days\`,\`${hrs}Hours\`,\`${min}Minutes\`,\`${sec}Seconds\``;
+ },
+ //function for awaiting reactions
+ promptMessage: async function(message, author, time, validReactions) {
+ try{
+ time *= 1000;
+ for (const reaction of validReactions) await message.react(reaction);
+ const filter = (reaction, user) => validReactions.includes(reaction.emoji.name) && user.id === author.id;
+ return message.awaitReactions(filter, {
+ max: 1,
+ time: time
+ }).then((collected) => collected.first() && collected.first().emoji.name);
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+ },
+ //Function to wait some time
+ delay: function(delayInms) {
+ try{
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve(2);
+ }, delayInms);
+ });
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+ },
+ //randomnumber between 0 and x
+ getRandomInt: function(max) {
+ try{
+ return Math.floor(Math.random() * Math.floor(max));
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+ },
+ //random number between y and x
+ getRandomNum: function(min, max) {
+ try{
+ return Math.floor(Math.random() * Math.floor((max - min) + min));
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+ },
+ //function for creating a bar
+ createBar: function(maxtime, currenttime, size = 25, line = "▬", slider = "🔶") {
+ try{
+ let bar = currenttime > maxtime ? [line.repeat(size / 2 * 2), (currenttime / maxtime) * 100] : [line.repeat(Math.round(size / 2 * (currenttime / maxtime))).replace(/.$/, slider) + line.repeat(size - Math.round(size * (currenttime / maxtime)) + 1), currenttime / maxtime];
+ if (!String(bar).includes("🔶")) return `**[🔶${line.repeat(size - 1)}]**\n**00:00:00 / 00:00:00**`;
+ return `**[${bar[0]}]**\n**${new Date(currenttime).toISOString().substr(11, 8)+" / "+(maxtime==0?" ◉ LIVE":new Date(maxtime).toISOString().substr(11, 8))}**`;
+ }catch (e) {
+ console.log(String(e.stack).bgRed)
+ }
+ },
+ format: function(millis) {
+ try{
+ var h = Math.floor(millis / 3600000),
+ m = Math.floor(millis / 60000),
+ s = ((millis % 60000) / 1000).toFixed(0);
+ if (h < 1) return (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s + " | " + (Math.floor(millis / 1000)) + " Seconds";
+ else return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s + " | " + (Math.floor(millis / 1000)) + " Seconds";
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+ },
+ escapeRegex: function(str) {
+ try{
+ return str.replace(/[.*+?^${}()|[\]\\]/g, `\\$&`);
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+ },
+ arrayMove: function(array, from, to) {
+ try{
+ array = [...array];
+ const startIndex = from < 0 ? array.length + from : from;
+ if (startIndex >= 0 && startIndex < array.length) {
+ const endIndex = to < 0 ? array.length + to : to;
+ const [item] = array.splice(from, 1);
+ array.splice(endIndex, 0, item);
+ }
+ return array;
+ }catch (e){
+ console.log(String(e.stack).bgRed)
+ }
+ }
+}
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/index.js b/index.js
index 4c45a41..dd06567 100644
--- a/index.js
+++ b/index.js
@@ -1,90 +1,44 @@
-//Modules
-const { Client, Collection } = require("discord.js");
-const config = require("./botconfig/config.json"); //loading config file with token and prefix
-const prefix = (config.prefix); //defining the prefix as a constant variable
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
+//Importing all needed Commands
+const Discord = require("discord.js"); //this is the official discord.js wrapper for the Discord Api, which we use!
+const colors = require("colors"); //this Package is used, to change the colors of our Console! (optional and doesnt effect performance)
const fs = require("fs"); //this package is for reading files and getting their inputs
-
-const client = new Client({
-disableEveryone: true //disables, that the bot is able to send @everyone
-, partials: ['MESSAGE', 'CHANNEL', 'REACTION'] }); //creating the client with partials, so you can fetch OLD messages
-
-client.commands = new Collection(); //an collection (like a digital map(database)) for all your commands
-client.aliases = new Collection(); //an collection for all your command-aliases
-const cooldowns = new Collection(); //an collection for cooldown commands of each user
-
+//Creating the Discord.js Client for This Bot with some default settings ;) and with partials, so you can fetch OLD messages
+const client = new Discord.Client({
+ messageCacheLifetime: 60,
+ fetchAllMembers: false,
+ messageCacheMaxSize: 10,
+ restTimeOffset: 0,
+ restWsBridgetimeout: 100,
+ disableEveryone: true,
+ partials: ['MESSAGE', 'CHANNEL', 'REACTION']
+});
+//Client variables to use everywhere
+client.commands = new Discord.Collection(); //an collection (like a digital map(database)) for all your commands
+client.aliases = new Discord.Collection(); //an collection for all your command-aliases
client.categories = fs.readdirSync("./commands/"); //categories
+client.cooldowns = new Discord.Collection(); //an collection for cooldown commands of each user
-["command"].forEach(handler => {
- require(`./handlers/command`)(client);
-}); //this is for command loading in the handler file, one fireing for each cmd
-const eventhandler = require("./handlers/events");
-eventhandler(client); //this is for event handling
-
-//fires each time the bot receives a message
-client.on("message", async message => {
-
- if (message.author.bot) return;// if the message author is a bot, return aka ignore the inputs
- if (!message.guild) return; //if the message is not in a guild (aka in dms), return aka ignore the inputs
-
- if(!message.content.startsWith(prefix)&& message.content.startsWith(client.user.id)) return message.reply(`My Prefix is: **\`${prefix}\`**, tpye \`${prefix}help\` for more information!`); //if the messages is not a command and someone tags the bot, then send an info msg
- if (!message.content.startsWith(prefix)) return; //if the message does not starts with the prefix, return, so only commands are fired!
-
- const args = message.content.slice(prefix.length).trim().split(/ +/g); //creating the argumest (each space == 1 arg)
- const cmd = args.shift().toLowerCase(); //creating the cmd argument by shifting the args by 1
-
- if (cmd.length === 0) return; //if no cmd, then return
-
- let command = client.commands.get(cmd); //get the command from the collection
- if (!command) command = client.commands.get(client.aliases.get(cmd)); //if the command does not exist, try to get it by his alias
-
-
- if (command) //if the command is now valid
- {
- if (!cooldowns.has(command.name)) { //if its not in the cooldown, set it too there
- cooldowns.set(command.name, new Collection());
- }
-
- const now = Date.now(); //get the current time
- const timestamps = cooldowns.get(command.name); //get the timestamp of the last used commands
- const cooldownAmount = (command.cooldown || 1) * 1000; //get the cooldownamount of the command, if there is no cooldown there will be automatically 1 sec cooldown, so you cannot spam it^^
-
- if (timestamps.has(message.author.id)) { //if the user is on cooldown
- const expirationTime = timestamps.get(message.author.id) + cooldownAmount; //get the amount of time he needs to wait until he can run the cmd again
-
- if (now < expirationTime) { //if he is still on cooldonw
- const timeLeft = (expirationTime - now) / 1000; //get the lefttime
- return message.reply(
- `Please wait ${timeLeft.toFixed(1)} more second(s) before reusing the \`${command.name}\` command.`
- ); //send an information message
- }
- }
-
- timestamps.set(message.author.id, now); //if he is not on cooldown, set it to the cooldown
- setTimeout(() => timestamps.delete(message.author.id), cooldownAmount); //set a timeout function with the cooldown, so it gets deleted later on again
- try{
- command.run(client, message, args, message.author, args.join(" "), prefix); //run the command with the parameters: client, message, args, user, text, prefix,
- /* /////////////////////////////////////////
- HERE AN EXAMPLE:
-
- User: Tomato#6966 types command:
-
- !say Hello World, HEY!
-
- what you can get from say cmd parameters:
- client is: the
- message is: the
- user is: the
- text is:
- prefix is:
- */ ///////////////////////////////////////////////////////
- }catch (error){
- console.log(error)
- return message.reply("Something went wrong while, running the: `" + command.name + "` command")
- }
- }
- else //if the command is not found send an info msg
- return message.reply(`Unkown command, try: **\`${prefix}help\`**`)
-
+//Loading files, with the client variable like Command Handler, Event Handler, ...
+["command", "events"].forEach(handler => {
+ require(`./handlers/${handler}`)(client);
});
-
-client.login(config.token); //login into the bot
\ No newline at end of file
+//login into the bot
+client.login(require("./botconfig/config.json").token);
+/**
+ * @INFO
+ * Bot Coded by Tomato#6966 | https://github.com/Tomato6966/Discord-Js-Handler-Template
+ * @INFO
+ * Work for Milrato Development | https://milrato.eu
+ * @INFO
+ * Please mention Him / Milrato Development, when using this Code!
+ * @INFO
+*/
diff --git a/package.json b/package.json
index a48e66e..f1616a9 100644
--- a/package.json
+++ b/package.json
@@ -1,19 +1,20 @@
{
- "name": "discordbothandler",
+ "name": "discord-js-handler-template",
"version": "1.0.0",
- "description": "",
+ "description": "Discord.js Command and Event Handler Template with example Command usages! For Questions: https://discord.gg/fS6qBSm",
"main": "index.js",
- "dependencies": {
- "ascii-table": "^0.0.9",
- "common-tags": "^1.8.0",
- "discord.js": "^12.5.1",
- "got": "^11.8.1"
- },
- "devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "Tomato#6966",
- "license": "ISC"
+ "license": "ISC",
+ "dependencies": {
+ "ascii-table": "0.0.9",
+ "discord.js": "^12.5.1"
+ },
+ "devDependencies": {
+ "ascii-table": "0.0.9",
+ "colors": "^1.4.0"
+ }
}