2019-07-24 16:45:29 -06:00
|
|
|
|
// ____ _ ____ _
|
|
|
|
|
|
// / ___| _ _ _ __ _ __ ___ _ __| |_| __ ) ___ | |_
|
|
|
|
|
|
// \___ \| | | | '_ \| '_ \ / _ \| '__| __| _ \ / _ \| __|
|
|
|
|
|
|
// ___) | |_| | |_) | |_) | (_) | | | |_| |_) | (_) | |_
|
|
|
|
|
|
// |____/ \__,_| .__/| .__/ \___/|_| \__|____/ \___/ \__|
|
|
|
|
|
|
// |_| |_|
|
2020-01-25 13:42:44 +00:00
|
|
|
|
// © 2020 Created by Emerald Services
|
|
|
|
|
|
// Licnese: MIT
|
|
|
|
|
|
// SupportBot v5.1.0
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
|
|
|
|
|
const Discord = require("discord.js");
|
|
|
|
|
|
const fs = require("fs");
|
|
|
|
|
|
const bot = new Discord.Client();
|
|
|
|
|
|
|
|
|
|
|
|
bot.commands = new Discord.Collection();
|
|
|
|
|
|
|
2020-01-25 13:48:02 +00:00
|
|
|
|
const yaml = require('js-yaml');
|
2020-01-25 13:55:33 +00:00
|
|
|
|
const supportbot = yaml.load(fs.readFileSync('./supportbot-config.yml', 'utf8'));
|
2020-01-25 13:48:02 +00:00
|
|
|
|
|
2019-06-09 23:52:41 +01:00
|
|
|
|
fs.readdir("./commands/", (err, files) => {
|
|
|
|
|
|
if(err) console.log(err);
|
|
|
|
|
|
|
|
|
|
|
|
let jsfile = files.filter(f => f.split(".").pop() === "js")
|
2020-01-25 13:55:33 +00:00
|
|
|
|
if(jsfile.length <= 0) return console.log(`${supportbot.Bot_Name} No commands found. Try to Re-download the resource`);
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
|
|
|
|
|
jsfile.forEach((f, i) =>{
|
|
|
|
|
|
let props = require(`./commands/${f}`);
|
2020-01-25 13:55:33 +00:00
|
|
|
|
console.log(`[${supportbot.Bot_Name}] > Command Loaded > ${f}`);
|
2019-06-09 23:52:41 +01:00
|
|
|
|
bot.commands.set(props.help.name, props);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
bot.addons = new Discord.Collection();
|
|
|
|
|
|
|
|
|
|
|
|
fs.readdir("./sb-addons/", (err, files) => {
|
|
|
|
|
|
if(err) console.log(err);
|
|
|
|
|
|
|
|
|
|
|
|
let jsfile = files.filter(f => f.split(".").pop() === "js")
|
2020-01-25 13:55:33 +00:00
|
|
|
|
if(jsfile.length <= 0) return console.log(`${supportbot.Bot_Name} No addons detected nor default! Either download addons from https://itzemerald.tk/`);
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
|
|
|
|
|
jsfile.forEach((f, i) =>{
|
|
|
|
|
|
let props = require(`./sb-addons/${f}`);
|
2020-01-25 13:55:33 +00:00
|
|
|
|
console.log(`[${supportbot.Bot_Name}] > Addons Loaded > ${f}`);
|
2019-06-09 23:52:41 +01:00
|
|
|
|
bot.addons.set(props.help.name, props);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
bot.on("ready", async () => {
|
2020-01-25 13:55:33 +00:00
|
|
|
|
bot.user.setActivity(supportbot.BotActivity, {type: supportbot.ActvityType});
|
2019-11-18 15:53:02 +00:00
|
|
|
|
console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`)
|
|
|
|
|
|
console.log(`\u001b[37m`, `Emerald Services has successfully connected to discord`)
|
|
|
|
|
|
console.log(`\u001b[37m`, `Invite your bot with https://discordapp.com/api/oauth2/authorize?client_id=516372960110444574&permissions=8&scope=bot`)
|
|
|
|
|
|
console.log(`\u001b[37m`, `© ️SupportBot created by Emerald Services`)
|
|
|
|
|
|
console.log(`\u001b[32m`, `―――――――――――――――――― SupportBot ――――――――――――――――――`)
|
2019-07-24 16:45:29 -06:00
|
|
|
|
|
2019-06-09 23:52:41 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
bot.on("message", async message => {
|
2020-01-26 22:35:45 +00:00
|
|
|
|
if(message.author.bot) return;
|
|
|
|
|
|
if(message.channel.type === "dm") return;
|
|
|
|
|
|
if (message.content.indexOf(supportbot.Prefix) !== 0) return;
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
2020-01-26 22:35:45 +00:00
|
|
|
|
let messageArray = message.content.split(" ");
|
|
|
|
|
|
const args = message.content.slice(supportbot.Prefix.length).trim().split(/ +/g);
|
|
|
|
|
|
const command = args.shift().toLowerCase();
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
2020-01-26 22:35:45 +00:00
|
|
|
|
const cmd = bot.commands.get(command);
|
|
|
|
|
|
if(!cmd) return;
|
|
|
|
|
|
cmd.run(bot, message, args);
|
|
|
|
|
|
message.delete();
|
2019-06-09 23:52:41 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
bot.on("message", async message => {
|
2020-01-26 22:35:45 +00:00
|
|
|
|
if(message.author.bot) return;
|
|
|
|
|
|
if(message.channel.type === "dm") return;
|
|
|
|
|
|
if (message.content.indexOf(supportbot.Prefix) !== 0) return;
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
2020-01-26 22:35:45 +00:00
|
|
|
|
let messageArray = message.content.split(" ");
|
|
|
|
|
|
const args = message.content.slice(supportbot.Prefix.length).trim().split(/ +/g);
|
|
|
|
|
|
const addon = args.shift().toLowerCase();
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
2020-01-26 22:35:45 +00:00
|
|
|
|
const cmd = bot.addons.get(addon);
|
|
|
|
|
|
if(!cmd) return;
|
|
|
|
|
|
cmd.run(bot, message, args);
|
|
|
|
|
|
message.delete();
|
2019-06-09 23:52:41 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
2019-06-18 16:13:38 +01:00
|
|
|
|
// [SupportBot] Welcome Message && Auto Join Role
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
|
|
|
|
|
bot.on("guildMemberAdd", (member) => {
|
2020-01-25 13:55:33 +00:00
|
|
|
|
let channel = member.guild.channels.find(channel => channel.name === `${supportbot.WelcomeChannel}`)
|
|
|
|
|
|
let autorole = member.guild.roles.find(autorole => autorole.name === `${supportbot.AutoRole}`)
|
2019-06-18 16:13:38 +01:00
|
|
|
|
|
2019-06-09 23:52:41 +01:00
|
|
|
|
const WelcomeMsg= new Discord.RichEmbed()
|
2020-01-25 13:55:33 +00:00
|
|
|
|
.setColor(supportbot.EmbedColour)
|
|
|
|
|
|
.setThumbnail(member.user.avatarURL)
|
|
|
|
|
|
.setDescription(`:wave: ${member.user.username}\n${supportbot.WelcomeMessage}`)
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
|
|
|
|
|
channel.send(WelcomeMsg);
|
2019-06-19 12:21:41 -06:00
|
|
|
|
member.addRole(autorole).catch(console.error);
|
2019-06-18 16:13:38 +01:00
|
|
|
|
|
2019-06-09 23:52:41 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// [SupportBot] Leave Message
|
|
|
|
|
|
|
|
|
|
|
|
bot.on("guildMemberRemove", (member) => {
|
2020-01-25 13:55:33 +00:00
|
|
|
|
let channel = member.guild.channels.find(channel => channel.name === `${supportbot.LeaveChannel}`)
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
|
|
|
|
|
const LeaveMsg= new Discord.RichEmbed()
|
2020-01-25 13:55:33 +00:00
|
|
|
|
.setColor(supportbot.EmbedColour)
|
|
|
|
|
|
.setThumbnail(member.user.avatarURL)
|
|
|
|
|
|
.setDescription(`:wave: ${member.user.username}\n${supportbot.LeaveMessage}`)
|
2019-06-09 23:52:41 +01:00
|
|
|
|
|
|
|
|
|
|
channel.send(LeaveMsg);
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2020-01-25 13:55:33 +00:00
|
|
|
|
bot.login(supportbot.Token);
|