Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- let connection = require('../database.js');
- module.exports = {
- name: 'progresssugg',
- aliases: ['inprogsugg', 'workingsugg', 'workingsuggestion', 'inprogresssuggestion', 'inprogresssuggestions', 'workingsuggestion', 'worksugg', 'ps', 'ws'],
- inHelp: 'yes',
- description: 'Marks a specific suggestion as in progress with the current status. **Note:** This can only be ran by moderators.',
- usage: '++progresssugg messageID [status message]',
- category: 'Messages',
- async execute(message, args, client) {
- const msgId = args[0];
- const result = await connection.query(
- `SELECT noSugg from Suggs WHERE noSugg = ?;`,
- [msgId]
- );
- const mId = result[0][0].noSugg;
- console.log(`msgId: ${msgId}\nAuthor: ${author}\nSugg: ${suggestion}\nAvatar: ${avatar}\nStatus: ${stats}`);
- const result2 = await connection.query(
- `SELECT Author from Suggs WHERE noSugg = ?;`,
- [msgId],
- );
- const author = result2[0][0].Author;
- const result3 = await connection.query(
- `SELECT Message from Suggs WHERE noSugg = ?;`,
- [msgId],
- );
- const suggestion = result3[0][0].Message;
- const result4 = await connection.query(
- `SELECT Avatar from Suggs WHERE noSugg = ?;`,
- [msgId],
- );
- const avatar = result4[0][0].Avatar;
- const mod = message.author.tag;
- const stats = args.slice(1).join(' ');
- if(!stats) return message.channel.send('You need to include the status of the suggestion as well as the message ID.');
- console.log(`msgId: ${msgId}\nAuthor: ${author}\nSugg: ${suggestion}\nAvatar: ${avatar}\nStatus: ${stats}`);
- connection.query(
- `UPDATE Suggs SET test = ?, Moderator = ? WHERE noSugg = ?;`,
- [stats, mod, msgId],
- );
- console.log('updated database!')
- const result8 = await connection.query(
- `SELECT test FROM Suggs WHERE noSugg = ?;`,
- [msgId]
- );
- const upStatus = result8[0][0].test;
- console.log(`${upStatus}`)
- const moderator = await connection.query(
- `SELECT Moderator FROM Suggs WHERE noSugg = ?;`,
- [msgId]
- );
- const moder = moderator[0][0].Moderator;
- const inprogress = new Discord.MessageEmbed()
- .setColor('004d4d')
- .setAuthor(`${author}`, `${avatar}`)
- .setDescription(`${suggestion}`)
- .addFields(
- { name: 'Current Status', value: `-TESTING-`},
- { name: 'The moderator that last updated this was', value: `${moder}`},
- )
- .setFooter('If you would like to suggest something, use \`++suggestions\`');
- if(message.member.roles.cache.has('780941276602302523') || message.member.roles.cache.has('718253309101867008')) {
- const newMessage = message.channel.send(inprogress);
- // message.delete();
- } else {
- 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.')
- }
- }
- };
Add Comment
Please, Sign In to add comment