2021年3月22日星期一

Discord.js random message after x amount of time (Code Correction)

I need to have my discord bot send a random message every 1.5 hours (1 second here for testing) and so far I used the following code but it did not work:

  'use strict';      const { Client, MessageEmbed } = require('discord.js');      const client = new Client();        client.on('ready', () => {    console.log(`Logged in to Discord succesfully as ${client.user.tag}!`);  });        var facts = ['Zebra', 'Elephant', 'Goose', 'Lion', 'Turtle', 'Mongoose']    setInterval(function() {    var fact = Math.floor(Math.random() * facts.length)    console.log(facts[fact])     }, 1000) // Changed to 1s for testing      client.on('message', message => {      if (message.content != '101') {      message.channel.send(facts[fact]);    }  });    client.login(process.env.DISCORD_TOKEN);  

I really would appreciate it if you helped me out and sorry because I am just a beginner to node.js, e.t.c.

Sorry if this is a duplicate but I needed urgent help. Thanks!

https://stackoverflow.com/questions/66756297/discord-js-random-message-after-x-amount-of-time-code-correction March 23, 2021 at 10:08AM

没有评论:

发表评论