2

I am trying to change to bot avatar to a certain user's avatar, but am having trouble.

I tried:

client.users.fetch('userid').then((user) => {
    client.user.setAvatar(user.avatarURL());
});

It doesn't work and the avatar doesn't change.

Nimantha
  • 6,405
  • 6
  • 28
  • 69

1 Answers1

0

Change your code to this:

client.users.fetch('userid').then((user) => {  client.user.setAvatar(user.avatarURL().replace("webp","png");
});

Avatar URL is just the image link. Discord CDN can automatically generate image in different format if you change image format in the link itself. Therefore I did the same above.

Ren Hiyama
  • 383
  • 2
  • 13