Login into your Discord Developer account, create a new application. The application name will be the "Playing.." shown on Discord.
Each application has an Application ID, you will use it to initialize the Discord RPC Client.
Upload your assets: every image has a name, called "key" in Discord language. You can use any image as Large or Small image.
The RPC is composed of:
- Details
- State
- Large Image Key
- Large Image Text (shown as tooltip on hover)
- Small Image Key (shown on the bottom right corner of the Large Image)
- Small Image Text (shown as tooltip on hover)
Open the DiscordRPCPlugin.csproj
with Visual Studio 2019 (or newer), compile it, and copy DiscordRPCPlugin.dll, DiscordRPC.dll, and Newtonson.Json.dll
inside your app, for example, a plugins
directory.
This plugin uses discord-rpc-csharp to communicate with Discord.
The callback style is the same commonly used in the Overwolf API:
{ "success": bool, "status": "success|error" }
initialize(applicationID, logLevel, callback)
: Initialize the Discord RPC ClientonClientReady(callback)
: Fired when the RPC Client is ready, sends the current Discord UseronPresenceUpdate(callback)
: Fired when the RPC is updatedonClientError(callback)
: Fired when the RPC Client has errorsonLogLine(callback)
: Fired when a log line is receivedupdatePresence(details, state, largeImageKey, largeImageText, smallImageKey, smallImageText, showTimestamps, endTime, button1Text, button1Url, button2Text, button2Url, callback)
: Update the Rich PresenceupdatePresenceWithButtonsArray(details, state, largeImageKey, largeImageText, smallImageKey, smallImageText, showTimestamps, endTime, buttonsJson, callback)
: Update the Rich Presence with buttonsdispose(callback)
: Clear the Rich Presence and dispose the connection
TypeScript typings for the plugin are available in the types.ts file.
In manifest.json
, declare the plugin under the extra-objects
property:
"DiscordRPCPlugin": {
"file": "plugins/DiscordRPCPlugin.dll",
"class": "overwolf.plugins.DiscordRPCPlugin"
}
const discordRPCPlugin = await pluginService.getPlugin('DiscordRPCPlugin');
discordRPCPlugin.onClientReady.addListener(console.log);
discordRPCPlugin.onPresenceUpdate.addListener(console.log);
discordRPCPlugin.onClientError.addListener(console.error);
discordRPCPlugin.onLogLine.addListener(console.info);
discordRPCPlugin.initialize('YOUR APPLICATION ID', LogLevel.Info, console.log);
discordRPCPlugin.updatePresence('My Details', 'My state', 'large_image_key', 'Large image', 'small_image_key', 'Small image', true, 0, 'Button 1', 'https://button1.url', 'Button 2', 'https://button2.url', console.log);
const buttonsJson = '[{"label": "Button 1", "url": "https://button1.url"}, {"label": "Button 2", "url": "https://button2.url"}]';
discordRPCPlugin.updatePresenceWithButtonsArray('My Details', 'My state', 'large_image_key', 'Large image', 'small_image_key', 'Small image', true, 0, buttonsJson, console.log);
discordRPCPlugin.dispose(console.log);