Automatically Change Bot Icon On Server Icon Change

I have a guild update event that checks if my server had it's icon changed, and if so assign that new icon to the bot as well, the problem is that I also have the mee6 bot with the custom bot option thing enabled, and I want to have that bot also change it's icon automatically, I've tried through the dashboard directly but it doesnt work and I honestly dont want to try asking in their support server. <continued>
22 Replies
d.js toolkit
d.js toolkit10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Sans
SansOP10mo ago
So this is what I've done:
import chalk from 'chalk';
import { Client } from 'discord.js';
import { DiscordEvent } from '../../../core/client/events/DiscordEvent.js';
import { log } from '../../../utils/log.js';

export default new DiscordEvent('guildUpdate', async (oldGuild, newGuild) => {
const oldIcon = oldGuild.iconURL({ forceStatic: false });
const newIcon = newGuild.iconURL({ forceStatic: false });

// Valorant Romania server
if (newGuild.id !== '788184621627473970') return;

if (oldIcon !== newIcon) {
log('p', 'Client', `Client Avatar has been updated due to Guild Icon update.`);

await newGuild.client.user.setAvatar(newIcon);

log('p', 'MEE6', `Creating Mee6 Custom Bot Client...`);

const mee6client = new Client({ intents: [] });

mee6client.once('ready', () => {
log('p', 'MEE6', `Logged in as ${chalk.yellow(mee6client.user!.username)} (${chalk.yellow(mee6client.user!.id)})`);

mee6client
.user!.setAvatar(newIcon)
.then(() => {
log('p', 'MEE6', `Client Avatar has been updated due to Guild Icon update.`);

mee6client
.destroy()
.then(() => log('p', 'MEE6', `Client destroyed.`))
.catch(console.error);
})
.catch(err => {
console.error(err);

mee6client
.destroy()
.then(() => log('p', 'MEE6', `Client destroyed.`))
.catch(console.error);
});
});

log('p', 'MEE6', `Logging in...`);

mee6client.login(process.env.MEE6_CUSTOM_DISCORD_TOKEN);
}
});
import chalk from 'chalk';
import { Client } from 'discord.js';
import { DiscordEvent } from '../../../core/client/events/DiscordEvent.js';
import { log } from '../../../utils/log.js';

export default new DiscordEvent('guildUpdate', async (oldGuild, newGuild) => {
const oldIcon = oldGuild.iconURL({ forceStatic: false });
const newIcon = newGuild.iconURL({ forceStatic: false });

// Valorant Romania server
if (newGuild.id !== '788184621627473970') return;

if (oldIcon !== newIcon) {
log('p', 'Client', `Client Avatar has been updated due to Guild Icon update.`);

await newGuild.client.user.setAvatar(newIcon);

log('p', 'MEE6', `Creating Mee6 Custom Bot Client...`);

const mee6client = new Client({ intents: [] });

mee6client.once('ready', () => {
log('p', 'MEE6', `Logged in as ${chalk.yellow(mee6client.user!.username)} (${chalk.yellow(mee6client.user!.id)})`);

mee6client
.user!.setAvatar(newIcon)
.then(() => {
log('p', 'MEE6', `Client Avatar has been updated due to Guild Icon update.`);

mee6client
.destroy()
.then(() => log('p', 'MEE6', `Client destroyed.`))
.catch(console.error);
})
.catch(err => {
console.error(err);

mee6client
.destroy()
.then(() => log('p', 'MEE6', `Client destroyed.`))
.catch(console.error);
});
});

log('p', 'MEE6', `Logging in...`);

mee6client.login(process.env.MEE6_CUSTOM_DISCORD_TOKEN);
}
});
The thing is I'm not sure if this would even work, and even if it does, would it be the optimal sollution?
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Sans
SansOP10mo ago
? no i meant, the second one is literally a different bot, whose icon i also want to change
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Sans
SansOP10mo ago
i mentioned mee6 because the second bot is managed by it's custom bot premium option thing thought like that mattered :p anyway, through their dashboard there's no way to make it do exactly this: change it's own icon when the guild icon changes and since I know mee6 support to be (excuse the language) shit, i'd rather solve it with code figured that too, but im not sure if there's another way considering the bot is already logged in because of mee6, so i had to log in again, in a separate bot, change the icon, and log out (client.destroy()) and this seemed like the best place to put the code for that that is, literally next to the code that changes the icon in the first bot :dumb:
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Sans
SansOP10mo ago
maybe once or twice per month? depending if we've got events going or not
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Sans
SansOP10mo ago
it is, but im mostly doing it so i can have my designer stop asking me to change the icons every time lol also i cant even upload animated avatars on the dev dashboard as of now
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Sans
SansOP10mo ago
pretty much, yea
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Sans
SansOP10mo ago
no, in theory it should work, i was asking if there's a better thing i can try though, because this all seems very loosely put together and it's the best thing i could come up with
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Sans
SansOP10mo ago
was worth asking about, dw as for intents, the second client is not really going to need to do anything aside from logging in, changing it's own icon and then destroying itself why does it need the Guilds intent?
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Sans
SansOP10mo ago
oh and while I'm on this, does the client.destroy method kill every session for that bot token or just 1? I see
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Sans
SansOP10mo ago
alright how exactly?
Sans
SansOP10mo ago
something like this?
No description
Sans
SansOP10mo ago
type is unknown oof, how exactly do i know if it failed or not? alright, but still how do i know if it failed or not? the type of that is unknown well, Promise<unknown> bet thanks
Want results from more Discord servers?
Add your server