Instalasi:
Langkah-langkah instalasi pemasangan plugin Anda bisa lihat di Dokumentasi
Penggunaan:
- Kirim pesan teks ke bot dengan format:
.country <negara>
const axios = require('axios');
const EMOJIS = {
loading: 'π',
success: 'β
',
error: 'β'
};
module.exports = async (sock, message, msg, sender) => {
if (msg && msg.toLowerCase().startsWith('.country')) {
const countryName = msg.split(' ').slice(1).join(' ').trim();
if (!countryName) {
await sock.sendMessage(sender, { text: 'Contoh: .country indonesia' }, { quoted: message });
return;
}
try {
await sock.sendMessage(sender, { react: { text: EMOJIS.loading, key: message.key } });
const { data } = await axios.get(`https://restcountries.com/v3.1/name/${countryName}`);
const country = data[0];
const { flag, name, capital, region, subregion, population, currencies, timezones, cca2, ccn3, cca3, cioc, maps } = country;
const currencyText = currencies
? Object.values(currencies)
.map(c => `${c.name} (${c.symbol})`)
.join(', ')
: 'N/A';
const responseText = `
*${flag} ${name.common} (${name.official})*
π *Capital:* ${capital?.[0] || 'N/A'}
π *Region:* ${region}
π *Subregion:* ${subregion}
π₯ *Population:* ${population.toLocaleString()}
π° *Currency:* ${currencyText}
π *Timezones:* ${timezones?.join(', ') || 'N/A'}
π€ *Codes:*
β’ CCA2: ${cca2}
β’ CCN3: ${ccn3}
β’ CCA3: ${cca3}
β’ CIOC: ${cioc}
πΊοΈ *Map:* Google Maps: ${maps.googleMaps}
`.trim();
await sock.sendMessage(sender, { text: responseText }, { quoted: message });
await sock.sendMessage(sender, { react: { text: EMOJIS.success, key: message.key } });
} catch (err) {
console.error('Country Error:', err.message);
await sock.sendMessage(sender, { react: { text: EMOJIS.error, key: message.key } });
}
}
};
Plugin tidak berkerja? Laporkan!