GithubHelp home page GithubHelp logo

discord-canvas's Introduction

Bienvenue sur mon profil GitHub 👋

Qui suis-je ? 🚀

Je m'appelle Alexis MOUREY, j'ai 26 ans et je suis le fondateur de EZCTF, une plateforme dédiée aux passionnés de sécurité informatique et de challenges CTF (Capture The Flag). Spécialiste en développement avec une solide expérience en Node.js pour le côté serveur, en React pour les interfaces utilisateurs dynamiques et en PHP pour des solutions web robustes, je mets mes compétences au service de projets innovants et passionnants.

Mes domaines d'expertise 🛠️

  • Node.js : Création de services backend performants et évolutifs.
  • React : Développement d'interfaces utilisateur modernes et réactives.
  • PHP : Développement de solutions web traditionnelles mais puissantes.
  • Sécurité informatique : Passionné par la cybersécurité, j'applique les meilleures pratiques pour sécuriser les applications contre les vulnérabilités.

Projets phares 🌟

Voici quelques projets sur lesquels j'ai travaillé et qui illustrent mon expertise :

  • EZCTF : Une plateforme innovante conçue pour les amateurs de sécurité informatique et les enthousiastes des compétitions CTF (Capture The Flag). EZCTF se décline en plusieurs branches, chacune répondant à un besoin spécifique de la communauté :
    • EZCTF Tools : Une gamme d'outils conçus pour assister les utilisateurs dans une variété de domaines, tels que la stéganographie, la cryptographie, et plus, rendant le processus de résolution des challenges plus accessible.
    • EZCTF Academy : Un espace éducatif offrant des cours et des tutoriels pour tous les niveaux, des débutants aux experts, abordant les principes fondamentaux ainsi que les techniques avancées en cybersécurité.
    • EZCTF Challenges : Le cœur compétitif de la plateforme, proposant une large gamme de challenges CTF incluant la cryptographie, la stéganographie, le lockpicking, et bien d'autres catégories. Ces défis sont conçus pour tester et améliorer les compétences pratiques des utilisateurs dans un environnement compétitif et stimulant.
  • discord-canvas : Un module NPM innovant qui simplifie la manipulation d'images pour les bots Discord.js, facilitant la création de cartes d'accueil personnalisées, d'annonces et bien plus encore. Conçu pour être facile à utiliser, discord-canvas permet aux développeurs d'intégrer des fonctionnalités visuelles attrayantes dans leurs bots Discord avec un minimum d'effort.

Pourquoi me suivre ? 🌈

En me suivant, vous resterez à jour avec mes dernières découvertes, projets, et contributions à l'univers du développement web et de la cybersécurité. Je partage régulièrement des tutoriels, des astuces de programmation, et des insights sur les dernières tendances technologiques.

Comment me contacter ? 📫


Je suis toujours ouvert à collaborer sur des projets passionnants et à échanger avec d'autres développeurs et technophiles. N'hésitez pas à me contacter !

Merci de votre visite et à bientôt sur GitHub !

discord-canvas's People

Contributors

androz2091 avatar richienb avatar shadyyey avatar speckyyt avatar twlite avatar xixi52 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

discord-canvas's Issues

Unhandled Promise Rejection Warning: Error: connect ETIMEDOUT

( Client is created at the beginning of my code )

`
client.on("guildMemberAdd", async (member) => {
const { MessageAttachment } = require('discord.js')
const Canvas = require("discord-canvas")

        const user = member.user;
        const image = await new Canvas.Welcome()
            .setUsername(user.username)
            .setDiscriminator(user.discriminator)
            .setMemberCount(member.guild.memberCount)
            .setGuildName(member.guild.name)
            .setAvatar(user.displayAvatarURL({ format: 'png' }))
            .setColor("border", "#8015EA")
            .setColor("username-box", "#8015EA")
            .setColor("discriminator-box", "#8015EA")
            .setColor("message-box", "#8015EA")
            .setColor("title", "#8015EA")
            .setColor("avatar", "#8015EA")
            .setBackground("https://site.com/background.jpg")
            .toAttachment();
    
        const attachment = new MessageAttachment((await image).toBuffer(), "goodbye-image.png");
        const channel = member.guild.channels.cache.find(ch => ch.name == 'welcome');
        channel.send(attachment);

})
`

This code in my discord bot isn't working for some reason, I've tried it without the canvas part and it worked perfectly, so I don't know what is wrong. I uninstalled and reinstalled discord-canvas but it still won't work. The error I get is:
UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT 204.74.99.100:443 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)

toBuffer() error

