Hoş Geldin!

Bize kaydolduğunuzda, topluluğumuzun diğer üyeleriyle tartışabilir, paylaşımda bulunabilir ve özel mesajlaşabilirsiniz.

Kayıt Ol!
Hoş geldin! CS2 Adresim'e Cexany tarafından davet edildin. Lütfen buraya tıklayarak kayıt ol.

NicqsiZAccentNicqsiZAccent is verified member.

NicqsiZAccent
Moderatör
Üye
Mesajlar 14
Beğeni 16
Katılım
12 Mayıs 2025
NicqsiZAccentNicqsiZAccent is verified member.
Discord.js v14 için Deprem Komutu

JavaScript:
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));

module.exports = {
  data: new SlashCommandBuilder()
    .setName('deprem')
    .setDescription('Türkiye’deki anlık deprem bilgilerini gösterir.'),

  async execute(interaction) {
    await interaction.deferReply();

    try {
      const response = await fetch('https://api.orhanaydogdu.com.tr/deprem/kandilli/live');
      const data = await response.json();

      const earthquakes = data.result;

      if (!earthquakes || !Array.isArray(earthquakes) || earthquakes.length === 0) {
        return interaction.editReply('<a:cs2adresimunlem:1354768406414360576> **veriler şu anda alınamıyor, daha sonra tekrar deneyin!**');
      }

      const lastFive = earthquakes.slice(0, 5)
  .map(eq => {
    const timestamp = Math.floor(new Date(eq.date).getTime() / 1000);
    return `<t:${timestamp}:t> [**${eq.title}**](https://alkan.web.tr) <a:cs2adresimalert:1376289980128690196> ${eq.mag}`;
  })
  .join('\n');

      const cityCounts = {};
      earthquakes.forEach(eq => {
        const city = eq.title.split('-')[0].trim() || '<a:cs2adresimno:1354539985658708184> Bilinmiyor.';
        cityCounts[city] = (cityCounts[city] || 0) + 1;
      });
      const topCities = Object.entries(cityCounts)
        .sort((a, b) => b[1] - a[1])
        .slice(0, 5)
        .map(([city, count]) => `- ${city} (**${count}**)`)
        .join('\n');

      const regionMap = {
        ':evergreen_tree:  Akdeniz': ['Antalya', 'Adana', 'Mersin', 'Hatay', 'Osmaniye', 'Kahramanmaraş'],
        '☀️ Ege': ['İzmir', 'Aydın', 'Muğla', 'Manisa', 'Denizli'],
        '🌊 Karadeniz': ['Samsun', 'Trabzon', 'Ordu', 'Giresun', 'Rize'],
        '🏢 Marmara': ['İstanbul', 'Bursa', 'Kocaeli', 'Sakarya', 'Tekirdağ'],
        '🏔️ Doğu Anadolu': ['Elazığ', 'Malatya', 'Erzurum', 'Van', 'Bingöl'],
        '🥜 İç Anadolu': ['Ankara', 'Konya', 'Kayseri', 'Eskişehir', 'Sivas'],
        '💡 Güneydoğu Anadolu': ['Diyarbakır', 'Şanlıurfa', 'Gaziantep', 'Mardin', 'Batman']
      };

      const regionCounts = {};
      for (const eq of earthquakes) {
  let matched = false;

  for (const region of Object.keys(regionMap)) {
    if (eq.title.toLowerCase().includes(region.toLowerCase())) {
      regionCounts[region] = (regionCounts[region] || 0) + 1;
      matched = true;
      break;
    }
  }

  if (!matched) {
    for (const [region, cities] of Object.entries(regionMap)) {
      if (cities.some(c => eq.title.toLowerCase().includes(c.toLowerCase()))) {
        regionCounts[region] = (regionCounts[region] || 0) + 1;
        matched = true;
        break;
      }
    }
  }

  if (!matched) {
    regionCounts['<a:cs2adresimno:1354539985658708184> Bilinmiyor.'] = (regionCounts['<a:cs2adresimno:1354539985658708184> Bilinmiyor.'] || 0) + 1;
  }
}

      const topRegions = Object.entries(regionCounts)
        .sort((a, b) => b[1] - a[1])
        .slice(0, 5)
        .map(([region, count]) => `- ${region} (**${count}**)`)
        .join('\n');

      const now = new Date();
      const periods = [
  { label: 'Tüm Gelen Veri', ms: Infinity },
  { label: 'Son 7 Gün', ms: 7 * 24 * 60 * 60 * 1000 },
  { label: 'Son 24 Saat', ms: 24 * 60 * 60 * 1000 }
];

      const stats = periods.map(p => {
  const count = earthquakes.filter(eq => {
    const eqTime = new Date(eq.date);
    return (now - eqTime) <= p.ms;
  }).length;
  return `- ${p.label}: (**${count})**`;
}).join('\n');

      const description = `
<a:cs2adresimflag:1376290793509097592> Türkiye'de ki Son 5 Deprem
${lastFive || '<a:cs2adresimno:1354539985658708184> Veri **yok.**'}
<a:cs2adresimmap:1354182018606563378> En Çok Deprem Olan Şehirler
${topCities || '<a:cs2adresimno:1354539985658708184> Veri **yok.**'}
<a:cs2adresimkonum:1376291777224511498> En Çok Deprem Olan Bölgeler
${topRegions || '<a:cs2adresimno:1354539985658708184> Veri **yok.**'}
<a:cs2adresimstat:1354183136938037338> Deprem İstatistikleri
${stats || '<a:cs2adresimno:1354539985658708184> Veri **yok.**'}
      `;

      const embed = new EmbedBuilder()
        .setColor(660000)
        .setDescription(description.trim())
        .setThumbnail("https://media.discordapp.net/attachments/1069639498637525043/1375838158603943948/2270-flagmap-tr.png?ex=68347622&is=683324a2&hm=1534103ac2148d98da60318140ff95ad944512f2d80dc9131e4cef660000e2ee&format=webp&quality=lossless&width=168&height=72&");

      await interaction.editReply({ embeds: [embed] });

    } catch (error) {
      console.error(error);
      await interaction.editReply('<a:cs2adresimunlem:1354768406414360576> **İstatistikler alınırken hata oluştu!**');
    }
  },
};
 
Moderatör tarafında düzenlendi:
Geri
Üst
✖

Dear User!

We found that you are blocking the display of ads on our site.

Please add it to the exception list or disable AdBlock.

Our materials are provided for FREE and the only revenue is advertising.

Thank you for understanding!

Sitemiz bir forum sitesi olduğu için kullanıcılar her türlü görüşlerini önceden onay olmadan anında siteye yazabilmektedir. 5651 sayılı yasaya göre bu yazılardan dolayı doğabilecek her türlü sorumluluk yazan kullanıcılara aittir. 5651 sayılı yasaya göre sitemiz mesajları kontrolle yükümlü olmayıp, yasaya aykırı yada telif hakkı içeren paylaşımlar BURADAN bize ulaşıldığı taktirde, ilgili konu en geç 48 saat içerisinde kaldırılacaktır. Sitemizde Bulunan Videolar YouTube, Facebook, Dailymotion, v.b. video paylaşım sitelerinden alınmaktadır. Telif hakları sorumluluğu bu sitelere aittir. Videoların hiç biri sunucularımızda bulunmamaktadır.