@@ -41,8 +41,6 @@ public static class InGameOverworldHelper {
4141 { "grandmaster" , Calc . HexToColor ( "DD87FF" ) }
4242 } ;
4343
44- private static Hook hookOnDiscordRichPresenceChange ;
45-
4644 private static bool presenceLock = false ;
4745
4846 internal static void Load ( ) {
@@ -65,20 +63,7 @@ internal static void Load() {
6563 IL . Celeste . OuiChapterPanel . _FixTitleLength += ModFixTitleLength ;
6664 On . Celeste . OuiMainMenu . CreateButtons += OnOuiMainMenuCreateButtons ;
6765
68- // hooks the Discord rich presence update method of stable version 3650
69- // TODO: this should be replace with On.Celeste when this will have reached stable
70- MethodInfo discordRichPresence = typeof ( EverestModule ) . Assembly . GetType ( "Celeste.Mod.Everest+Discord" ) ? . GetMethod ( "UpdateText" ) ;
71- if ( discordRichPresence != null ) {
72- hookOnDiscordRichPresenceChange = new Hook ( discordRichPresence , typeof ( InGameOverworldHelper )
73- . GetMethod ( "OnDiscordChangePresenceOld" , BindingFlags . NonPublic | BindingFlags . Static ) ) ;
74- }
75-
76- // hooks the Discord rich presence update method of pull request https://github.com/EverestAPI/Everest/pull/543
77- discordRichPresence = typeof ( EverestModule ) . Assembly . GetType ( "Celeste.Mod.Everest+DiscordSDK" ) ? . GetMethod ( "UpdatePresence" , BindingFlags . NonPublic | BindingFlags . Instance ) ;
78- if ( discordRichPresence != null ) {
79- hookOnDiscordRichPresenceChange = new Hook ( discordRichPresence , typeof ( InGameOverworldHelper )
80- . GetMethod ( "OnDiscordChangePresenceNew" , BindingFlags . NonPublic | BindingFlags . Static ) ) ;
81- }
66+ On . Celeste . Mod . Everest . DiscordSDK . UpdatePresence += OnDiscordChangePresence ;
8267
8368 hookOnMapDataOrigLoad = new Hook (
8469 typeof ( MapData ) . GetMethod ( "orig_Load" , BindingFlags . NonPublic | BindingFlags . Instance ) ,
@@ -129,8 +114,7 @@ internal static void Unload() {
129114 hookOnMapDataOrigLoad ? . Dispose ( ) ;
130115 hookOnMapDataOrigLoad = null ;
131116
132- hookOnDiscordRichPresenceChange ? . Dispose ( ) ;
133- hookOnDiscordRichPresenceChange = null ;
117+ On . Celeste . Mod . Everest . DiscordSDK . UpdatePresence -= OnDiscordChangePresence ;
134118 }
135119
136120 private static void OnOuiChapterPanelStart ( On . Celeste . OuiChapterPanel . orig_Start orig , OuiChapterPanel self , string checkpoint ) {
@@ -217,14 +201,8 @@ private static void OnReloadLevel(On.Celeste.Mod.AssetReloadHelper.orig_ReloadLe
217201 orig ( ) ;
218202 }
219203
220- private static void OnDiscordChangePresenceOld ( Action < string , string , Session > orig , string details , string state , Session session ) {
221- if ( ! presenceLock ) {
222- orig ( details , state , session ) ;
223- }
224- }
225-
226204
227- private static void OnDiscordChangePresenceNew ( Action < object , Session > orig , object self , Session session ) {
205+ private static void OnDiscordChangePresence ( On . Celeste . Mod . Everest . DiscordSDK . orig_UpdatePresence orig , Everest . DiscordSDK self , Session session ) {
228206 if ( ! presenceLock ) {
229207 orig ( self , session ) ;
230208 }
0 commit comments