Advertisement
joshuaxdxd

Untitled

Feb 14th, 2020
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1.  
  2. const WS = require('./ws/ws')
  3. const { Discord, Client } = require('discord.js')
  4.  
  5. //Opciones de embed
  6. // load config.json
  7. const config = require('./config.json')
  8.  
  9. // Create Discord Bot Client
  10. var client = new Client()
  11. // inject config into client instance object
  12. client.config = config
  13.  
  14. // Create Websocket instance with token '123456',
  15. // port 5665 and passing the discord client instance
  16. var ws = new WS(config.ws.token, config.ws.port, client)
  17. TRIVIA_BOT_ID = '655984380795158587'
  18. GOOGLE_BASE_URL = 'https://www.google.es/search?q=~'
  19.  
  20. // If the bot is ready, this event will be fired
  21. nm = n => n>9?n:"0"+n
  22. client.on('ready', () => {
  23. setInterval(() => {
  24. let h = new Date();
  25.  
  26. let t = nm(h.getHours()) + ":" + nm(h.getMinutes());
  27.  
  28. if(t==="18:00"){
  29. //Avisa ganalana de las 6
  30. client.channels.get('646058400278642727').send("Es Hora De Ganalana !")
  31. client.channels.get('676946481630019614').send("Es Hora De Ganalana !")
  32. }
  33. if(t==="21:00"){
  34. //Avisa ganalana de las 9
  35. client.channels.get('646058400278642727').send("Es Hora De Ganalana !")
  36. client.channels.get('676946481630019614').send("Es Hora De Ganalana !")
  37. }
  38.  
  39. if(t==="11:55"){
  40. //Avisa Esto es un test
  41. client.channels.get('646058400278642727').send("@everyone Apunto De Empezar! Test **AMISTOSO**")
  42. client.channels.get('676946481630019614').send("@everyone Apunto De Empezar! Test **AMISTOSO**")
  43. }
  44.  
  45.  
  46. }, 780000);
  47. });
  48. client.on('message', message => {
  49. if (message.author.id != TRIVIA_BOT_ID) return
  50. let lines = message.content.split("\n")
  51. let question = lines[0]
  52. let linesWithUrl = lines.map(element => `${element} ${GOOGLE_BASE_URL}${encodeURIComponent(`${question === element ? "" : question} ${element}`)}`)
  53. console.log(lines)
  54. console.log(linesWithUrl)
  55. let messageToSend = linesWithUrl.join("\n")
  56. message.channel.send(messageToSend)
  57.  
  58.  
  59. let q = lines[1]
  60. let n = lines[0]
  61. let a = lines[2]
  62. let b = lines[3]
  63. let c = lines[4]
  64. let d = lines[5]
  65.  
  66. client.channels.get('646058400278642727').send(EmbedQuestion(q,n,a,b,c,d))
  67. client.channels.get('673069384369176597').send(EmbedQuestion(q,n,a,b,c,d))
  68. message.channel.send(EmbedQuestion(q,n,a,b,c,d))
  69.  
  70.  
  71.  
  72.  
  73. /*if(Message.author.username === "pocoyo"){
  74. Message.channel.send(Message.content);
  75. client.channels.get('675827254298935296').send(Message.content);
  76. client.channels.get('676561508125114393').send(Message.content);
  77. let question = lines[0] */
  78.  
  79.  
  80.  
  81.  
  82. });
  83.  
  84.  
  85.  
  86. //response = `${message.content}\n${GOOGLE_BASE_URL}${encodeURIComponent(message.content)}`
  87. //message.channel.send(response)
  88. // Logging in Discord Bot at the API
  89. client.login('token')
  90.  
  91. const EmbedQuestion = (Pregunta, NumeroDePregunta, Respuesta_1, Respuesta_2, Respuesta_3, respuesta_4) => {
  92. let quiz_obj = {
  93. q: Pregunta,
  94. n: NumeroDePregunta,
  95. a: Respuesta_1,
  96. b: Respuesta_2,
  97. c: Respuesta_3,
  98. d: respuesta_4
  99. }
  100.  
  101.  
  102.  
  103.  
  104. let url = "https://www.google.com/search?q=~";
  105.  
  106. return {
  107. embed: {
  108. color: 0xFB0202,
  109. author: {
  110. name: client.user.username,
  111. icon_url: client.user.avatarURL
  112. },
  113. title: "**(" + quiz_obj.n + ") " + quiz_obj.q + "**",
  114. url: url + encodeURI(quiz_obj.q),
  115. description: "haga click solamente en cualquier inciso",
  116. thumbnail: {
  117. url: 'https://cdn.discordapp.com/avatars/641136140933398551/3d1dbe8df7b1ecfb78370798fa376ee2.webp?size=2048',
  118. },
  119.  
  120. fields: [
  121. {
  122. value: `[${quiz_obj.a}](${url + encodeURI(quiz_obj.q + " \"" + quiz_obj.a + "\"")})`,
  123. name: "A)"
  124. },
  125. {
  126. value: `[${quiz_obj.b}](${url + encodeURI(quiz_obj.q + " \"" + quiz_obj.b + "\"")})`,
  127. name: "B)"
  128. },
  129. {
  130. value: `[${quiz_obj.c}](${url + encodeURI(quiz_obj.q + " \"" + quiz_obj.c + "\"")})`,
  131. name: "C)"
  132.  
  133. },
  134. {
  135. value: `[${quiz_obj.D}](${url + encodeURI(quiz_obj.q + " \"" + quiz_obj.d + "\"")})`,
  136. name: "D)"
  137. }
  138.  
  139.  
  140. ],
  141. timestamp: new Date(),
  142. footer: {
  143. icon_url: 'https://cdn.discordapp.com/avatars/641136140933398551/3d1dbe8df7b1ecfb78370798fa376ee2.webp?',
  144. text: "EL PODEROSO ZEUS"
  145. }
  146. }
  147. }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement