Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord.js trying to merge images throws an error #106

Open
AroTheBirb opened this issue Apr 11, 2021 · 0 comments
Open

Discord.js trying to merge images throws an error #106

AroTheBirb opened this issue Apr 11, 2021 · 0 comments

Comments

@AroTheBirb
Copy link

I'm trying to merge an image from a dir and a user's avatar the dir is right but i get error

(node:6028) UnhandledPromiseRejectionWarning: Error: Couldn't load image
    at img.onerror (C:\Users\aoshe\OneDrive\Desktop\amogus\node_modules\merge-images\dist\index.umd.js:39:46)
    at setSource (C:\Users\aoshe\OneDrive\Desktop\amogus\node_modules\canvas\lib\image.js:91:13)
    at Image.set (C:\Users\aoshe\OneDrive\Desktop\amogus\node_modules\canvas\lib\image.js:62:9)
    at C:\Users\aoshe\OneDrive\Desktop\amogus\node_modules\merge-images\dist\index.umd.js:41:12
    at new Promise (<anonymous>)
    at C:\Users\aoshe\OneDrive\Desktop\amogus\node_modules\merge-images\dist\index.umd.js:30:55
    at Array.map (<anonymous>)
    at C:\Users\aoshe\OneDrive\Desktop\amogus\node_modules\merge-images\dist\index.umd.js:30:24
    at new Promise (<anonymous>)
    at mergeImages (C:\Users\aoshe\OneDrive\Desktop\amogus\node_modules\merge-images\dist\index.umd.js:22:10)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6028) 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: 2)
(node:6028) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

the code:

const mergeImages = require('merge-images')
const { Canvas, Image } = require('canvas');

module.exports = {
    name: 'avatar',
    description: 'avatar',
    async execute(message, args) {
        var url;

        mergeImages(['../../assets/colors/yellow.png', message.author.displayAvatarURL()], {
            Canvas: Canvas,
            Image: Image
          }).then(b64 => url = b64);
          

        message.reply(url);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant