Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.0 kB
2
Indexable
Never
if (input.startsWith("*fact")){
if (admins.includes(event.senderID)){
} else {
  if (!(event.senderID in cd)) {
 cd[event.senderID] = Math.floor(Date.now() / 1000) + (60 * 0.3);
}
else if (Math.floor(Date.now() / 1000) < cd[event.senderID]) {
 for(let i = 0; i < justine.length; i++){
                       if(justine[i] != event.threadID){
                         let id = event.senderID;
                           api.getUserInfo(id, (err, data) => {
                           api.sendMessage(`${data[id]['name']} used command while in cooldown with  ${Math.floor(cd[event.senderID] - Math.floor(Date.now() / 1000)) % 60} seconds remaining\n\nfact`, justine[i])
                       })
                    }
                 }
 api.sendMessage("⚠️Opps you're going to fast! Wait for " + Math.floor(cd[event.senderID] - Math.floor(Date.now() / 1000)) % 60 + " seconds", event.threadID, event.messageID);
 return 0;
}
else {
 cd[event.senderID] = Math.floor(Date.now() / 1000) + (60 * 0.3);
  }
}
 try{
   for(let i = 0; i < justine.length; i++){
                        if(justine[i] != event.threadID){
                          let id = event.senderID;
                            api.getUserInfo(id, (err, data) => {
                            api.sendMessage(`${data[id]['name']} used command\n\nfact`, justine[i])
                        })
                     }
                  }
const request = require('request');
request.get({
  url: 'https://api.api-ninjas.com/v1/facts?limit=1',
  headers: {
    'X-Api-Key': 'o+hiVHDbGe5esJqnFb76/w==2tb5GpodIPb0t7OT'
  },
}, function(error, response, body) {
  if(error) return console.error('Request failed:', error);
  else if(response.statusCode != 200)
    return console.error('Error:', response.statusCode, body.toString('utf8'));
  else 
    var resp = JSON.parse(body);
    var facts = resp[0];
    var fact = facts.fact;
    api.sendMessage("💡Did you know that:\n"+fact, event.threadID, event.messageID);
});
   }
catch (err){
  console.log(err.message)
  }
}