Advertisement
Guest User

Untitled

a guest
May 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. const Discord = require('discord.js');
  2.  
  3. module.exports.run = async (bot, message, args, con) => {
  4. let name = args[0];
  5. let title = [];
  6. let description = [];
  7. let color = [];
  8. let i = 1;
  9.  
  10. const previewMessage = await message.channel.send('How do you want it? 1 mytitle');
  11.  
  12. const setAttribute = (optionString, value) => {
  13. switch(optionString){
  14. case '1':
  15. case 'title': return title.push(value) && i++;
  16. case '2':
  17. case 'description': return description.push(value) && i++;
  18. case '3':
  19. case 'color': return color.push(value) && i++;
  20. default: return false;
  21. }
  22. }
  23. const isStop = (content) => ['stop', 'end', 'done'].includes(content.toLowerCase());
  24.  
  25. const collector = message.channel.createMessageCollector((m) => m.author.id === message.author.id, {time: 120e3});
  26.  
  27. collector.on('collect', message => {
  28. const { content } = message;
  29. if (isStop(content) ) return collector.stop();
  30.  
  31. let [optionString, ...value] = content.split(' ');
  32. value = value.join(' ').trim();
  33.  
  34. if (!optionString || !value || !setAttribute(optionString, value) ){
  35. previewMessage.edit('Was no valid input');
  36. }
  37.  
  38. if (i == 2) {
  39. message.channel.send('Description? 2 [description]');
  40. } else if (i == 3) {
  41. message.channel.send('Color? 3 [red]');
  42. } else {
  43.  
  44. }
  45. });
  46.  
  47. collector.on('end', () => {
  48. con.query(`SELECT * FROM updatable_embeds WHERE command_title = '${name}'`, (err, rows) => {
  49. if (rows.length < 1) {
  50. message.channel.send(`${name}'s command embed does not exist..`);
  51. } else {
  52. if (color == 'red') {
  53. var newcolor = '0xff0000';
  54. }
  55. let embed = new Discord.RichEmbed()
  56. .setTitle(title)
  57. .setDescription(description)
  58. .setColor(newcolor)
  59.  
  60. con.query(`UPDATE updatable_embeds SET embed_title = '${title}', embed_description = '${description}', color = '${newcolor}' WHERE command_title = '${name}'`);
  61. message.channel.send(`${name}'s embed has been updated!`);
  62. message.channel.send(embed);
  63. }
  64. });
  65. })
  66. }
  67.  
  68. module.exports.help = {
  69. name: 'updateembed'
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement