{"size": 1108, "ext": "js", "max_stars_repo_path": "src/commands/levels/level.js", "max_stars_repo_name": "biswajitguha01/ghostybot", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/commands/levels/level.js", "max_issues_repo_name": "biswajitguha01/ghostybot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/commands/levels/level.js", "max_forks_repo_name": "biswajitguha01/ghostybot", "max_forks_repo_forks_event_min_datetime": "2021-07-19T15:35:33.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-19T15:35:33.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 30.7777777778, "max_line_length": 80, "alphanum_fraction": 0.6561371841}
const { getUserById, calculateUserXp } = require("../../utils/functions");

module.exports = {
  name: "level",
  description: "Get your current level",
  category: "levels",
  aliases: ["lvl", "rank"],
  async execute(bot, message, args) {
    const lang = await bot.getGuildLang(message.guild.id);
    const member = bot.findMember(message, args, true);

    if (member.user.bot) {
      return message.channel.send(lang.MEMBER.BOT_DATA);
    }

    const { user } = await getUserById(member.user.id, message.guild.id);

    const level = calculateUserXp(user.xp);
    const avatar = encodeURIComponent(member.user.displayAvatarURL());
    const isBoosting =
      member.premiumSinceTimestamp >= 1
        ? "&isBoosting=true"
        : "&isBoosting=false";

    const url = `https://vacefron.nl/api/rankcard?username=${encodeURIComponent(
      member.user.username
    )}&avatar=${avatar}&level=${level}&rank=${level}&currentxp=${
      user.xp
    }&nextlevelxp=${user.xp + 1200}&previouslevelxp=${
      user.xp
    }&custombg=2F3136&xpcolor=fff${isBoosting}`;

    message.channel.send(url);
  },
};
