Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

292
Views
UnhandledPromiseRejectionWarning: ReferenceError: interaction is not defined

I made a discord bot that edit peoples profiles, but it came out like this.

UnhandledPromiseRejectionWarning: ReferenceError: interaction is not defined

I'm new to programming

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

module.exports.run = async (bot, message, args)=> {

  const canvas = Canvas.createCanvas(256, 256);
  const ctx = canvas.getContext('2d');

  const background = await Canvas.loadImage(interaction.user.displayAvatarURL({ format: 'png' }));
  ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

  const avatar = await Canvas.loadImage('./bars.png');
  ctx.drawImage(avatar, 25, 0, 200, canvas.height )

  const attachment = new MessageAttachment(canvas.toBuffer(), 'jailxd.png');

  message.channel.send(attachment);
  }

  exports.conf = {
    enabled: true,
    guildOnly: true,
    aliase:["catch"]
}

exports.help = {
    name:"jail",
    description:"Empty",
    usage:"jail",
    category:"fun"
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Looks like you are trying to make common text command and not slash command, so instead of interaction.user.displayAvatarURL you need to use message.author.displayAvatarURL!

const background = await Canvas.loadImage(message.author.displayAvatarURL({ format: 'png' }));
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!