Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const WS = require('./ws/ws')
- const { Discord, Client } = require('discord.js')
- //Opciones de embed
- // load config.json
- const config = require('./config.json')
- // Create Discord Bot Client
- var client = new Client()
- // inject config into client instance object
- client.config = config
- // Create Websocket instance with token '123456',
- // port 5665 and passing the discord client instance
- var ws = new WS(config.ws.token, config.ws.port, client)
- TRIVIA_BOT_ID = '655984380795158587'
- GOOGLE_BASE_URL = 'https://www.google.es/search?q=~'
- // If the bot is ready, this event will be fired
- nm = n => n>9?n:"0"+n
- client.on('ready', () => {
- setInterval(() => {
- let h = new Date();
- let t = nm(h.getHours()) + ":" + nm(h.getMinutes());
- if(t==="18:00"){
- //Avisa ganalana de las 6
- client.channels.get('646058400278642727').send("Es Hora De Ganalana !")
- client.channels.get('676946481630019614').send("Es Hora De Ganalana !")
- }
- if(t==="21:00"){
- //Avisa ganalana de las 9
- client.channels.get('646058400278642727').send("Es Hora De Ganalana !")
- client.channels.get('676946481630019614').send("Es Hora De Ganalana !")
- }
- if(t==="11:55"){
- //Avisa Esto es un test
- client.channels.get('646058400278642727').send("@everyone Apunto De Empezar! Test **AMISTOSO**")
- client.channels.get('676946481630019614').send("@everyone Apunto De Empezar! Test **AMISTOSO**")
- }
- }, 780000);
- });
- client.on('message', message => {
- if (message.author.id != TRIVIA_BOT_ID) return
- let lines = message.content.split("\n")
- let question = lines[0]
- let linesWithUrl = lines.map(element => `${element} ${GOOGLE_BASE_URL}${encodeURIComponent(`${question === element ? "" : question} ${element}`)}`)
- console.log(lines)
- console.log(linesWithUrl)
- let messageToSend = linesWithUrl.join("\n")
- message.channel.send(messageToSend)
- let q = lines[1]
- let n = lines[0]
- let a = lines[2]
- let b = lines[3]
- let c = lines[4]
- let d = lines[5]
- client.channels.get('646058400278642727').send(EmbedQuestion(q,n,a,b,c,d))
- client.channels.get('673069384369176597').send(EmbedQuestion(q,n,a,b,c,d))
- message.channel.send(EmbedQuestion(q,n,a,b,c,d))
- /*if(Message.author.username === "pocoyo"){
- Message.channel.send(Message.content);
- client.channels.get('675827254298935296').send(Message.content);
- client.channels.get('676561508125114393').send(Message.content);
- let question = lines[0] */
- });
- //response = `${message.content}\n${GOOGLE_BASE_URL}${encodeURIComponent(message.content)}`
- //message.channel.send(response)
- // Logging in Discord Bot at the API
- client.login('token')
- const EmbedQuestion = (Pregunta, NumeroDePregunta, Respuesta_1, Respuesta_2, Respuesta_3, respuesta_4) => {
- let quiz_obj = {
- q: Pregunta,
- n: NumeroDePregunta,
- a: Respuesta_1,
- b: Respuesta_2,
- c: Respuesta_3,
- d: respuesta_4
- }
- let url = "https://www.google.com/search?q=~";
- return {
- embed: {
- color: 0xFB0202,
- author: {
- name: client.user.username,
- icon_url: client.user.avatarURL
- },
- title: "**(" + quiz_obj.n + ") " + quiz_obj.q + "**",
- url: url + encodeURI(quiz_obj.q),
- description: "haga click solamente en cualquier inciso",
- thumbnail: {
- url: 'https://cdn.discordapp.com/avatars/641136140933398551/3d1dbe8df7b1ecfb78370798fa376ee2.webp?size=2048',
- },
- fields: [
- {
- value: `[${quiz_obj.a}](${url + encodeURI(quiz_obj.q + " \"" + quiz_obj.a + "\"")})`,
- name: "A)"
- },
- {
- value: `[${quiz_obj.b}](${url + encodeURI(quiz_obj.q + " \"" + quiz_obj.b + "\"")})`,
- name: "B)"
- },
- {
- value: `[${quiz_obj.c}](${url + encodeURI(quiz_obj.q + " \"" + quiz_obj.c + "\"")})`,
- name: "C)"
- },
- {
- value: `[${quiz_obj.D}](${url + encodeURI(quiz_obj.q + " \"" + quiz_obj.d + "\"")})`,
- name: "D)"
- }
- ],
- timestamp: new Date(),
- footer: {
- icon_url: 'https://cdn.discordapp.com/avatars/641136140933398551/3d1dbe8df7b1ecfb78370798fa376ee2.webp?',
- text: "EL PODEROSO ZEUS"
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement