Advertisement
gaber-elsayed

Code Note || كود ملاحظات او مفكره

Sep 17th, 2021
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. const Notes = JSON.parse(fs.readFileSync('./Notes.json','utf8'));
  2. const captcha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  3. client.on('message', message => {
  4. let prefix = ">"
  5. if(message.content.startsWith(prefix + 'note')) {
  6. let ID = "";
  7. let name;
  8. let note;
  9. let filter = m => m.author.id === message.author.id;
  10. for (var m = 0; m < 8; m++) {
  11. ID += `${captcha.charAt(Math.floor(Math.random() * captcha.length))}`;
  12. }
  13. message.channel.send('📜 **| Give a name to your note... ✏ **').then(msg => {
  14. message.channel.awaitMessages(filter, {
  15. max: 1,
  16. time: 90000,
  17. errors: ['time']
  18. }).then(collected => {
  19. collected.first().delete();
  20.  
  21. name = collected.first().content;
  22. if(name == `cancel`) {
  23. msg.edit(`**Successfully cancelled.**`).then(hello => {hello.delete({timeout:3000})})
  24. }else{
  25. if(name.length > 18 || name.length < 3) {
  26. msg.edit(`**The length of the name shouldn\'t be shorter than \`3\` or longer than \`18\`.**`).then(msg => {msg.delete({timeout:5000})})
  27. }else{
  28.  
  29. msg.edit(`📝 **| Now, Type your note... ✏**`).then(msg => {
  30. message.channel.awaitMessages(filter, {
  31. max: 1,
  32. time: 90000,
  33. errors: ['time']
  34. }).then(collected => {
  35. collected.first().delete();
  36.  
  37. note = collected.first().content;
  38. if(note == `cancel`) {
  39. msg.edit(`**Successfully cancelled.**`).then(hello => {hello.delete({timeout:3000})})
  40. }else{
  41. msg.edit(`✅ **| Successfully saved your note /n ID: ${ID}**`)
  42.  
  43. Notes[`${message.author.id}-${ID}`] = {
  44. ID: ID,
  45. NAME: name,
  46. DATE: moment(message.createdTimestamp).format ('DD/MM/YYYY hh:mm'),
  47. MSG: note
  48. }
  49. fs.writeFile('./Notes.json', JSON.stringify(Notes), (err) => {
  50. if (err) console.error(err);
  51. })
  52.  
  53. }
  54. })
  55. })
  56. }
  57. }
  58. })
  59. })
  60. }
  61. })
  62.  
  63. client.on('message', message => {
  64. if(message.content.startsWith(prefix + 'myNote')) {
  65. const args = message.content.slice(prefix.length).split(/ +/)
  66. let id = args[1]
  67. if(!id) return message.reply(`Usage ${prefix}myNote <Note_ID>`)
  68. let syntax = `${message.author.id}-${id}`
  69. let note = Notes[syntax]
  70. if(!note) return message.reply("Wrong ID")
  71.  
  72. let noteEmbed = {
  73. color: 0x5e5e5e,
  74. author: {
  75. name: `${note.NAME}`,
  76. icon_url: "https://i.top4top.io/p_1822u2too1.jpg"
  77. },
  78. description: note.MSG,
  79. footer: {
  80. text: `ID: ${note.ID}, Date: ${note.DATE}`,
  81. icon_url: "https://i.top4top.io/p_1822u2too1.jpg"
  82. },
  83. }
  84. message.channel.send({ embed: noteEmbed })
  85. }
  86. }) //MEWO TOXIC CODES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement