-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EmoteCloner: Fix a hang when the sticker/original server is deleted #3087
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -63,16 +63,20 @@ async function fetchSticker(id: string) { | |||||||||||||
const cached = StickersStore.getStickerById(id); | ||||||||||||||
if (cached) return cached; | ||||||||||||||
|
||||||||||||||
const { body } = await RestAPI.get({ | ||||||||||||||
url: Constants.Endpoints.STICKER(id) | ||||||||||||||
}); | ||||||||||||||
try { | ||||||||||||||
const { body } = await RestAPI.get({ | ||||||||||||||
url: Constants.Endpoints.STICKER(id) | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
FluxDispatcher.dispatch({ | ||||||||||||||
type: "STICKER_FETCH_SUCCESS", | ||||||||||||||
sticker: body | ||||||||||||||
}); | ||||||||||||||
FluxDispatcher.dispatch({ | ||||||||||||||
type: "STICKER_FETCH_SUCCESS", | ||||||||||||||
sticker: body | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
return body as Sticker; | ||||||||||||||
return body as Sticker; | ||||||||||||||
} catch (err) { | ||||||||||||||
return undefined; | ||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
async function cloneSticker(guildId: string, sticker: Sticker) { | ||||||||||||||
|
@@ -336,7 +340,33 @@ const messageContextMenuPatch: NavContextMenuPatchCallback = (children, props) = | |||||||||||||
const sticker = props.message.stickerItems.find(s => s.id === favoriteableId); | ||||||||||||||
if (sticker?.format_type === 3 /* LOTTIE */) return; | ||||||||||||||
|
||||||||||||||
return buildMenuItem("Sticker", () => fetchSticker(favoriteableId)); | ||||||||||||||
// Workaround for cases when it's not available | ||||||||||||||
// (e.g when using MessageLinkEmkbeds) | ||||||||||||||
if (sticker === undefined) { | ||||||||||||||
return; | ||||||||||||||
} | ||||||||||||||
Comment on lines
+345
to
+347
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
|
||||||||||||||
return buildMenuItem("Sticker", async () => { | ||||||||||||||
const fetchedSticker = await fetchSticker(favoriteableId); | ||||||||||||||
|
||||||||||||||
// Workaround for incase the sticker or the server it's from is deleted. | ||||||||||||||
// Allows the sticker to still be cloned. | ||||||||||||||
if (fetchedSticker === undefined) { | ||||||||||||||
return { | ||||||||||||||
"id": sticker?.id, | ||||||||||||||
"name": sticker?.name, | ||||||||||||||
"format_type": sticker?.format_type, | ||||||||||||||
// Discord has a character limit of at least 1 for tags (aka related emoji) | ||||||||||||||
"tags": " ", | ||||||||||||||
"description": "", | ||||||||||||||
"type": "2", | ||||||||||||||
"available": true, | ||||||||||||||
"guild_id": 0 | ||||||||||||||
Comment on lines
+356
to
+364
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. format to have normal key names not in quotes |
||||||||||||||
}; | ||||||||||||||
} else { | ||||||||||||||
return fetchedSticker; | ||||||||||||||
} | ||||||||||||||
Comment on lines
+366
to
+368
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
}); | ||||||||||||||
} | ||||||||||||||
})(); | ||||||||||||||
|
||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.