Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const discord = require("discord.js");
- const bot = new discord.Client({
- disableEveryone: true
- });
- const db = require('quick.db')
- const fs = require("fs");
- const botconfig = require("./botconfig.json");
- require("./util/eventHandler")(bot)
- bot.commands = new discord.Collection();
- bot.alias = new discord.Collection();
- fs.readdir("./commands/", (err, files) => {
- if (err) console.log(err)
- let jsfile = files.filter(f => f.split(".").pop() === 'js')
- if (jsfile.length <= 0) {
- return console.log("[LOGS] Couldn't find commands!");
- }
- jsfile.forEach((f, i) => {
- let pull = require(`./commands/${f}`)
- bot.commands.set(pull.config.name, pull);
- pull.config.alias.forEach(alias => {
- bot.alias.set(alias, pull.config.name)
- })
- })
- })
- bot.on("message", (message) => {
- if (message.channel.type === 'dm') return;
- if (message.author.bot) return;
- let prefix = botconfig.prefix
- let messageArray = message.content.split(" ")
- let cmd = messageArray[0]
- let args = messageArray.slice(1)
- if (!message.content.startsWith(prefix)) return;
- let commandfile = bot.commands.get(cmd.slice(prefix.length)) || bot.commands.get(bot.alias.get(cmd.slice(prefix.length)))
- if (commandfile) commandfile.run(bot, message, args)
- });
- bot.on('guildMemberAdd', (member) => {
- const usr = member.user
- const serv = member.guild
- const punishlog = db.fetch(`punishlog_${serv.id}`)
- const punishchan = serv.channels.get(punishlog)
- const bannedboo = db.fetch(`banned_${usr.id}`)
- const reason = db.fetch(`reason_${usr.id}`)
- const proof = db.fetch(`proof_${usr.id}`)
- if (bannedboo === 'true') {
- const guildmode = db.fetch(`guildmode_${serv.id}`)
- if (guildmode === 'ban') {
- if (punishlog !== 'null') {
- const punishchan = serv.channels.get(punishlog)
- const punembed = new discord.RichEmbed()
- .setTitle(`Global Ban Enforced`)
- .setColor(`#ff1919`)
- .setThumbnail(usr.displayAvatarURL)
- .setDescription(`${usr.tag} (\`${usr.id}\`)`)
- .addField(`Action Taken`, `Ban`)
- .addField(`Reason`, reason)
- .setFooter(`Use .checkban ${usr.id} for more information!`)
- punishchan.send(punembed)
- }
- serv.ban(usr.id, {
- reason: reason
- })
- }
- if (guildmode === 'warn') {
- if (punishlog !== 'null') {
- const punembed1 = new discord.RichEmbed()
- .setTitle(`Global Ban Enforced`)
- .setColor(`#ffc219`)
- .setThumbnail(usr.displayAvatarURL)
- .setDescription(`${usr.tag} (\`${usr.id}\`)`)
- .addField(`Action Taken`, `Warn`)
- .addField(`Reason`, reason)
- .setFooter(`Use .checkban ${usr.id} for more information!`)
- punishchan.send(punembed1)
- }
- serv.owner.send(`A globally banned user has joined your server ${serv.name}!\n > **User:** ${usr.tag} (\`${usr.id}\`)\n > **Reason:** ${reason}\n > **Proof:** ${proof}`)
- }
- }
- });
- bot.on("guildCreate", (newGuild) => {
- console.log(`Joined server: ${newGuild.name}`)
- bot.channels.get("645792498995822622").send(`I was added to a guild: \`${newGuild.name}\` with \`${newGuild.members.size}\` members. I am now in ${bot.guilds.size} guilds!`)
- });
- bot.on("guildDelete", (oldGuild) => {
- console.log(`Left server: ${oldGuild.name}`)
- bot.channels.get("645792498995822622").send(`I was removed from a guild: \`${oldGuild.name}\` with \`${newGuild.members.size}\` members. I am now in ${bot.guilds.size} guilds!`)
- });
- bot.login(botconfig.token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement