gaber-elsayed

Suggestions (JS)

Nov 26th, 2019
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. const sug = require("./suggestions.json")
  2.  
  3. client.on("message", msg => {
  4. let message = msg;
  5. let messageArray = msg.content.split(" ");
  6. let args = messageArray.slice(1);
  7. let caseid = Date.now() + msg.author.discriminator
  8. if (msg.content.startsWith(prefix + "suggest" || msg.content.startsWith(prefix + "sug"))){
  9. let suggestionchat = msg.guild.channels.find(channel => channel.name === "الاقتراحات")
  10. // ^^^^^^^^^وأكيد يمديك تعدل اسم الروم لو تبي
  11. let suggestion = args.join(' '); // بتلاقون تعريف الأرقز حقي فوق
  12. if(!suggestion) return message.channel.send('الرجاء وضع اقتراحك بعد الأمر');
  13. if(!suggestionchat) return message.channel.send('لا يمكنني ايجاد الشات');
  14. let suggestionembed = new Discord.RichEmbed()
  15. .setAuthor('New Suggestion!')
  16. .addField('الأقتراح من قبل', `${message.author.tag} **|** ${message.author.id}`, true)
  17. .addField('اسم السيرفر المرسل منه الأقتراح', `${message.guild.name} **|** ${message.guild.id}`)
  18. .addField('الأقتراح', `${suggestion}`)
  19. .setColor('#ffffff')
  20. .setFooter(`ID: ${Date.now() + msg.author.discriminator}`)
  21. .setThumbnail(message.author.avatarURL)
  22. .setTimestamp();
  23. suggestionchat.send(suggestionembed).then(send =>{
  24. sug[caseid] = {
  25. message: suggestion,
  26. by: msg.author.id,
  27. Time: message.createdAt,
  28. thisisimportant: send.id
  29. }
  30. fs.writeFile("./suggestions.json", JSON.stringify(sug, null , 4), err =>{
  31. console.log(err);
  32. })
  33. })
  34. message.channel.send("**تم أرسال اقتراحك**")
  35. }
  36.  
  37. if (msg.content.startsWith(prefix + "allsuggestions")){
  38. let data = undefined;
  39. for(i in sug){
  40. if (data === undefined) {
  41. data = "";
  42. }
  43. let data1 = sug[i].message
  44. let data2 = sug[i].by
  45. const stuff = `${data1} **By** <@${data2}>`;
  46. data += (stuff) + "\n\n";
  47. }
  48. if (data !== undefined) {
  49. const richEmbed = new Discord.RichEmbed();
  50. richEmbed.addField("Messages", data)
  51. msg.channel.send(richEmbed)
  52. }else if(data === undefined) return message.channel.send("Couldn't find any suggestion")
  53. }
  54. if (msg.content.startsWith(prefix + "dsug")){
  55. let that = args.join(' ')
  56. if(!that) return message.channel.send("Hmmm please put an id")
  57. if(sug[that] === undefined) return message.channel.send("Couldn't find that suggestion id!")
  58. message.channel.send("Deleted!")
  59. message.guild.channels.find(ch => ch.name === "الاقتراحات").fetchMessage(sug[that].thisisimportant).then(msg => msg.delete());
  60. delete sug[that];
  61. fs.writeFile("./suggestions.json", JSON.stringify(sug, null , 4), err =>{
  62. console.log(err)
  63. })
  64. }
  65.  
  66. });
Advertisement
Add Comment
Please, Sign In to add comment