DudeThatsErin

prog-sugg.js

Mar 2nd, 2021 (edited)
885
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. let connection = require('../database.js');
  3.  
  4. module.exports = {
  5.     name: 'progresssugg',
  6.     aliases: ['inprogsugg', 'workingsugg', 'workingsuggestion', 'inprogresssuggestion', 'inprogresssuggestions', 'workingsuggestion', 'worksugg', 'ps', 'ws'],
  7.     inHelp: 'yes',
  8.     description: 'Marks a specific suggestion as in progress with the current status. **Note:** This can only be ran by moderators.',
  9.     usage: '++progresssugg messageID [status message]',
  10.     category: 'Messages',
  11.     async execute(message, args, client) {
  12.  
  13.         const msgId = args[0];
  14.         const result = await connection.query(
  15.             `SELECT noSugg from Suggs WHERE noSugg = ?;`,
  16.             [msgId]
  17.         );
  18.         const mId = result[0][0].noSugg;
  19.         console.log(`msgId: ${msgId}\nAuthor: ${author}\nSugg: ${suggestion}\nAvatar: ${avatar}\nStatus: ${stats}`);
  20.  
  21.         const result2 = await connection.query(
  22.             `SELECT Author from Suggs WHERE noSugg = ?;`,
  23.             [msgId],
  24.         );
  25.         const author = result2[0][0].Author;
  26.  
  27.         const result3 = await connection.query(
  28.             `SELECT Message from Suggs WHERE noSugg = ?;`,
  29.             [msgId],
  30.         );
  31.         const suggestion = result3[0][0].Message;
  32.  
  33.         const result4 = await connection.query(
  34.             `SELECT Avatar from Suggs WHERE noSugg = ?;`,
  35.             [msgId],
  36.         );
  37.         const avatar = result4[0][0].Avatar;
  38.  
  39.         const mod = message.author.tag;
  40.  
  41.         const stats = args.slice(1).join(' ');
  42.         if(!stats) return message.channel.send('You need to include the status of the suggestion as well as the message ID.');
  43.         console.log(`msgId: ${msgId}\nAuthor: ${author}\nSugg: ${suggestion}\nAvatar: ${avatar}\nStatus: ${stats}`);
  44.  
  45.         connection.query(
  46.             `UPDATE Suggs SET test = ?, Moderator = ? WHERE noSugg = ?;`,
  47.             [stats, mod, msgId],
  48.         );
  49.         console.log('updated database!')
  50.  
  51.         const result8 = await connection.query(
  52.             `SELECT test FROM Suggs WHERE noSugg = ?;`,
  53.             [msgId]
  54.         );
  55.         const upStatus = result8[0][0].test;
  56.         console.log(`${upStatus}`)
  57.  
  58.         const moderator = await connection.query(
  59.             `SELECT Moderator FROM Suggs WHERE noSugg = ?;`,
  60.             [msgId]
  61.         );
  62.         const moder = moderator[0][0].Moderator;
  63.  
  64.         const inprogress = new Discord.MessageEmbed()
  65.             .setColor('004d4d')
  66.             .setAuthor(`${author}`, `${avatar}`)
  67.             .setDescription(`${suggestion}`)
  68.             .addFields(
  69.                 { name: 'Current Status', value: `-TESTING-`},
  70.                 { name: 'The moderator that last updated this was', value: `${moder}`},
  71.             )
  72.             .setFooter('If you would like to suggest something, use \`++suggestions\`');
  73.  
  74.         if(message.member.roles.cache.has('780941276602302523') || message.member.roles.cache.has('718253309101867008')) {
  75.             const newMessage = message.channel.send(inprogress);
  76.            // message.delete();
  77.         } else {
  78.             message.channel.send('You do not have the permissions to use this command. You must be a moderator of our server. If this is in error, please report it.')
  79.         }
  80.  
  81.     }
  82. };
RAW Paste Data