Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- module.exports.run = async (bot, message, args, con) => {
- let name = args[0];
- let title = [];
- let description = [];
- let color = [];
- let i = 1;
- const previewMessage = await message.channel.send('How do you want it? 1 mytitle');
- const setAttribute = (optionString, value) => {
- switch(optionString){
- case '1':
- case 'title': return title.push(value) && i++;
- case '2':
- case 'description': return description.push(value) && i++;
- case '3':
- case 'color': return color.push(value) && i++;
- default: return false;
- }
- }
- const isStop = (content) => ['stop', 'end', 'done'].includes(content.toLowerCase());
- const collector = message.channel.createMessageCollector((m) => m.author.id === message.author.id, {time: 120e3});
- collector.on('collect', message => {
- const { content } = message;
- if (isStop(content) ) return collector.stop();
- let [optionString, ...value] = content.split(' ');
- value = value.join(' ').trim();
- if (!optionString || !value || !setAttribute(optionString, value) ){
- previewMessage.edit('Was no valid input');
- }
- if (i == 2) {
- message.channel.send('Description? 2 [description]');
- } else if (i == 3) {
- message.channel.send('Color? 3 [red]');
- } else {
- }
- });
- collector.on('end', () => {
- con.query(`SELECT * FROM updatable_embeds WHERE command_title = '${name}'`, (err, rows) => {
- if (rows.length < 1) {
- message.channel.send(`${name}'s command embed does not exist..`);
- } else {
- if (color == 'red') {
- var newcolor = '0xff0000';
- }
- let embed = new Discord.RichEmbed()
- .setTitle(title)
- .setDescription(description)
- .setColor(newcolor)
- con.query(`UPDATE updatable_embeds SET embed_title = '${title}', embed_description = '${description}', color = '${newcolor}' WHERE command_title = '${name}'`);
- message.channel.send(`${name}'s embed has been updated!`);
- message.channel.send(embed);
- }
- });
- })
- }
- module.exports.help = {
- name: 'updateembed'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement