Created
March 16, 2024 23:49
-
-
Save JanPlazovnik/de7cc5e14cd1d22254652b4b27526604 to your computer and use it in GitHub Desktop.
Set gif avatar/banner to bot via discord.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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