Advertisement
samiroexpikachu

Crypto

Jun 12th, 2024
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const axios = require('axios');
  2. const fs = require('fs');
  3. const path = require('path');
  4.  
  5.  
  6. function toBoldFont(text) {
  7.   const boldMap = {
  8.     'a': '๐šŠ', 'b': '๐š‹', 'c': '๐šŒ', 'd': '๐š', 'e': '๐šŽ', 'f': '๐š', 'g': '๐š', 'h': '๐š‘',
  9.   'i': '๐š’', 'j': '๐š“', 'k': '๐š”', 'l': '๐š•', 'm': '๐š–', 'n': '๐š—', 'o': '๐š˜', 'p': '๐š™', 'q': '๐šš',
  10.   'r': '๐š›', 's': '๐šœ', 't': '๐š', 'u': '๐šž', 'v': '๐šŸ', 'w': '๐š ', 'x': '๐šก', 'y': '๐šข', 'z': '๐šฃ',
  11.   'A': '๐™ฐ', 'B': '๐™ฑ', 'C': '๐™ฒ', 'D': '๐™ณ', 'E': '๐™ด', 'F': '๐™ต', 'G': '๐™ถ', 'H': '๐™ท',
  12.   'I': '๐™ธ', 'J': '๐™น', 'K': '๐™บ', 'L': '๐™ป', 'M': '๐™ผ', 'N': '๐™ฝ', 'O': '๐™พ', 'P': '๐™ฟ', 'Q': '๐š€',
  13.   'R': '๐š', 'S': '๐š‚', 'T': '๐šƒ', 'U': '๐š„', 'V': '๐š…', 'W': '๐š†', 'X': '๐š‡', 'Y': '๐šˆ', 'Z': '๐š‰',
  14.     '0': '๐ŸŽ', '1': '๐Ÿ', '2': '๐Ÿ', '3': '๐Ÿ‘', '4': '๐Ÿ’', '5': '๐Ÿ“', '6': '๐Ÿ”', '7': '๐Ÿ•', '8': '๐Ÿ–', '9': '๐Ÿ—'
  15.   };
  16.   return text.split('').map(c => boldMap[c] || c).join('');
  17. }
  18.  
  19. module.exports = {
  20.   config: {
  21.     name: "crypto",
  22.     version: "1.0",
  23.     author: "Samir ล’",
  24.     aliases: ["cryptoinfo", "cryptocurrency"],
  25.     countDown: 5,
  26.     role: 0,
  27.     category: "Information",
  28.     guide: {
  29.       en: "{pn} <query>"
  30.     }
  31.   },
  32.  
  33.   onStart: async function ({ event, message, args }) {
  34.     const query = args.join(" ");
  35.     if (!query) {
  36.       return message.reply("Please provide a query for the cryptocurrency.");
  37.     }
  38.  
  39.     const apiUrl = `https://samirxpikachu.onrender.com/crypto?q=${encodeURIComponent(query)}`;
  40.     try {
  41.       const res = await axios.get(apiUrl);
  42.       const data = res.data;
  43.  
  44.       if (!data || !data.id) {
  45.         return message.reply("No data found for the provided query.");
  46.       }
  47.  
  48.       const cryptoInfo = `
  49. ${toBoldFont('Name')}: ${data.name} ๐Ÿช™
  50.  
  51. ${toBoldFont('ID')}: ${data.id}
  52.  
  53. ${toBoldFont('Symbol')}: ${data.symbol} ๐Ÿ’ฒ
  54.  
  55. ${toBoldFont('Rank')}: ${data.rank} ๐Ÿ†
  56.  
  57. ${toBoldFont('Price')}: $${data.quotes.USD.price.toFixed(2)} ๐Ÿ“ˆ
  58.  
  59. ${toBoldFont('Total Supply')}: ${data.total_supply} ๐Ÿ”ข
  60.  
  61. ${toBoldFont('Max Supply')}: ${data.max_supply} ๐Ÿ”„
  62.  
  63. ${toBoldFont('Market Cap')}: $${data.quotes.USD.market_cap.toLocaleString()} ๐Ÿ’ฐ
  64.  
  65. ${toBoldFont('First Data Date')}: ${new Date(data.first_data_at).toLocaleDateString()} ๐Ÿ“…
  66.  
  67. ${toBoldFont('Last Updated')}: ${new Date(data.last_updated).toLocaleString()} ๐Ÿ•’
  68.  
  69. ${toBoldFont('All-Time High Price')}: $${data.quotes.USD.ath_price.toFixed(2)} on ${new Date(data.quotes.USD.ath_date).toLocaleDateString()} ๐Ÿš€
  70.  
  71. ${toBoldFont('Change from ATH')}: ${data.quotes.USD.percent_from_price_ath.toFixed(2)}% ๐Ÿ“‰
  72. ${toBoldFont('Price Change (24h)')}: ${data.quotes.USD.percent_change_24h.toFixed(2)}% ๐Ÿ”„
  73. ${toBoldFont('Price Change (7d)')}: ${data.quotes.USD.percent_change_7d.toFixed(2)}% ๐Ÿ”„
  74. ${toBoldFont('Price Change (30d)')}: ${data.quotes.USD.percent_change_30d.toFixed(2)}% ๐Ÿ”„
  75. ${toBoldFont('Price Change (1y)')}: ${data.quotes.USD.percent_change_1y.toFixed(2)}% ๐Ÿ“ˆ
  76.  
  77. ${toBoldFont('Volume (24h)')}: $${data.quotes.USD.volume_24h.toLocaleString()} (${data.quotes.USD.volume_24h_change_24h.toFixed(2)}%) ๐Ÿ’ธ
  78.       `;
  79.  
  80.       const logoUrl = data.logoURL;
  81.       const logoPath = path.join(__dirname, 'cache', `${data.id}-logo.png`);
  82.       const logoResponse = await axios.get(logoUrl, { responseType: 'arraybuffer' });
  83.       await fs.promises.writeFile(logoPath, logoResponse.data);
  84.  
  85.       await message.reply({
  86.         body: cryptoInfo,
  87.         attachment: fs.createReadStream(logoPath)
  88.       });
  89.  
  90.       fs.unlinkSync(logoPath);
  91.     } catch (error) {
  92.       console.error("Error fetching cryptocurrency data:", error.message);
  93.       message.reply("not found maybe your currency ๐Ÿ’ฒ is lowly .");
  94.     }
  95.   }
  96. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement