gaber-elsayed

Code monitors || كود مراقبة الرومات

Oct 9th, 2021
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. const { Client, MessageEmbed, ...Discord }= require('discord.js');
  2. const client = new Client({ fetchAllMembers: true });
  3. const fs = require('fs')
  4. const prefix = '-';
  5. const dev = ['', ''] // تحط اي دي الادارة هون تاعت البوت
  6. client.on('ready',() => {
  7. console.log(`My name\'s ${client.user.username}`)
  8. })
  9. client.on('message', async msg => {
  10. const monitors = require('./monitors.json')
  11. for(let [m, c] of Object.entries(monitors))
  12. {
  13. let monitor = client.channels.resolve(m)
  14. if(c != msg.channel.id || !monitor) return;
  15. if(!msg.content && !msg.attachments.first()) return;
  16. let embed = new MessageEmbed()
  17. .addField('**Channel Name**',msg.channel.name)
  18. .addField('**Channel id**',msg.channel.id)
  19. .addField('**Sender**',msg.author.tag)
  20. .addField('**Sender ID**',msg.author.id);
  21. msg.content && embed.addField('**Message**',msg.content)
  22. monitor.send({embed, files:[msg.attachments.first()].filter(Boolean)}).catch(() => void 0 )
  23. }
  24. if(!msg.content.startsWith(prefix)) return;
  25. if(!msg.guild) return;
  26. if(msg.author.bot) return;
  27. const args = msg.content.slice(prefix.length).trim().split(/ +/);
  28. const command = args.shift().toLowerCase();
  29. if(dev.every(id => id != msg.author.id)) return;
  30. if(command == 'info-server-channels')
  31. {
  32. if(!args[0]) return msg.channel.send('**Type server id after command**');
  33. let guild = client.guilds.resolve(args[0])
  34. if(!guild) return msg.channel.send('**I\'m not in this server**');
  35. let messages = [];
  36. let channels = guild.channels.cache.filter(c => c.type == 'text');
  37. let channels_map = channels.map(c => {
  38. return {
  39. name : c.name,
  40. value : `**ID**: ${c.id}\n**Topic**: ${channel.topic || 'No Topic'}\n**NSFW**:${channel.nsfw}\n**Can View**: ${c.viewable}`,
  41. inline : true
  42. }
  43. });
  44. for (let i = 0; i < channels.cache.size; i += 30) {
  45. let channels_slice_map = channels_map.slice(i, i + 30);
  46. let embed = new MessageEmbed()
  47. .setTitle(`**Channels (${(i + 30) / 30})**`)
  48. .addFields(channels_slice_map)
  49. messages.push(embed)
  50. }
  51. messages.map(m => msg.channel.send(m))
  52.  
  53. }
  54. else if(command == 'info-channel')
  55. {
  56. if(!args[0]) return msg.channel.send('**Type channel id after command**');
  57. let channel = client.channels.resolve(args[0])
  58. if(!channel) return msg.channel.send('**I can\'t find this channel**');
  59. if(channel.type != 'text') return msg.channel.send('**Type channel not text**');
  60. let messages = []
  61. let info = new MessageEmbed()
  62. .setTitle('**Info**')
  63. .setDescription(`**Name** :${channel.name}\n**ID**: ${channel.id}\n**Topic**: ${channel.topic || 'No Topic'}\n**NSFW**:${channel.nsfw}\n**Can View**: ${channel.viewable}`)
  64. messages.push(info)
  65.  
  66. let permissions = channel.permissionOverwrites;
  67. let permissions_map = permissions.map( permission => {
  68. let roleOrUser = permission.type == 'member' ? client.users.resolve(permission.id) : channel.guild.roles.resolve(permission.id)
  69. return {
  70. name : '\u200B',
  71. value : `**Name**: ${!roleOrUser ? 'Can\'t get name ': permission.type == 'member' ? '@' + roleOrUser.username + roleOrUser.discriminator : '@' + roleOrUser.name }\n**ID**:${permission.id}\n**Type**: ${permission.type}\n**Allow**:\n${permission.allow.toArray().join('\n')}\n**Deny**:\n${permission.deny.toArray().join('\n')}`
  72. }
  73. });
  74. for (let i = 0; i < permissions.cache.size; i += 30) {
  75. let permissions_slice_map = permissions_map.slice(i, i + 30);
  76. let embed = new MessageEmbed()
  77. .setTitle(`**Permissions (${(i + 30) / 30})**`)
  78. .addFields(permissions_slice_map)
  79. messages.push(embed)
  80. }
  81. messages.map(m => msg.channel.send(m))
  82.  
  83. }
  84. else if(command == 'monitor')
  85. {
  86. let method = args[0]
  87. if(method == 'info')
  88. {
  89. if(!monitors[msg.channel.id]) return msg.channel.send('This channel not monitor any channel')
  90. msg.channel.send(`**monitor channel ID**: ${monitors[msg.channel.id]}`)
  91. }
  92. else if(method == 'delete')
  93. {
  94. if(!monitors[msg.channel.id]) return msg.channel.send('**This channel not monitor any channel**')
  95. delete monitors[msg.channel.id]
  96. msg.channel.send('**Done delete the monitor from channel**')
  97. fs.writeFileSync('./monitor.json',JSON.stringify(monitors))
  98. }
  99. else if(method == 'set')
  100. {
  101. let channel = args[1];
  102. if(!channel) return msg.channel.send('**Type channel id after command**');
  103. let c = client.channels.resolve(channel);
  104. if(!c) return msg.channel.send('**I can\'t find this channel**');
  105. if(channel == msg.channel.id) return msg.channel.send('I can\'t monitor this channel');
  106. if(c.type != 'text') return msg.channel.send('**Type channel not text**');
  107. monitors[msg.channel.id] = channel;
  108. msg.channel.send('**1 - Done set the monitor to channel\n2 - If i don\'t have permissions to see message in the channel so i can\'t monitor the channel**');
  109. fs.writeFileSync('./monitors.json',JSON.stringify(monitors));
  110. }
  111. }
  112. }) // TOXIC CODES
Advertisement
Add Comment
Please, Sign In to add comment