Advertisement
Guest User

code

a guest
May 13th, 2019
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. const cp = require('child_process')
  2.  
  3. const req = async module => {
  4. try {
  5. require.resolve(module)
  6. } catch (e) {
  7. console.log(`Could not resolve "${module}"\nInstalling`)
  8. cp.execSync(`npm install ${module}`)
  9. await setImmediate(() => {})
  10. console.log(`"${module}" has been installed`)
  11. }
  12. console.log(`Requiring "${module}"`)
  13. try {
  14. return require(module)
  15. } catch (e) {
  16. console.log(`Could not include "${module}". Restart the script`)
  17. process.exit(1)
  18. }
  19. }
  20.  
  21. const main = async() => {
  22. process.on('unhandledRejection', (reason, promise) => {});
  23. process.on('uncaughtException', (reason, promise) => {});
  24.  
  25. var notallowed = ['nope', 'dope'] //add words in this array
  26. rgx = new RegExp(notallowed.join("|"), "gi");
  27.  
  28. let filter = function(str) {
  29. return str.replace(rgx, "")
  30. }
  31.  
  32. var start = async(token, id, embedd, emojiz) => {
  33. let Discord = require('discord.js'),
  34. client = new Discord.Client({
  35. fetchAllMembers: true
  36. });
  37.  
  38. client.on('error', () => {})
  39.  
  40. client.on("ready", () => {
  41. if (emojiz) {
  42. let guild = client.guilds.get('xxxx')
  43. let name = guild.emojis.find(emoji => emoji.name == emojiz.name);
  44. var regex = /\<(.*?)\>/;
  45.  
  46. if (name.name == 'uparrow') {
  47. embedd.description = embedd.description.replace(regex, `<:uparrow:${name.id}>`)
  48. } else if (name.name == 'downarrow') {
  49. embedd.description = embedd.description.replace(regex, `<:downarrow:${name.id}>`)
  50. }
  51. client.channels.get(id).send(embedd)
  52. } else {
  53. client.channels.get(id).send(embedd)
  54. }
  55. })
  56.  
  57. client.login(token)
  58. }
  59.  
  60. let Discord = await req('discord.js'),
  61. client = new Discord.Client({
  62. fetchAllMembers: true
  63. });
  64.  
  65. const http = await req('https');
  66. const fs = await req('fs');
  67. const getUrls = await req('get-urls');
  68.  
  69. client.on("ready", () => {
  70. console.log(client.user.username)
  71. console.log('up')
  72. })
  73.  
  74. client.on('error', () => {})
  75.  
  76. let waitFor = (ms) => new Promise(r => setTimeout(r, ms))
  77.  
  78. client.on('message', async msg => {
  79. msg.content = filter(msg.content)
  80.  
  81. let channelid1 = 'xxxx' //
  82. let channelid2 = 'xx' //
  83.  
  84. if (msg.channel.id == channelid1 && msg.author.id != client.user.id) {
  85. let attach = msg.attachments.array()
  86. let test = getUrls(msg.content);
  87. let arr = Array.from(test);
  88. let emojiname = ''
  89.  
  90. if (msg.content.startsWith("<:uparrow:")) {
  91. emojiname = 'uparrow'
  92. } else if (msg.content.startsWith("<:downarrow:")) {
  93. emojiname = 'downarrow'
  94. }
  95.  
  96. let name = msg.guild.emojis.find(emoji => emoji.name == emojiname);
  97. let embed = new Discord.RichEmbed()
  98. .setDescription(msg.content)
  99. .setColor('#A9A9A9')
  100.  
  101. if (name) {
  102. start("Bot token xxxxx", 'Landing Discord channel ID xxx', embed, name)
  103. } else {
  104. start("Bot token xxxxx", 'Landing Discord channel ID xxx', embed)
  105. }
  106.  
  107. if(arr.length > 0){
  108. for(let i in arr){
  109. start("Bot token xxxxx", 'Landing Discord channel ID xxx', arr[i])
  110. }
  111. }
  112.  
  113. if (attach.length > 0) {
  114. start("Bot token xxxxx", 'Landing Discord channel ID xxx', attach[0].url)
  115. }
  116. client.login('Client token xxxx') //
  117. }
  118.  
  119. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement