gaber-elsayed

twitch profile (JS)

Aug 19th, 2021
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. var api = require("twitch-api-v5");
  2. const _ = require('lodash')
  3. var moment = require("moment")
  4.  
  5. //read the docs how to get the Twitch-CliendID: https://dev.twitch.tv/docs/v5
  6. api.clientID = "";
  7.  
  8. module.exports = {
  9. name: "twitch",
  10. usage: ["Checks the Twitch Profile also ```{prefix}ttv <twitch userr>```"],
  11. enabled: true,
  12. aliases: ["ttv"],
  13. category: "General",
  14. memberPermissions: [],
  15. botPermissions: [ "SEND_MESSAGES", "EMBED_LINKS" ],
  16. //Settings for command
  17. nsfw: false,
  18. ownerOnly: false,
  19. cooldown: 5000,
  20.  
  21. // Execute contains content for the command
  22. async execute(client, message, args, data){
  23. api.search.channels({ query: `${args[0]}`}, (err, res) => {
  24. if (err) {
  25. console.log(err);
  26. } else {
  27. let final = _.first(res.channels)
  28. console.log(final)
  29.  
  30. let broadcasterType = final.broadcaster_type
  31. if (broadcasterType === '') {
  32. broadcasterType = "None"
  33. } else if (broadcasterType === 'affiliate') {
  34. broadcasterType = "Affiliate"
  35. } else if (broadcasterType === 'partner') {
  36. broadcasterType = "Partner"
  37. }
  38.  
  39. let created = moment(final.created_at).format('DD-MM-YYYY')
  40. let lastLive = moment(final.updated_at).format('DD-MM-YYYY, HH:mm')
  41.  
  42. const twitchEmbed = new MessageEmbed()
  43. .setColor("#6441a5")
  44. .setAuthor(` │ ${final.display_name}`, client.user.displayAvatarURL())
  45. .setDescription(`${final.description}`)
  46. .addField('Latest Stream:', `${final.status}\fGame: \`${final.game}\``)
  47. .addField('Followers', final.followers.toLocaleString(), true)
  48. .addField('Views', final.views.toLocaleString(), true)
  49. .addField('Broadcaster Type', broadcasterType)
  50. .addField("Created On", created, true)
  51. .addField("Last Live", lastLive, true)
  52. .setThumbnail(final.logo)
  53. .setFooter(`Their URL: ${final.url}`)
  54.  
  55. return message.channel.send(twitchEmbed)
  56. }
  57. });
  58. }
  59. };
Advertisement
Add Comment
Please, Sign In to add comment