This is node.js module for Electron to integrate with Discord.
- Node.js 11+
- Electron 6.0+
The Windows is required to add dll
to project root, please copy sdk\{ARCH}\discord_game_sdk.dll
to your project folder to ensure your Electron can access SDK correctly.
Before using this module, you have to go to Discord Developer to create an application.
Initialize Discord.
const Discord = require('discord-game');
const isRequireDiscord = true;
Discord.create('Client ID', isRequireDiscord);
// => true
Get Discord Game SDK Version
Resolve Discord's async behavior and call the callback;
const Discord = require('discord-game');
const isRequireDiscord = true;
Discord.create('Client ID', isRequireDiscord);
setInterval(function() {
Discord.runCallback(); // => true
}, 1000/60)
Get the current locale
Get the current branch
Get the user OAuth2 Token.
const Discord = require('discord-game');
const isRequireDiscord = true;
Discord.create('Client ID', isRequireDiscord);
Discord.Application
.getOAuth2Token()
.then(function(token) { console.log('Token is', token) });
setInterval(function() {
Discord.runCallback(); // => true
}, 1000/60)
Update user's rich presence.
const Discord = require('discord-game');
const isRequireDiscord = true;
Discord.create('Client ID', isRequireDiscord);
// All property are optional
const activity = {
details: 'Details',
state: 'State',
assets: {
largeImage: 'large',
largeText: 'Large',
samllImage: 'small',
smallText: 'Small'
},
timestamps: {
startAt: new Date(),
endAt: new Date()
},
secrets: {
match: 'match',
join: 'join',
spectate: 'spectate'
},
party: {
id: 'id',
currentSize: 1,
maxSize: 5
}
}
const start_at = new Date();
Discord.Activity
.update(activity)
.then(function() { console.log('Rich Presence updated') });
setInterval(function() {
Discord.runCallback(); // => true
}, 1000/60)
Clear user's rich presence.
Discord.Activity.clear()