`const { MessageAttachment } = require("discord.js");
const canvas = require("discord-canvas")

exports.run = async (client, message, args, prefix) => {

let image = new canvas.RankCard()
.setAddon("xp", false)
.setAddon("rank", false)
.setAvatar(message.author.avatarURL)
.setLevel(7)
.setReputation(450)
.setRankName("professional")
.setUsername("xixi52")
.setBadge(1, "gold")
.setBadge(3, "diamond")
.setBadge(5, "silver")
.setBadge(6, "bronze")
.setBackground("https://www.site.com/background.jpg")
.toAttachment();

let attachment = new MessageAttachment(image.toBuffer(), "rank-card.png");

message.channel.send(attachment)
}

I was testing the npm and when I put the command I get the following error:

(node:2851) UnhandledPromiseRejectionWarning: TypeError: image.toBuffer is not a function

I don't understand the mistake

rank.js

const Discord = require("discord.js");
const Canvas = require("discord-canvas");

module.exports = {
  name: "rank",
  description: "Permet de pouvoir voir l'Expérience une personne",
  permission: "Aucune",
  dm: false,
  category: "Expérience",
  options: [
    {
      type: "user",
      name: "membre",
      description: "La personne à bannir",
      required: true,
    },
  ],

  async run(bot, message, args, db) {
    let user;
    if (args.getUser("membre")) {
      user = args.getUser("membre");
      if (!user || !message.guild.members.cache.get(user?.id))
        return message.replay("Pas de membre");
    } else user = message.user;

    db.query(
      `SELECT * FROM xp WHERE guild = '${message.guildId}' AND user = '${user.id}'`,
      async (err, req) => {
        db.query(
          `SELECT * FROM xp WHERE guild = '${message.guildId}'`,
          async (err, all) => {
            if (req.length < 1)
              return message.reply("Ce membre n'a pas encore d'xp");

            await message.deferReply();

            const calculXp = (xp, level) => {
              let xptotal = 0;
              for (i = 0; i < level + 1; i++) xptotal += i * 1000;
              xptotal += xp;
              return xptotal;
            };

            let leaderboard = await all.sort(async (a, b) =>
              calculXp(
                parseInt(b.xp),
                parseInt(b.level) - calculXp(parseInt(a.xp), parseInt(a.level))
              )
            );

            let level = parseInt(req[0].level);
            let xp = parseInt(req[0].xp);
            let rank = leaderboard.findIndex((r) => r.user === user.id) + 1;
            let need = (level + 1) * 1000;

            let Card = await new Canvas.RankCard()

              .setBackground(
                "https://images.hdqwalls.com/download/anime-sky-4k-0f-1920x1080.jpg"
              )
              .setAddon(rank)
              .setRankName(need)
              .setAvatar(message.user.displayAvatarURL({ extension: "jpg" }))
              .setLevel(level)
              .setReputation(xp)
              .setUsername(user.tag)
              .toAttachment();

            await message.followUp({
              files: [
                new Discord.AttachmentBuilder(Card.toBuffer(), {
                  name: "rank.png",
                }),
              ],
            });
          }
        );
      }
    );
  },
};

error

\Tsuki\node_modules\discord-canvas\utils\functions.js:10
        const formattedVariable = variable.toLowerCase()
                                           ^

TypeError: variable.toLowerCase is not a function
    at formatVariable (C:\Users\Izuki\OneDrive\Documents\Tsuki\node_modules\discord-canvas\utils\functions.js:10:44)
    at RankCard.setAddon (C:\Users\Izuki\OneDrive\Documents\Tsuki\node_modules\discord-canvas\src\rank\Rank.js:107:31)
    at Query.<anonymous> (C:\Users\Izuki\OneDrive\Documents\Tsuki\Commandes\rank.js:62:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

config

how to enter a bot token?

Developer Response

Why isn't discord-canvas working on discord.js v13?

  1. It's not working because of a different package you can use, Canvas-Constructor. It's documents will be listed at the end of the messages.

Will we be getting the fix for discord.js V13.

  1. I would likely say no, because i cannot get to xixi52. And cannot get in touch with her/him/them.

Links that i promised

Github: https://github.com/kyranet/canvasConstructor
NPM: https://www.npmjs.com/package/canvas-constructor
Docs: https://canvasconstructor.js.org/
Guide: https://canvasconstructor.js.org/#/docs/CanvasConstructor/master/Getting%20Started/GettingStarted

Permanent invite to this server: https://discord.gg/taNgb9d

.setMemberCount

How am I suppose to set Member Count for welcome message?

xp and needed xp?

what is the field to modify the xp bar in the canvas?

dd

i tried
.setxpCurrent()
.setxpNeeded()
but it doesn't work, what is the exact value please?
Thanks

Documentation website down

Hi I was thinking of using this and wanted to check out the documentation however the website is down so I can't.

TypeError: image.toBuffer is not a function

im using the default welcome message code and it says image.toBuffer is not a function

My code:~

    bot.on("guildMemberAdd", async member => {
      if(!member.guild) return;
      const channel = await db.fetch(`WELCOME-${member.guild.id}`);
      if(!channel) return;

      const image = new Canvas.Welcome()
      .setUsername(member.user.username)
      .setDiscriminator(member.user.discriminator)
      .setMemberCount(member.guild.memberCount.toLocaleString())
      .setGuildName(member.guild.name)
      .setAvatar(member.user.displayAvatarURL())
      .setColor("border", "#6edb90")
      .setColor("username-box", "#6edb90")
      .setColor("discriminator-box", "#6edb90")
      .setColor("message-box", "#6edb90")
      .setColor("title", "#6edb90")
      .setColor("avatar", "#6edb90")
      .setText("member-count", "- {count}th Member!")
      .setText("title", "New User")
      .setText("message", "Welcome new user!")


      const attachment = new Discord.MessageAttachment(image.toBuffer(), "welcome-image.png");
 
       bot.channels.cache.get(channel).send(attachment);
    })
    ```

Site not working

The site discord-canvas.net is not working .
Please send the details on the website to me as i need the doccumentation

when i try to make a welcome card

(process:23100): Pango-WARNING **: 14:28:09.544: couldn't load font "The Bold Font Bold Not-Rotated 47px", falling back to "Sans Bold Not-Rotated 47px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.593: couldn't load font "The Bold Font Bold 47px", falling back to "Sans Bold 47px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.598: couldn't load font "The Bold Font Bold Not-Rotated 52px", falling back to "Sans Bold Not-Rotated 52px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.618: couldn't load font "The Bold Font Bold 52px", falling back to "Sans Bold 52px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.622: couldn't load font "The Bold Font Bold Not-Rotated 51px", falling back to "Sans Bold Not-Rotated 51px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.629: couldn't load font "The Bold Font Bold 51px", falling back to "Sans Bold 51px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.631: couldn't load font "The Bold Font Bold Not-Rotated 50px", falling back to "Sans Bold Not-Rotated 50px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.657: couldn't load font "The Bold Font Bold 50px", falling back to "Sans Bold 50px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.658: couldn't load font "The Bold Font Bold Not-Rotated 49px", falling back to "Sans Bold Not-Rotated 49px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.664: couldn't load font "The Bold Font Bold 49px", falling back to "Sans Bold 49px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.664: couldn't load font "The Bold Font Bold Not-Rotated 48px", falling back to "Sans Bold Not-Rotated 48px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.672: couldn't load font "The Bold Font Bold 48px", falling back to "Sans Bold 48px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.675: couldn't load font "The Bold Font Bold Not-Rotated 40px", falling back to "Sans Bold Not-Rotated 40px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.689: couldn't load font "The Bold Font Bold Not-Rotated 22px", falling back to "Sans Bold Not-Rotated 22px", expect ugly output.        

(process:23100): Pango-WARNING **: 14:28:09.699: couldn't load font "Sketch Match Not-Rotated 75px", falling back to "Sans Not-Rotated 75px", expect ugly output.

(process:23100): Pango-WARNING **: 14:28:09.725: couldn't load font "The Bold Font Bold Not-Rotated 90px", falling back to "Sans Bold Not-Rotated 90px", expect ugly output.

Fontconfig error: Cannot load default config file

Hello. Whenever I try to make an image from discord-canvas, this log always appears but the image is properly generated. Any help? Thanks in advance.
Here's the log:
image

Successfully generated image:
image

Code:

// This code is for my WhatsApp bot
const welcomer = await new canvas.Welcome()
    .setUsername(pushname)
    .setDiscriminator(event.who.substring(6, 10))
    .setMemberCount(groupMetadata.participants.length)
    .setGuildName(name)
    .setAvatar(picx)
    .setColor('border', '#00FFFF')
    .setColor('username-box', '#00FFFF')
    .setColor('discriminator-box', '#00FFFF')
    .setColor('message-box', '#00FFFF')
    .setColor('title', '#00FFFF')
    .toAttachment()
const base64 = `data:image/jpg;base64,${welcomer.toBuffer().toString('base64')}`
await bocchi.sendFile(event.chat, base64, 'welcome.jpg', `Welcome ${pushname}!`)

Error: Unsupported image type

Error: Unsupported image type

const image = await new Canvas.Welcome()
  .setUsername(`${interaction.user.username}`)
  .setDiscriminator(`${interaction.user.discriminator}`)
  .setMemberCount(`${interaction.guild.memberCount}`)
  .setGuildName(`${interaction.guild.name}`)
  .setAvatar(`${user.displayAvatarURL({ dynamic: true, size: 256})}`)
  .setColor("border", "#ffffff")
  .setColor("username-box", "#6b6b6b")
  .setColor("discriminator-box", "#4d4d4d")
  .setColor("message-box", "#4d4d4d")
  .setColor("title", "#4d4d4d")
  .setColor("avatar", "#4d4d4d")
  .setBackground("./src/images/background.jpg")
  .toAttachment();

It gives an error with the avatar image, help.

Not working

Hey, can someone help me with this? This code does not work...

const Discord = require('discord.js')
        const canvas = require('discord-canvas'),
        welcomeCanvas = new canvas.Welcome();
        let image = await welcomeCanvas
        .setUsername("${username}")
        .setDiscriminator("${discrim}")
        .setMemberCount("${members}")
        .setGuildName("${guild}")
        .setAvatar("${avatar}")
        .setColor("border", "#ff0000")
        .setColor("username-box", "#660000")
        .setColor("discriminator-box", "#ff0000")
        .setColor("message-box", "#ff6666")
        .setColor("title", "#ff0000")
        .setColor("avatar", "#660000")
        .setBackground("${background}")
        .toAttachment();
let attachment = new Discord.MessageAttachment(image.toBuffer(), "card.png");
message.channel.send(attachment)

There is no error, but the bot does not respond...

Error: No such FIle or directory '{user's username}'

Please Help!
Error: UnhandledPromiseRejectionWarning: Error: ENOENT, No such file or directory 'xixi52'
Code:

        const image = await new Canvas.RankCard()
            .setAvatar("xixi52")
            .setXP("current", 500)
            .setXP("needed", 1000)
            .setLevel(7)
            .setRank(2)
            .setReputation(450)
            .setRankName("professional")
            .setUsername("xixi52")
            .setBadge(1, "gold")
            .setBadge(3, "diamond")
            .setBadge(5, "silver")
            .setBadge(6, "bronze")
            .setBackground("https://coolbackgrounds.io/images/backgrounds/index/sea-edge-79ab30e2.png")
            .toAttachment();
 
        const attachment = new Discord.MessageAttachment(image.toBuffer(), "rank-card.png");
 
        message.channel.send(attachment);

Error!

image.toBuffer() is not function

server responded with 404

return onerror(new Error(Server responded with ${res.statusCode}))
^

Error: Server responded with 404
at C:\Users\x\Desktop\test\node_modules\canvas\lib\image.js:56:28
at C:\Users\x\Desktop\test\node_modules\simple-get\index.js:89:7
at IncomingMessage. (C:\Users\x\Desktop\test\node_modules\simple-concat\index.js:8:13)

return Canvas._registerFont(fs.realpathSync(src), fontFace)

return Canvas._registerFont(fs.realpathSync(src), fontFace)
^

Error: Could not parse font file
at Object.registerFont (C:\Users\Home\Desktop\Secretaria\Discord\Programação\Bots\star\star-developer\node_modules\canvas\index.js:48:17)
at Object. (C:\Users\Home\Desktop\Secretaria\Discord\Programação\Bots\star\star-developer\node_modules\discord-canvas\index.js:3:8)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object. (C:\Users\Home\Desktop\Secretaria\Discord\Programação\Bots\star\star-developer\src\commands\Others\fnshop.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at C:\Users\Home\Desktop\Secretaria\Discord\Programação\Bots\star\star-developer\bot.js:100:21
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node bot.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Home\AppData\Roaming\npm-cache_logs\2021-01-07T15_18_05_141Z-debug.log

(node:8940) UnhandledPromiseRejectionWarning: Error: ENOENT, No such file or directory 'undefined'

(node:8940) UnhandledPromiseRejectionWarning: Error: ENOENT, No such file or directory 'undefined'
at setSource (C:\Users\Giingu\Desktop\Discord.Bot.Maker\BOTS\NezukoBot\node_modules\discord-canvas\node_modules\canvas\lib\image.js:91:13)
at Image.set (C:\Users\Giingu\Desktop\Discord.Bot.Maker\BOTS\NezukoBot\node_modules\discord-canvas\node_modules\canvas\lib\image.js:62:9)
at C:\Users\Giingu\Desktop\Discord.Bot.Maker\BOTS\NezukoBot\node_modules\discord-canvas\node_modules\canvas\index.js:34:15
at Object.loadImage (C:\Users\Giingu\Desktop\Discord.Bot.Maker\BOTS\NezukoBot\node_modules\discord-canvas\node_modules\canvas\index.js:23:10)
at Welcome.toAttachment (C:\Users\Giingu\Desktop\Discord.Bot.Maker\BOTS\NezukoBot\node_modules\discord-canvas\src\greetings\Base.js:149:37)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async eval (eval at Actions.eval (C:\Users\Giingu\Desktop\Discord.Bot.Maker\BOTS\NezukoBot\bot.js:344:10), :6:14)
(node:8940) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)

