Update Guild
Hi!
I am unable to update the guild (server), I want to update server name and server icon but i can not do it, i think actually the update is one step behind. For example, my server name is mate and i want to update it to mate1, it stays mate, and then when i update my server name in the discord app as mate2, then i fetch mate1 name inside my logs. I am getting this guild object https://discord.com/developers/docs/resources/guild#guild-object. Can you help me with the updating my guild/server? #
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
9 Replies
- 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 staffyour code?
this is inside my try block logger.trace('Trying to retrieve cached M2M Token...');
const m2mToken = await cache.get(CACHE_KEYS.M2M_TOKEN);
let freshM2MToken;
if (!m2mToken) {
logger.trace('No M2M Token in the cache, fetching a new one...');
freshM2MToken = await fetchM2MToken();
cache.set(CACHE_KEYS.M2M_TOKEN, freshM2MToken);
}
logger.trace(
'Attempting to ping LP API to fetch guild's LP discord server...'
);
const response = await axios.get(
${letsPlayApiPath}/connection/discord/${guild.guild.id}
,
{
headers: {
Authorization: Bearer ${m2mToken ?? freshM2MToken}
,
},
}
);
if (!response.data) {
logger.trace('Couldn't fetch guild's LP discord server from LP API.');
return;
}
const { name, iconUrl } = response.data;
logger.trace({ name, iconUrl });
if (name !== guild.guild.name || iconUrl !== guild.iconUrl) {
logger.trace(
'Attempting to ping LP API to update discord server name or icon url...'
);
await axios.patch(
${letsPlayApiPath}/connection/discord/${guild.id}
,
{
name: guild.guild.name,
iconUrl: guild.iconUrl,
},
{
headers: {
Authorization: Bearer ${m2mToken ?? freshM2MToken}
,
},
}
);
logger.trace('Successfully updated discord server name or icon url.');
} else {
logger.trace('Discord server name and icon url are not changed.');
}
guild is fetched as a parameter of the method
and the method is executed on Events.GuildUpdate
so i have an idea my state is late for 1 stepThis also doesnt look like djs
i am importing discord js events
Okay but your above code is not in any way djs related
Its raw api requests
that guild object is exactly the same as in the documentation
okay
Then shiw the actual relevant code
#other-js-ts otherwise