fix: Discord Rich Presence Fix (#3074)

* discord presence fix

* Update src/plugins/discord/main.ts

Co-authored-by: JellyBrick <shlee1503@naver.com>

* variable length support

---------

Co-authored-by: JellyBrick <shlee1503@naver.com>
This commit is contained in:
Tix
2025-03-24 11:20:50 +07:00
committed by GitHub
parent 21b54ef6ff
commit e00c357fae

View File

@ -38,6 +38,12 @@ const info: Info = {
*/
const refreshCallbacks: (() => void)[] = [];
const truncateString = (str: string, length: number): string => {
if (str.length > length)
return `${str.substring(0, length - 3)}...`;
return str;
}
const resetInfo = () => {
info.ready = false;
clearTimeout(clearActivity);
@ -184,8 +190,8 @@ export const backend = createBackend<
const activityInfo: SetActivity = {
type: ActivityType.Listening,
details: songInfo.title,
state: songInfo.artist,
details: truncateString(songInfo.title, 128),
state: truncateString(songInfo.artist, 128),
largeImageKey: songInfo.imageSrc ?? '',
largeImageText: songInfo.album ?? '',
buttons,