Advertisement
BETAlwrd

Untitled

Jun 28th, 2025
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { AttachmentBuilder } = require('discord.js');
  2. const getProfile = require('../../managers/getProfile');
  3. const path = require('path');
  4. const fs = require('fs');
  5.  
  6. module.exports = {
  7.   name: 'nitro',
  8.   aliases: ['n', 'nitr', 'mynitro'],
  9.   description: 'Show Nitro subscription info',
  10.   async execute(message) {
  11.     const user = message.mentions.users.first() || message.author;
  12.     if (user.bot)
  13.       return message.reply({ content: 'Bots cannot have Nitro!', ephemeral: true });
  14.  
  15.     const profile = await getProfile(user.id);
  16.     if (!profile || !profile.premium_since)
  17.       return message.reply({ content: 'No Nitro subscription found.', ephemeral: true });
  18.  
  19.     const since = new Date(profile.premium_since);
  20.     const now = Date.now();
  21.  
  22.     const levels = [
  23.       { name: 'Normal', months: 0, file: 'beta-10.png' },
  24.       { name: 'Bronze', months: 1, file: 'beta-11.png' },
  25.       { name: 'Silver', months: 3, file: 'beta-12.png' },
  26.       { name: 'Gold', months: 6, file: 'beta-13.png' },
  27.       { name: 'Platinum', months: 12, file: 'beta-14.png' },
  28.       { name: 'Diamond', months: 24, file: 'beta-15.png' },
  29.       { name: 'Emerald', months: 36, file: 'beta-16.png' },
  30.       { name: 'Ruby', months: 60, file: 'beta-17.png' },
  31.       { name: 'Opal', months: 72, file: 'beta-18.png' },
  32.     ];
  33.  
  34.     const nextIndex = levels.findIndex(l =>
  35.       since.getTime() + l.months * 30 * 24 * 60 * 60 * 1000 > now
  36.     );
  37.     const isMax = nextIndex === -1;
  38.     const currentIndex = isMax ? levels.length - 1 : Math.max(0, nextIndex - 1);
  39.     const nextLevel = isMax ? null : levels[nextIndex];
  40.  
  41.     const currentLevel = levels[currentIndex];
  42.     const cbadge = message.guild.emojis.cache.find(e =>
  43.       currentLevel.months === 0
  44.         ? e.name === 'premium'
  45.         : e.name === `premium_tenure_${currentLevel.months}_month_v2`
  46.     );
  47.     const nbadge = nextLevel && message.guild.emojis.cache.find(e =>
  48.       e.name === `premium_tenure_${nextLevel.months}_month_v2`
  49.     );
  50.  
  51.     const relSince = Math.floor(since.getTime() / 1000);
  52.     let desc = `${
  53.       user.id === message.author.id ? 'You started' : `${profile.user.username} started`
  54.     } Nitro <t:${relSince}:R> (Tier: ${currentLevel.name})`;
  55.     if (!isMax && nextLevel) {
  56.       const nextTs = Math.floor(
  57.         since.getTime() + nextLevel.months * 30 * 24 * 60 * 60 * 1000
  58.       ) / 1000;
  59.       desc += `\nNext: ${nextLevel.name} ${nbadge} in <t:${Math.floor(nextTs)}:R>`;
  60.     } else {
  61.       desc += ' (Max tier)';
  62.     }
  63.  
  64.     const imageFile = currentLevel.file;
  65.     const imagePath = path.resolve(__dirname, '../../images', imageFile);
  66.     if (!fs.existsSync(imagePath)) console.error('Missing image:', imagePath);
  67.     const attachment = new AttachmentBuilder(imagePath, { name: imageFile });
  68.  
  69.     return message.reply({
  70.       content: `${cbadge || ''} ${currentLevel.name}${isMax ? ' (Max)' : ''} ${cbadge || ''}`,
  71.       embeds: [
  72.         {
  73.           title: profile.user.global_name || profile.user.username,
  74.           description: desc,
  75.           color: process.env.color,
  76.           image: { url: `attachment://${imageFile}` },
  77.           timestamp: new Date().toISOString(),
  78.           footer: {
  79.             text: message.guild.name,
  80.             icon_url: message.guild.iconURL(),
  81.           },
  82.         },
  83.       ],
  84.       files: [attachment],
  85.     });
  86.   },
  87. };
  88.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement