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

259
Views
Sudo command (discord.js)

Im trying to make a sudo command but the user i mention in args 0's Profile picture wont show.

async execute(client, message, args) {
    if (!message.member.hasPermission("MANAGE_WEBHOOKS")) {
            return message.channel.send(`You don't have permission to execute this command.`)}
    message.delete();
    let user =
    message.mentions.members.first() ||
    message.guild.members.cache.get(args[0]) ||
    message.member.id();
    if (!user) return message.channel.send("Please provide a user!");
    const webhook = await message.channel.createWebhook(user.displayName, {
    avatar: user.user.displayAvatarURL(),
    channel: message.channel.id
    });
    await webhook.send(args.slice(1).join(" ")).then(() => {
    webhook.delete();
    });
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

A couple of things:

  1. Your declaration of user (let user =) is a bit misleading when you are fetching a member object from the cache. I would recommend changing it to member instead for coherency.

  2. Smallketchup82 is correct. Because you are getting a member object you would need to use the .user attribute to get anything pertaining to the user portion (username, tag, discriminator, and avatar).

If you were to follow the above advice you could do something like:

avatar: member.user.avatarURL()

I'm not entirely sure of which method gets the user's avatar as I have only worked with discordjs v13. However, its most likely one of the two:

  • member.user.displayAvatarURL()
  • member.user.avatarURL()
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!