- KenDayy#0001
- Katılım
- 26 Ağu 2021
- Mesajlar
- 247
- Tepkime puanı
- 124
- Şehir
- Yurtdışı
Kod Bana Aittir "Twitch Yayıncılarıyla Alakalı Bilgileri" Gösteren Bir Komuttur (İzinsiz Paylaşmayınız).
Kod Yapımcısı: Barış Özcan#0001
Diğer Modüller: Superagent
Kodlama Dili: Discord.js@v13 Sürümü "Slash Komuttur"
Kod Yapımcısı: Barış Özcan#0001
Diğer Modüller: Superagent
Kodlama Dili: Discord.js@v13 Sürümü "Slash Komuttur"
JavaScript:
const { CommandInteraction, MessageEmbed } = require("discord.js");
const superagent = require('superagent');
module.exports = {
name: "twitch",
description: "Twitch İstatistiklerini Gösterir",
options: [
{
name: "user",
description: "Bilgi alınacak kullanıcı",
type: "STRING",
required: true
}
],
/**
*
* @param {CommandInteraction} interaction
* @param {Client} client
*/
async execute(interaction) {
const { options, member, guild, channel } = interaction;
const channelName = options.getString("user");
if(!channelName)
return interaction.reply({content: "Lütfen bir Twitch kanal adı girin.", ephermeral: true});
try {
const Response = await superagent.get(`https://api.crunchprank.net/twitch/followcount/${channelName.toLowerCase()}`);
const upTime = await superagent.get(`https://api.crunchprank.net/twitch/uptime/${channelName.toLowerCase()}`);
const totalViews = await superagent.get(`https://api.crunchprank.net/twitch/total_views/${channelName.toLowerCase()}`);
const accountage = await superagent.get(`https://api.crunchprank.net/twitch/creation/${channelName.toLowerCase()}`);
const lastGame = await superagent.get(`https://api.crunchprank.net/twitch/game/${channelName.toLowerCase()}`);
const embed = new MessageEmbed()
.setColor("#0099ff")
.setTitle(`${channelName}'ın Twitch İstatistikleri`)
.setDescription(`❣️ **Takipçiler**: ${Response.text} \n👀 **Görüntüleme**: ${totalViews.text}\n ⬆ **Yayın süresi**: ${upTime.text} \n📝 **Oluşturulma Tarihi**: ${accountage.text} \n⏮️ **Son Oynadığı Oyun**: ${lastGame.text} \n🔴 **Yayın**: ${upTime.text}`)
.setFooter(`${member.user.tag} tarafından talep edildi`, member.user.displayAvatarURL())
.addField(`ㅤ`, `[**Destek**](https://discord.gg/invite-code)`)
.setURL(`https://twitch.tv/${channelName}`)
.setThumbnail("https://pngimg.com/uploads/twitch/twitch_PNG27.png")
.setTimestamp()
interaction.reply({embeds: [embed]});
if (upTime.text === `${channelName} çevrimdışı`) {
upTime.text = "Offline";
}
} catch (error) {
console.error(error);
return interaction.reply({content: "Twitch istatistikleri alınırken bir hata oluştu.", ephermeral: true});
}
}
}