Mount & Blade II: Bannerlord

Mount & Blade II: Bannerlord

49 ratings
Discord Rich Presence
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
20.164 MB
5 Dec, 2022 @ 6:24am
30 Jun, 2024 @ 7:36am
6 Change Notes ( view )

Subscribe to download
Discord Rich Presence

Description
Sources available at GitHub[github.com]!

Adds Discord Rich Presence support for the game! Inspired by one of the first mods on NexusMods, Discord RP for Bannerlord[www.nexusmods.com]!

Full translation support as expected from BUTR mods!
Settings are available via MCM!

You can also enable mod sharing in Options that will add a fancy button on the bottom of your profile, opening it will give you an URL in format `https://modlist.butr.link/d29ee27c-5f08-4a53-b4ae-231a76d5e404` that will contain your game version and the list of enabled mods! The url will be available for 8 hour since the start of your game!
Some commentary about this feature. At the start of the game when the option is enabled or when saving with the enabled option, the module will send to `https://modlist.butr.link` the game version and the mod list and obtain a link that lives 8 hours that will show you the info. This is done this way because Discord has a limit on the URL length and we can't put the info inside the URL via the query params, so we have a quick lived backend server that stores this info.
Because the Module is open-sourced, even if our server dies after some years, we have the backend available[github.com] for anyone to host and setup the module again with the feature!

The game supports basic states:
  • Main Menu
  • Loading
  • Custom Battles
  • Campaign:
  • Traveling near a settlement
  • Conversation with someone
  • At Settlement
  • In Settlement (Mission)
  • In Battle (simulation and not) with troop count. Attacking/Defending. Raid, Siege, Forcing* are all supported

For Modders
Other mods can use this module to set their own presence:
Note that you can use this code even if Bannerlord.DiscordRichPresence is not enabled by user, the actions will be skipped.
ButterLib's DynamicAPI
internal static class DiscordRichPresenceAPI { private static readonly Action<string, DateTime?, DateTime?, bool>? SetPresenceMethod = DynamicAPIProvider.RequestAPIMethod<Action<string, DateTime?, DateTime?, bool>>("Bannerlord.DiscordRichPresence", "SetPresence"); private static readonly Action<bool>? SetPreviousPresenceMethod = DynamicAPIProvider.RequestAPIMethod<Action<bool>>("Bannerlord.DiscordRichPresence", "SetPreviousPresence"); public static void SetPresence(string details, DateTime? start, DateTime? end) { if (SetPresenceMethod != null) { SetPresenceMethod(details, start, end, true); } } public static void SetPreviousPresence() { if (SetPreviousPresenceMethod != null) { SetPreviousPresence(true); } } }
Reflection and Harmony
internal static class DiscordRichPresenceAPI { private static readonly Action<string, DateTime?, DateTime?, bool>? SetPresenceMethod = AccessTools.Method("Bannerlord.DiscordRichPresence:SetPresence") is { } method ? AccessTools.MethodDelegate<Action<string, DateTime?, DateTime?, bool>>(method) : null; private static readonly Action<bool>? SetPreviousPresenceMethod = AccessTools.Method("Bannerlord.DiscordRichPresence:SetPreviousPresence") is { } method ? AccessTools.MethodDelegate<Action<bool>>(method) : null; public static void SetPresence(string details, DateTime? start, DateTime? end) { if (SetPresenceMethod != null) { SetPresenceMethod(details, start, end, true); } } public static void SetPreviousPresence() { if (SetPreviousPresenceMethod != null) { SetPreviousPresence(true); } } }
Popular Discussions View All (1)
3
3 Mar, 2023 @ 11:15am
Discord Rich Presence Ideas
Pinkie Arg
19 Comments
Oh for Fox Sake 25 Feb @ 6:06pm 
Found the crash! *Delete*
Cyphero7 26 Jan @ 2:19am 
Update please ... v1.2.12 instant crash at start
Caldery 28 Oct, 2024 @ 4:27pm 
@Pinkie Arg Personally not getting crashes (only tested loading and starting campaign since those are the main 2 complaints) so its likely either outdated versions/people not resubbing to mods when they update or a mod conflict that I don't have despite using a moderate mod list
wf1675 3 Jul, 2024 @ 11:57pm 
getting crashes :P
BloodSkals 24 Dec, 2023 @ 1:49pm 
I confirm this makes the game crash on V1.2.7
Spooky Foosh 11 Oct, 2023 @ 3:03pm 
Still causes crashes on current release, no other mods enabled
EdwinVonKalckreuth 24 Jul, 2023 @ 10:39am 
Game crashes whenever I am trying to start a campaign, no other mods enables current lates release
Emrun 4 Jul, 2023 @ 1:33pm 
Game version 1.1.5.21456 Game crashes when starting campaign
Pinkie Arg  [author] 2 Jul, 2023 @ 11:44am 
Again, where does it crash? What game version? Is a crash report available?
soupKitchen 1 Jul, 2023 @ 8:54pm 
great idea but sadly it still crashes after update. is there a certain load order you recommend