Discord v12 Hava Durumu Gösteren Kod

Katılım
4 Nis 2023
Konular
1
Mesajlar
4
Tepki puanı
0
Puanları
705
const Discord = require('discord.js');
const weather = require('weather-js'); // weather-js kütüphanesini kullanmak için

exports.run = (client, message, args) => {
// Komutun kullanımını kontrol et
if (!args[0]) {
return message.channel.send('Lütfen bir şehir adı belirtin.');
}

// weather-js ile hava durumu bilgisini al
weather.find({ search: args.join(' '), degreeType: 'C' }, function (error, result) {
if (error) {
return message.channel.send('Hava durumu bilgileri alınamadı.');
}

// Hava durumu bilgilerini mesaj olarak gönder
const current = result[0].current;
const location = result[0].location;

const weatherEmbed = new Discord.MessageEmbed()
.setTitle(`Hava Durumu: ${location.name}`)
.setDescription(`${current.skytext}`)
.addField('Sıcaklık', `${current.temperature} °C`, true)
.addField('Hissedilen Sıcaklık', `${current.feelslike} °C`, true)
.addField('Rüzgar', `${current.winddisplay}`, true)
.addField('Nem', `${current.humidity}%`, true)
.setThumbnail(current.imageUrl);

message.channel.send(weatherEmbed);
});
};

exports.conf = {
aliases: ['havadurumu', 'hava'],
permLevel: 0,
kategori: 'Genel',
};

exports.help = {
name: 'havadurumu',
description: 'Belirtilen şehirin hava durumunu gösterir.',
usage: 'havadurumu <şehir>',
};
 
Katılım
31 Eki 2023
Konular
0
Mesajlar
1
Tepki puanı
0
Puanları
55
apisiz bir kod daha iyi olabilirdi ama yinede teşekkürler
 
Katılım
9 Şub 2021
Konular
32
Mesajlar
40
Tepki puanı
32
Puanları
2,610
const Discord = require('discord.js');
const weather = require('weather-js'); // weather-js kütüphanesini kullanmak için

exports.run = (client, message, args) => {
// Komutun kullanımını kontrol et
if (!args[0]) {
return message.channel.send('Lütfen bir şehir adı belirtin.');
}

// weather-js ile hava durumu bilgisini al
weather.find({ search: args.join(' '), degreeType: 'C' }, function (error, result) {
if (error) {
return message.channel.send('Hava durumu bilgileri alınamadı.');
}

// Hava durumu bilgilerini mesaj olarak gönder
const current = result[0].current;
const location = result[0].location;

const weatherEmbed = new Discord.MessageEmbed()
.setTitle(`Hava Durumu: ${location.name}`)
.setDescription(`${current.skytext}`)
.addField('Sıcaklık', `${current.temperature} °C`, true)
.addField('Hissedilen Sıcaklık', `${current.feelslike} °C`, true)
.addField('Rüzgar', `${current.winddisplay}`, true)
.addField('Nem', `${current.humidity}%`, true)
.setThumbnail(current.imageUrl);

message.channel.send(weatherEmbed);
});
};

exports.conf = {
aliases: ['havadurumu', 'hava'],
permLevel: 0,
kategori: 'Genel',
};

exports.help = {
name: 'havadurumu',
description: 'Belirtilen şehirin hava durumunu gösterir.',
usage: 'havadurumu <şehir>',
};

https://codeshare.me ile daha fazla kişiye bu kodu ulaştıra bilirsiniz. :)