Advertisement
ninja-gen

message.js

Jan 22nd, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require("discord.js");
  2. const bot = new Discord.Client();
  3. const sql = require("sqlite");
  4. sql.open("./assets/guildsettings.sqlite");
  5.  
  6. module.exports = async (client, message, guild, member) => {
  7.     sql.get(`SELECT * FROM scores WHERE guildId = "${message.guild.id}"`).then(row => {
  8.         if (!row) {
  9.             sql.run("INSERT INTO scores (guildId, prefix, casenumber, autoroleenabled, roletogive, logsenabled, logschannel, automoderation, wlchannel, wlsystem, welcomemessage, leavemessage, dmmessage, slowmode, slowmodetime, invitelinkprotection, websitelinkprotection, dupcharactersprotection, antijoin, modonlycommands, botlock, botlockchannel, levelsystem) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [message.guild.id, ">", 1, "enabled", "none", "enabled", "logs", "disabled", "welcome", "disabled", "Hello %MENTION%, welcome to %GUILDNAME%.", "%NAME% has left the guild", "disabled", "disabled", 3, "disabled", "disabled", "disabled", "disabled", "disabled", "disabled", "bot-commands", "disabled"]);
  10.           }
  11.         }).catch(() => {
  12.         console.error;
  13.         sql.run("CREATE TABLE IF NOT EXISTS scores (guildId TEXT, prefix TEXT, casenumber INTEGER, autoroleenabled TEXT, roletogive TEXT, logsenabled TEXT, logschannel TEXT, automoderation TEXT, wlchannel TEXT, wlsystem TEXT, welcomemessage TEXT, leavemessage TEXT, dmmessage TEXT, slowmode TEXT, slowmodetime INTEGER, invitelinkprotection TEXT, websitelinkprotection TEXT, dupcharactersprotection TEXT, antijoin TEXT, modonlycommands TEXT, botlock TEXT, botlockchannel TEXT, levelsystem TEXT)").then(() => {
  14.           sql.run("INSERT INTO scores (guildId, prefix, casenumber, autoroleenabled, roletogive, logsenabled, logschannel, automoderation, wlchannel, wlsystem, welcomemessage, leavemessage, dmmessage, slowmode, slowmodetime, invitelinkprotection, websitelinkprotection, dupcharactersprotection, antijoin, modonlycommands, botlock, botlockchannel, levelsystem) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", [message.guild.id, ">", 1, "enabled", "none", "enabled", "logs", "disabled", "welcome", "disabled", "Hello %MENTION%, welcome to %GUILDNAME%.", "%NAME% has left the guild", "disabled", "disabled", 3, "disabled", "disabled", "disabled", "disabled", "disabled", "disabled", "bot-commands", "disabled"]);
  15.       })
  16.     })
  17.  
  18.     if (message.author.bot) return;
  19.     if (message.channel.type === 'dm') return;
  20.     sql.get(`SELECT * FROM scores WHERE guildId ="${message.guild.id}"`).then(row => {
  21.         if (!row) return;
  22.             if (!message.guild.member(client.user).hasPermission('SEND_MESSAGES')) return;
  23.             if (!message.guild.member(client.user).hasPermission('VIEW_CHANNEL')) return;
  24.  
  25.              if (row.modonlycommands === "enabled") {
  26.                 if (!message.member.hasPermission("KICK_MEMBERS")) return;
  27.                 const prefix = row.prefix
  28.                 if (row.prefix === undefined) return prefix = ">"
  29.                 if (message.content.indexOf(prefix) !== 0) return;
  30.                 const args = message.content.slice(prefix.length).trim().split(/ +/g);
  31.                 const command = args.shift().toLowerCase();
  32.                     console.log(`[Orcinus] [${message.guild.name}] [${message.author.username}] ${row.prefix}${command} ${args}`);
  33.                     try {
  34.                         let commandFile = require(`../commands/${command}.js`);
  35.                         commandFile.run(client, message, args);
  36.                     } catch (err) {
  37.                         if (err instanceof Error && err.code === "MODULE_NOT_FOUND") {
  38.                             return;
  39.                     } else
  40.                         console.log(err)
  41.                     }
  42.               } else {
  43.             const prefix = row.prefix
  44.             if (row.prefix === undefined) return prefix = ">"
  45.             if (message.content.indexOf(prefix) !== 0) return;
  46.             const args = message.content.slice(prefix.length).trim().split(/ +/g);
  47.             const command = args.shift().toLowerCase();
  48.                 console.log(`[Orcinus] [${message.guild.name}] [${message.author.username}] ${row.prefix}${command} ${args}`);
  49.                 try {
  50.                     let commandFile = require(`../commands/${command}.js`);
  51.                     commandFile.run(client, message, args);
  52.                 } catch (err) {
  53.                         if (err instanceof Error && err.code === "MODULE_NOT_FOUND") {
  54.                             return;
  55.                     } else
  56.                         console.log(err)
  57.                     }
  58.             }
  59.           })
  60.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement