Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const axios = require('axios');
- const fs = require('fs');
- const path = require('path');
- function toBoldFont(text) {
- const boldMap = {
- 'a': '๐', 'b': '๐', 'c': '๐', 'd': '๐', 'e': '๐', 'f': '๐', 'g': '๐', 'h': '๐',
- 'i': '๐', 'j': '๐', 'k': '๐', 'l': '๐', 'm': '๐', 'n': '๐', 'o': '๐', 'p': '๐', 'q': '๐',
- 'r': '๐', 's': '๐', 't': '๐', 'u': '๐', 'v': '๐', 'w': '๐ ', 'x': '๐ก', 'y': '๐ข', 'z': '๐ฃ',
- 'A': '๐ฐ', 'B': '๐ฑ', 'C': '๐ฒ', 'D': '๐ณ', 'E': '๐ด', 'F': '๐ต', 'G': '๐ถ', 'H': '๐ท',
- 'I': '๐ธ', 'J': '๐น', 'K': '๐บ', 'L': '๐ป', 'M': '๐ผ', 'N': '๐ฝ', 'O': '๐พ', 'P': '๐ฟ', 'Q': '๐',
- 'R': '๐', 'S': '๐', 'T': '๐', 'U': '๐', 'V': '๐ ', 'W': '๐', 'X': '๐', 'Y': '๐', 'Z': '๐',
- '0': '๐', '1': '๐', '2': '๐', '3': '๐', '4': '๐', '5': '๐', '6': '๐', '7': '๐', '8': '๐', '9': '๐'
- };
- return text.split('').map(c => boldMap[c] || c).join('');
- }
- module.exports = {
- config: {
- name: "crypto",
- version: "1.0",
- author: "Samir ล",
- aliases: ["cryptoinfo", "cryptocurrency"],
- countDown: 5,
- role: 0,
- category: "Information",
- guide: {
- en: "{pn} <query>"
- }
- },
- onStart: async function ({ event, message, args }) {
- const query = args.join(" ");
- if (!query) {
- return message.reply("Please provide a query for the cryptocurrency.");
- }
- const apiUrl = `https://samirxpikachu.onrender.com/crypto?q=${encodeURIComponent(query)}`;
- try {
- const res = await axios.get(apiUrl);
- const data = res.data;
- if (!data || !data.id) {
- return message.reply("No data found for the provided query.");
- }
- const cryptoInfo = `
- ${toBoldFont('Name')}: ${data.name} ๐ช
- ${toBoldFont('ID')}: ${data.id}
- ${toBoldFont('Symbol')}: ${data.symbol} ๐ฒ
- ${toBoldFont('Rank')}: ${data.rank} ๐
- ${toBoldFont('Price')}: $${data.quotes.USD.price.toFixed(2)} ๐
- ${toBoldFont('Total Supply')}: ${data.total_supply} ๐ข
- ${toBoldFont('Max Supply')}: ${data.max_supply} ๐
- ${toBoldFont('Market Cap')}: $${data.quotes.USD.market_cap.toLocaleString()} ๐ฐ
- ${toBoldFont('First Data Date')}: ${new Date(data.first_data_at).toLocaleDateString()} ๐
- ${toBoldFont('Last Updated')}: ${new Date(data.last_updated).toLocaleString()} ๐
- ${toBoldFont('All-Time High Price')}: $${data.quotes.USD.ath_price.toFixed(2)} on ${new Date(data.quotes.USD.ath_date).toLocaleDateString()} ๐
- ${toBoldFont('Change from ATH')}: ${data.quotes.USD.percent_from_price_ath.toFixed(2)}% ๐
- ${toBoldFont('Price Change (24h)')}: ${data.quotes.USD.percent_change_24h.toFixed(2)}% ๐
- ${toBoldFont('Price Change (7d)')}: ${data.quotes.USD.percent_change_7d.toFixed(2)}% ๐
- ${toBoldFont('Price Change (30d)')}: ${data.quotes.USD.percent_change_30d.toFixed(2)}% ๐
- ${toBoldFont('Price Change (1y)')}: ${data.quotes.USD.percent_change_1y.toFixed(2)}% ๐
- ${toBoldFont('Volume (24h)')}: $${data.quotes.USD.volume_24h.toLocaleString()} (${data.quotes.USD.volume_24h_change_24h.toFixed(2)}%) ๐ธ
- `;
- const logoUrl = data.logoURL;
- const logoPath = path.join(__dirname, 'cache', `${data.id}-logo.png`);
- const logoResponse = await axios.get(logoUrl, { responseType: 'arraybuffer' });
- await fs.promises.writeFile(logoPath, logoResponse.data);
- await message.reply({
- body: cryptoInfo,
- attachment: fs.createReadStream(logoPath)
- });
- fs.unlinkSync(logoPath);
- } catch (error) {
- console.error("Error fetching cryptocurrency data:", error.message);
- message.reply("not found maybe your currency ๐ฒ is lowly .");
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement