Add discord protocol

This commit is contained in:
Tom 2020-01-04 01:03:02 +00:00
parent 211c2d1635
commit 8ad0fbc87b
No known key found for this signature in database
GPG key ID: 6A9F111228283C55
3 changed files with 42 additions and 1 deletions

View file

@ -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
---

View file

@ -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
View 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;