Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
avoid crash if guild has Apps context menu 2
Browse files Browse the repository at this point in the history
  • Loading branch information
userXinos committed Sep 9, 2022
1 parent 2e589aa commit 9f6b1db
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions modules/Patcher/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ module.exports = class General {
if (menu?.type?.displayName) {
patchMenu(menu.type.displayName);
} else {
const { getGuild } = getModule([ 'getGuild' ], false);
if (getGuild(menu?.props?.guildId).applicationCommandCounts[2]) {
return menu; // avoid infinite loop if there are context menu commands in the guild
}
menu.type = memorizeRender(menu.type, (res) => {
res.props.children.type = memorizeRender(res.props.children.type, (res2) => {
patchMenu(res2?.type?.displayName);
Expand Down Expand Up @@ -186,6 +182,14 @@ module.exports = class General {
const guildMemberAvatars = Object.entries(user.guildMemberAvatars);
const currentGuildId = guildMemberAvatars.findIndex(([ id ]) => id === guildId);
const isCurrentGuild = currentGuildId !== -1;

// @TODO (temporarily ?)
// avoid infinite loop if there are context menu commands in the guild
if (guildId) {
if (2 in getGuild(guildId).applicationCommandCounts) {
return children;
}
}
if (isCurrentGuild) {
guildMemberAvatars.splice(0, 0, guildMemberAvatars.splice(currentGuildId, 1)[0]);
}
Expand Down

0 comments on commit 9f6b1db

Please sign in to comment.