Skip to content

Instantly share code, notes, and snippets.

@MCausc78
Created March 6, 2025 12:59
Show Gist options
  • Save MCausc78/9eda7792183ac02dfbd475885910bad4 to your computer and use it in GitHub Desktop.
Save MCausc78/9eda7792183ac02dfbd475885910bad4 to your computer and use it in GitHub Desktop.
Forcefully reload application command cache
(() => {
let wp;
webpackChunkdiscord_app.push([[Symbol()], {}, r => wp = r]);
webpackChunkdiscord_app.pop();
let Dispatcher, GuildStore;
for (const m of Object.values(wp.c)) {
if (Dispatcher !== undefined && GuildStore !== undefined) break;
if (!m.exports || m.exports === window) continue;
for (const p of Object.values(m.exports)) {
if (Dispatcher !== undefined && GuildStore !== undefined) break;
if (p?.getGuildIds && p?.getRoles && GuildStore === undefined) {
GuildStore = p;
} else if (p?._dispatchWithDevtools && Dispatcher === undefined) {
Dispatcher = p;
}
}
}
// Invalidate user application command index.
Dispatcher.dispatch({
type: 'USER_APPLICATION_UPDATE',
applicationId: '0',
});
// Invalidate application command index for all guilds.
for (const guildId of GuildStore.getGuildIds()) {
Dispatcher.dispatch({
type: 'GUILD_APPLICATION_COMMAND_INDEX_UPDATE',
guildId,
version: Date.now(),
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment