xixi52/discord-canvas

403 Error

dylanjamesdev opened this issue · 1 comments

Hi There! I love the node module, I've been using it for a while but I'm curious to see why the server is responding with a 403? Nothing has changed for the code.

0|clusters  | [Unhandled Rejection] Error: Server responded with 403
0|clusters  |     at /root/tritan-bot/node_modules/canvas/lib/image.js:56:28
0|clusters  |     at /root/tritan-bot/node_modules/simple-get/index.js:89:7
0|clusters  |     at PassThrough.<anonymous> (/root/tritan-bot/node_modules/simple-concat/index.js:8:13)
0|clusters  |     at Object.onceWrapper (events.js:421:28)
0|clusters  |     at PassThrough.emit (events.js:315:20)
0|clusters  |     at PassThrough.EventEmitter.emit (domain.js:467:12)
0|clusters  |     at endReadableNT (internal/streams/readable.js:1327:12)
0|clusters  |     at processTicksAndRejections (internal/process/task_queues.js:80:21)

Command:

const Canvas = require("discord-canvas");
const Discord = require("discord.js");
const Levels = require("discord-xp");
module.exports = {
  name: "rank",
  description: "View your rank card",
  aliases: ["me", "level", "xp"],
  async execute(message, args) {
    const target = message.mentions.users.first() || message.author;
    const user = await Levels.fetch(target.id, message.guild.id, true);

    if (!user) return message.channel.send("Seems like this user has not earned any xp so far.");

    const plusone = user.level + 1;
    const nextlevel = Levels.xpFor(plusone);
    const percent = Math.round((user.xp / nextlevel) * 100);

    let image = await new Canvas.RankCard()
      .setAvatar(target.displayAvatarURL({ format: "jpg" }))
      .setXP("current", user.xp)
      .setXP("needed", nextlevel)
      .setLevel(user.level)
      .setRank(user.position)
      .setReputation(user.xp)
      .setRankName(message.guild.name)
      .setUsername(target.tag)
      .setBadge(1, "gold")
      .setBadge(2, "diamond")
      .setBadge(3, "silver")
      .setBadge(4, "bronze")
      .setBackground(
        "https://free4kwallpapers.com/uploads/wallpaper/blurple-nebula-wallpaper-1024x768-wallpaper.jpg"
      )
      .toAttachment();

    let attachment = new Discord.MessageAttachment(image.toBuffer(), "rank-card.png");
    message.channel.send(attachment);
  }
};

Did you find a solution?