When I try to use client.user.setAvatar(), nothing happens

Viewed 88

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.

1 Answers

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.

Related