JohnTomah

Untitled

Mar 25th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. const reply = JSON.parse(fs.readFileSync('./replys.json' , 'utf8'));
  2. client.on('message', async message => {
  3. let messageArray = message.content.split(" ");
  4. if(message.content.startsWith(prefix + "setreply")) {
  5. let filter = m => m.author.id === message.author.id;
  6. let thisMessage;
  7. let thisFalse;
  8.  
  9. if(!message.member.hasPermission("MANAGE_GUILD")) return message.channel.send('You don\'t have permission').then(msg => {
  10. msg.delete(4500);
  11. message.delete(4500);
  12. });
  13.  
  14. message.channel.send('**:pencil: Write Message | اكتب رسالة :pencil2: **').then(msg => {
  15.  
  16. message.channel.awaitMessages(filter, {
  17. max: 1,
  18. time: 90000,
  19. errors: ['time']
  20. })
  21. .then(collected => {
  22. collected.first().delete();
  23. thisMessage = collected.first().content;
  24. let boi;
  25. msg.edit('**:scroll: Write Reply | اكتب الرد :pencil2: **').then(msg => {
  26.  
  27. message.channel.awaitMessages(filter, {
  28. max: 1,
  29. time: 90000,
  30. errors: ['time']
  31. })
  32. .then(collected => {
  33. collected.first().delete();
  34. boi = collected.first().content;
  35. msg.edit('**✅Done | تم ✅**').then(msg => {
  36.  
  37. message.channel.awaitMessages(filter, {
  38. max: 1,
  39. time: 90000,
  40. errors: ['time']
  41. })
  42. let embed = new Discord.RichEmbed()
  43. .setTitle('**Done The Autoreply Code Has Been Setup**')
  44. .addField('Message:', `${thisMessage}`)
  45. .addField('Reply:', `${boi}`)
  46. .setThumbnail(message.author.avatarURL)
  47. .setFooter(`${client.user.username}`)
  48. message.channel.sendEmbed(embed)
  49. reply[message.guild.id] = {
  50. msg: thisMessage,
  51. reply: boi,
  52. }
  53. fs.writeFile("./replys.json", JSON.stringify(reply), (err) => {
  54. if (err) console.error(err)
  55. })
  56. }
  57. )
  58. })
  59. })
  60. })
  61. })
  62. }})
  63. client.on('message', async message => {
  64. if(message.content === reply[message.guild.id].message) {
  65. message.channel.send(reply[message.guild.id].reply)
  66. }}
  67. )
Advertisement
Add Comment
Please, Sign In to add comment