mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
Suppor string game updates and better setStatus logic
This commit is contained in:
5687
ref/gameMap.js
5687
ref/gameMap.js
File diff suppressed because it is too large
Load Diff
@@ -824,31 +824,33 @@ export default class InternalClient {
|
||||
}
|
||||
|
||||
//def setStatus
|
||||
setStatus(idleStatus, gameID) {
|
||||
setStatus(idleStatus, game) {
|
||||
|
||||
this.idleStatus = idleStatus || this.idleStatus || null;
|
||||
if(idleStatus){
|
||||
if(idleStatus === "online" || idleStatus === "here" || idleStatus === "available"){
|
||||
this.idleStatus = null;
|
||||
}
|
||||
else if (this.idleStatus === "idle" || this.idleStatus === "away") {
|
||||
packet.d.idle_since = Date.now();
|
||||
}
|
||||
this.gameID = this.resolver.resolveGameID(gameID) || this.gameID || null;
|
||||
else {
|
||||
this.idleStatus = this.idleStatus || null; //undefineds
|
||||
}
|
||||
|
||||
this.game = game === null ? null : game || this.game;
|
||||
|
||||
var packet = {
|
||||
op: 3,
|
||||
d: {
|
||||
idle_since: this.idleStatus,
|
||||
game_id: this.gameID
|
||||
game: {
|
||||
name: this.game
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (this.idleStatus === "idle" || this.idleStatus === "away") {
|
||||
packet.d.idle_since = Date.now();
|
||||
}
|
||||
|
||||
this.sendWS(packet);
|
||||
|
||||
return Promise.resolve();//why?
|
||||
return Promise.resolve();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,28 +12,12 @@ import PMChannel from "../../Structures/PMChannel";
|
||||
import Server from "../../Structures/Server";
|
||||
import Message from "../../Structures/Message";
|
||||
import Invite from "../../Structures/Invite";
|
||||
import Games from "../../../ref/gameMap";
|
||||
|
||||
export default class Resolver {
|
||||
constructor(internal) {
|
||||
this.internal = internal;
|
||||
}
|
||||
|
||||
resolveGameID(resource) {
|
||||
if (!isNaN(resource) && parseInt(resource) % 1 === 0) {
|
||||
return resource;
|
||||
}
|
||||
if (typeof resource === "string" || resource instanceof String) {
|
||||
var gameName = resource.toLowerCase();
|
||||
var found = Games.find(game => game.name.toLowerCase() === gameName);
|
||||
if(found) {
|
||||
return found.id;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
resolveToBase64(resource) {
|
||||
if (resource instanceof Buffer) {
|
||||
resource = resource.toString("base64");
|
||||
|
||||
Reference in New Issue
Block a user