Advertisement
codelyon

Untitled

Jan 30th, 2021
4,274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require('dotenv').config();
  2. const cod_api = require('call-of-duty-api')();
  3.  
  4. module.exports = {
  5.     name: 'mpcheck',
  6.     description: 'this command shows stats for call of duty multiplayer',
  7.     async execute(client, message, args, Discord){
  8.         if(!args[0]) return message.channel.send('Please enter a username');
  9.         if(!args[1]) return message.channel.send('Please enter a platfrom');
  10.  
  11.         //Getting username and password from the .env file. If you don't have or need a .env file just hard code your username and password.
  12.         let username = process.env.COD_USERNAME;
  13.         let password = process.env.COD_PASSWORD;
  14.  
  15.         try{
  16.             await cod_api.login(username, password);
  17.             //Getting data from CWmp (Cold War Multiplayer) make sure to check the docs if you wish to get data from other games.
  18.             let data = await cod_api.CWmp(args[0], args[1]);
  19.            
  20.             const embed = new Discord.MessageEmbed()
  21.             .setColor('#BFCDEB')
  22.             .setTitle('COD Multiplayer Stats')
  23.             .setDescription('Cod stats')
  24.             .addFields(
  25.                 { name: 'Games Played', value: data.lifetime.all.properties.totalGamesPlayed, inline: true},
  26.                 { name: 'Wins', value: data.lifetime.all.properties.wins, inline: true},
  27.                 { name: 'Losses', value: data.lifetime.all.properties.losses, inline: true},
  28.                 { name: 'KD Ratio', value: data.lifetime.all.properties.kdratio, inline: true},
  29.                 { name: 'Kills', value: data.lifetime.all.properties.kills, inline: true},
  30.                 { name: 'Deaths', value: data.lifetime.all.properties.deaths, inline: true},
  31.                 { name: 'Longest Kill Streak', value: data.lifetime.all.properties.longestKillstreak},
  32.                 {name: 'Total Time Played', value: (parseFloat(data.lifetime.all.properties.timePlayedTotal / 3600).toFixed(2)) + " Hours"}
  33.            
  34.             )
  35.             .setFooter('COD stats by Codelyon');
  36.  
  37.             message.channel.send(embed);
  38.  
  39.             //I left the console.log so you can see the reponse we are getting. You can delete this if you wish.
  40.             console.log(data.lifetime.all.properties);
  41.  
  42.         }catch(error){
  43.             message.channel.send('There was an error fetching this player');
  44.             throw error;
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement