gaber-elsayed

Blacklist - servers

Jun 7th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. let blacklists = require ('./blacklists.json')
  2.  
  3. function saveB() {
  4. fs.writeFileSync ('./blacklists.json', JSON.stringify (blacklists, null, 4), (err) => {
  5. if (err) throw err;
  6. })
  7. }
  8.  
  9. let settings = {
  10. "owners": ["owner id"]
  11. }
  12.  
  13. client.on ('message', async (message) => {
  14. if (!message.guild || message.author.bot) return undefined;
  15. let Command = message.content.split(' ')[0].toLowerCase();
  16. let args = message.content.split(' ');
  17.  
  18. if (Command == prefix + 'blacklist') {
  19. if (!settings.owners.includes (message.author.id)) return null;
  20. if (!args[1] || !args[2] || !args[3]) return message.reply ('Ex: '+Command+' add/remove <serverid> <reason>');
  21. if (!['add', 'remove'].includes (args[1].toLowerCase())) return message.channel.send ('**Invalid args 🙄.**');
  22. let truefalse = args[1].toLowerCase() == 'add' ? true : false;
  23. let nahah = truefalse ? 'blacklisted' : 'unblacklisted';
  24. if (truefalse && Client.guilds.get (args[2])) {
  25. let guild = Client.guilds.get (args[2]);
  26. guild.owner.send (`**Your server \`${guild.name}\` has been blacklisted for \`${args.slice(3).join(' ')}\`**`).catch (err => undefined).then(() => guild.leave());
  27.  
  28. };
  29. if (!blacklists[args[2]]) {
  30. blacklists[args[2]] = {
  31. "status": truefalse,
  32. "reason": args.slice(3).join(' ').split('`').join('')
  33. };
  34. saveB();
  35. message.channel.send (`**Succesfully ${nahah} ${Client.guilds.get (args[2]) ? Client.guilds.get (args[2]).name+'.**' : 'the server.**'}`);
  36. } else {
  37. blacklists[args[2]] = {
  38. "status": truefalse,
  39. "reason": args.slice(3).join(' ').split('`').join('')
  40. };
  41. saveB();
  42. message.channel.send (`**Succesfully ${nahah} ${Client.guilds.get (args[2]) ? Client.guilds.get (args[2]).name+'.**' : 'the server.**'}`);
  43. }
  44. };
  45. if (Command == prefix+'leave') {
  46. if (!settings.owners.includes (message.author.id)) return null;
  47. if (!args [1]) return message.channel.send('**Ex: ' + Command+ ' <server name / server id>**');
  48. let guild = Client.guilds.get (args[1]) || Client.guilds.find (Guild => (Guild.name == args.slice(1).join(' ')) || (Guild.name.startsWith (args.slice(1).join(' '))))
  49. if (!guild) return message.channel.send (`**No guild found with id/name \`${args.slice(1).join(' ')}\`**`)
  50. this.emojis = {
  51. yes: '✅',
  52. no: '❌'
  53. };
  54. message.channel.send (`**Are You sure you want me left this server:\nName: ${guild.name}\nMembers Count: ${guild.memberCount}\nOwnerShip: ${guild.owner} (ID: ${guild.ownerID})**`).then (async (msg) => {
  55. await msg.react (this.emojis.yes);
  56. await msg.react (this.emojis.no);
  57. let filter = (reaction, user) => {
  58. return user.id == message.author.id;
  59. }
  60. let collector = await msg.createReactionCollector (filter, {time: 1000 * 15});
  61. collector.on ('collect', async (r) => {
  62. collector.stop();msg.delete().catch (err => undefined);
  63. switch (r.emoji.name) {
  64. case this.emojis.yes:
  65. message.channel.send ('**Successfully left the server.**').then (() => guild.leave()).catch (err => guild.leave());
  66. break;
  67. case this.emojis.no:
  68. message.channel.send ('**Successfully cancelled.**');
  69. break;
  70. }
  71. }).on ('end', () => {
  72. msg.delete();
  73. message.reply ('**Time out.**');
  74. })
  75. })
  76. }
  77. });
  78. client.on ('guildCreate', Guild => {
  79. if (blacklists [Guild.id] && blacklists[Guild.id].status == true){
  80. Guild.owner.send (`**You can't add me to \`${Guild.name}\` server this server is blacklisted for \`${blacklists[Guild.id].reason}\`**`).catch (err => undefined).then (() => Guild.leave());
  81. }
  82. });
  83.  
  84. //By 3Mo_Steve | Toxic Codes
Add Comment
Please, Sign In to add comment