Socket
Socket
Sign inDemoInstall

@puyodead1/discord-game

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @puyodead1/discord-game

The Discord Game SDK for Electron.js


Version published
Maintainers
1
Created

Readme

Source

Discord Game SDK

Node CI Status FOSSA Status

This is node.js module for Electron to integrate with Discord.

Requirements

  • Node.js 11+
  • Electron 6.0+

Windows Setup

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.

Usage

Before using this module, you have to go to Discord Developer to create an application.

Discord

create()

Initialize Discord.

const Discord = require('discord-game');

const isRequireDiscord = true;
Discord.create('Client ID', isRequireDiscord);
// => true
version

Get Discord Game SDK Version

runCallback()

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)

Application

locale

Get the current locale

branch

Get the current branch

getOAuth2Token()

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)

Activity (aka Rich Presence)

update

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)

License

FOSSA Status

Keywords

FAQs

Last updated on 27 Jul 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc