Skip to content

Instantly share code, notes, and snippets.

@JanPlazovnik
Created March 16, 2024 23:49
Show Gist options
  • Save JanPlazovnik/de7cc5e14cd1d22254652b4b27526604 to your computer and use it in GitHub Desktop.
Save JanPlazovnik/de7cc5e14cd1d22254652b4b27526604 to your computer and use it in GitHub Desktop.
Set gif avatar/banner to bot via discord.js
// discord developer dashboard doesnt yet allow uploading gif banners or avatars, so you need to do it via their api
// some gifs end up being "corrupted", as in they'll flicker black or look like they were shat out by a hellhound
// not sure yet why, maybe it's a filesize/dimensions kinda thing
const url = 'url.gif';
const banner = await axios.get(url, { responseType: 'arraybuffer' });
const base64 = Buffer.from(banner.data).toString('base64');
const base64Image = `data:image/gif;base64,${base64}`;
await this.client.rest.patch('/users/@me', {
body: {
avatar: base64Image,
// banner: base64Image,
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment