mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-17 17:25:19 +01:00
Add discord protocol
This commit is contained in:
parent
211c2d1635
commit
8ad0fbc87b
3 changed files with 42 additions and 1 deletions
|
@ -159,6 +159,7 @@ Games List
|
|||
| `devastation` | Devastation (2003)
|
||||
| `dinodday` | Dino D-Day (2011)
|
||||
| `dirttrackracing2` | Dirt Track Racing 2 (2002)
|
||||
| `discord` | Discord | [Notes](#discord)
|
||||
| `doom3` | Doom 3 (2004)
|
||||
| `dota2` | Dota 2 (2013)
|
||||
| `drakan` | Drakan: Order of the Flame (1999)
|
||||
|
@ -451,6 +452,10 @@ For teamspeak 3 queries to work correctly, the following permissions must be ava
|
|||
Requires tshock server mod, and a REST user token, which can be passed to GameDig with the
|
||||
additional option: token
|
||||
|
||||
### Discord
|
||||
You must set host to the server's guild ID instead of IP, this can be found in server widget settings (Server ID) or by enabling developer mode in client settings and right-clicking the server's icon.
|
||||
In order to retrieve information from discord server's they must have the Enable server widget option enabled.
|
||||
|
||||
Usage from Command Line
|
||||
---
|
||||
|
||||
|
@ -547,7 +552,7 @@ Changelog
|
|||
|
||||
##### Breaking API changes
|
||||
* **Node 8 is now required**
|
||||
* Removed the `port_query` option. You can now pass either the server's game port **or** query port in the `port` option, and
|
||||
* Removed the `port_query` option. You can now pass either the server's game port **or** query port in the `port` option, and
|
||||
GameDig will automatically discover the proper port to query. Passing the query port is more likely be successful in
|
||||
unusual cases, as otherwise it must be automatically derived from the game port.
|
||||
* Removed `callback` parameter from Gamedig.query. Only promises are now supported. If you would like to continue
|
||||
|
|
|
@ -87,6 +87,7 @@ deusex|Deus Ex (2000)|gamespy2|port=7791,port_query_offset=1
|
|||
devastation|Devastation (2003)|unreal2|port=7777,port_query_offset=1
|
||||
dinodday|Dino D-Day (2011)|valve|port=27015
|
||||
dirttrackracing2|Dirt Track Racing 2 (2002)|gamespy1|port=32240,port_query_offset=-100
|
||||
discord|Discord|discord|port=443
|
||||
dnl|Dark and Light (2017)|valve|port=7777,port_query=27015
|
||||
dod|Day of Defeat (2003)|valve|port=27015
|
||||
dods|Day of Defeat: Source (2005)|valve|port=27015
|
||||
|
|
35
protocols/discord.js
Normal file
35
protocols/discord.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
const Core = require('./core');
|
||||
|
||||
class Discord extends Core {
|
||||
constructor() {
|
||||
super();
|
||||
this.dnsResolver = { resolve: function(address) {return {address: address} } };
|
||||
}
|
||||
|
||||
async run(state) {
|
||||
console.log('SENDING HTTP Request');
|
||||
this.usedTcp = true;
|
||||
console.log(this.options);
|
||||
const raw = await this.request({
|
||||
uri: 'https://discordapp.com/api/guilds/' + this.options.address + '/widget.json',
|
||||
});
|
||||
const json = JSON.parse(raw);
|
||||
state.name = json.name;
|
||||
if (json.instant_invite) {
|
||||
state.connect = json.instant_invite;
|
||||
} else {
|
||||
state.connect = 'https://discordapp.com/channels/' + this.options.address
|
||||
}
|
||||
state.players = json.members.map(v => {
|
||||
return {
|
||||
name: v.username + '#' + v.discriminator,
|
||||
username: v.username,
|
||||
discriminator: v.discriminator,
|
||||
team: v.status
|
||||
}
|
||||
});
|
||||
state.raw = json;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Discord;
|
Loading…
Reference in a new issue