Using:
Discord.js v12.2.0
discord-canvas v1.3.2

HELP

Error: Cannot find module 'moment'
Require stack:

  • C:\Users\LuisDavi\Desktop\Projects\Discord-Police\node_modules\discord-canvas\src\fortnite\Shop.js
  • C:\Users\LuisDavi\Desktop\Projects\Discord-Police\node_modules\discord-canvas\index.js
  • C:\Users\LuisDavi\Desktop\Projects\Discord-Police\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at Object. (C:\Users\LuisDavi\Desktop\Projects\Discord-Police\node_modules\discord-canvas\src\fortnite\Shop.js:4:12)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    'C:\Users\LuisDavi\Desktop\Projects\Discord-Police\node_modules\discord-canvas\src\fortnite\Shop.js',
    'C:\Users\LuisDavi\Desktop\Projects\Discord-Police\node_modules\discord-canvas\index.js',
    'C:\Users\LuisDavi\Desktop\Projects\Discord-Police\index.js'
    ]
    }

403 Error

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);
  }
};

Outdated

Discord-canvas currently depends on unsafe dependencies can you update it??

# npm audit report

simple-get  <4.0.1
Severity: high
Exposure of Sensitive Information in simple-get - https://github.com/advisories/GHSA-wpg7-2c88-r8xv
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/simple-get
  canvas  >=2.5.0
  Depends on vulnerable versions of simple-get
  node_modules/canvas
    discord-canvas  >=1.0.1
    Depends on vulnerable versions of canvas
    node_modules/discord-canvas

3 high severity vulnerabilities

My code doesnt work

const { MessageEmbed, MessageAttachment } = require("discord.js");
const db = require('quick.db')
const canvas = require("discord-canvas")
module.exports = {
name: "guildMemberAdd",
async execute(client, member) {
let welcomeChannel = db.get(welchannel_${member.guild.id});

if(welcomeChannel === null) {
  return;
}
let autoRole = db.get(`welcomerole_${member.guild.id}`);
if (autoRole === null || !autoRole) return;
const avatar = member.displayAvatarURL({ dynamic: true });
const membercount = message.guild.memberCount;

let image = new canvas.Welcome()
.setUsername(${member.username})
.setDiscriminator(${member.discriminator})
.setMemberCount(membercount)
.setGuildName(${member.guild.name})
.setAvatar(avatar)
.setColor("border", "#8015EA")
.setColor("username-box", "#8015EA")
.setColor("discriminator-box", "#8015EA")
.setColor("message-box", "#8015EA")
.setColor("title", "#8015EA")
.setColor("avatar", "#8015EA")
.setBackground("https://www.osustuff.org/img/imageslice/2020-09-22/128949/710153.jpg")
.toAttachment();

let attachment = new MessageAttachment(image.toBuffer(), "welcome-image.png");

client.channels.cache.get(welcomeChannel).send(attachment)
member.roles.add(autoRole.id);

}
}

Cannot find module 'moment'

Hi!
I have tried to install discord-canvas, even the types but it gives me 404 error so add @ts-ignore to be able to run the bot
But when I run the bot, it shows me the error that the moment module is not found

TypeScript v4.3.5

Module Error Preview

can't require the package

When I try to install the package via npm i --save-dev @types/discord-canvas I get this error:
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@types%2fdiscord-canvas - Not found
npm ERR! 404
npm ERR! 404 '@types/discord-canvas@*' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Using Typescript.

Connection Timeout when sending message

The Connection always times out when it posts the attachment. After some research i found this is the problem of discord-canvas only.

Error: connect ETIMEDOUT 204.74.99.100:443 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) { errno: -4039, code: 'ETIMEDOUT', syscall: 'connect', address: '204.74.99.100', port: 443 }

v13 is broken

Hello, are you doing to upgrade to v13? Most of the package is broken for v13.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.