text: const config = require("../config.js")
  const logger = require("../modules/Logger.js");
  const Twit = require('twit')
  const { time } = require('@discordjs/builders');
  
  var T = new Twit({
    consumer_key: process.env.TWIT_CONSUMER_KEY,
    consumer_secret: process.env.TWI_CONSUMER_SECRET,
    access_token: process.env.TWIT_ACCESS_TOKEN,
    access_token_secret: process.env.TWIT_ACCESS_TOKEN_SECRET,
    timeout_ms: 60 * 1000,
    strictSSL: true,
  })
  
  module.exports = async (client) => {
    const usersCount = client.guilds.cache.filter(g => g.id === config.bot.guilds.ngblue).map(g => g.memberCount)
  
    logger.log(`${client.user.tag}, ready to serve ${usersCount} users.`, "ready");
  
    let activities = [`/help | `, config.bot.discord], i = 0;
  
    client.user.setPresence({
      status: "online",
      activities:
        [{
          name: `${usersCount} users`,
          type: 'COMPETING',
        }]
    })
  
    await client.channels.fetch(config.channels.cmd.croux)
      .then(c => {
        c.send("**✅ | BOT ON !**")
      })
  
    await client.channels.fetch(config.channels.log.status)
      .then(c => {
        const embed = {
          color: config.embed.color,
          title: "✅ | BOT ON !",
          description: time(new Date(), 'R'),
          timestamp: new Date(),
        };
  
        c.send({ embeds: [embed] })
      })
  
    var stream = T.stream('statuses/filter', { follow: [process.env.TWIT_USER_ID] })
  
    stream.on('tweet', function (tweet) {
      if (tweet.user.id == process.env.TWIT_USER_ID) {
        var url = "https://twitter.com/" + tweet.user.screen_name + "/status/" + tweet.id_str;
        try {
          client.channels.fetch(config.channels.twitter)
            .then(c => {
              c.send("**<a:DINGGG:780468268707086366> Hey, @Twitter NationsGlory a tweeté:** " + url)
            }).catch(err => {
              console.log(err)
            })
        } catch (error) {
          console.error(error);
        }
      }
    })
  };
  