Code quality improvements.

This commit is contained in:
Holly Stubbs 2023-10-04 12:28:47 +01:00
parent 93da399fa5
commit 686e6001b2
12 changed files with 316 additions and 303 deletions

View file

@ -81,8 +81,6 @@ setInterval(() => {
} }
}, 10000); }, 10000);
const EMPTY_BUFFER = Buffer.alloc(0);
export default async function HandleRequest(req:IncomingMessage, res:ServerResponse, packet:Buffer) { export default async function HandleRequest(req:IncomingMessage, res:ServerResponse, packet:Buffer) {
// Get the client's token string and request data // Get the client's token string and request data
const requestTokenString = typeof(req.headers["osu-token"]) === "string" ? req.headers["osu-token"] : undefined; const requestTokenString = typeof(req.headers["osu-token"]) === "string" ? req.headers["osu-token"] : undefined;
@ -94,7 +92,7 @@ export default async function HandleRequest(req:IncomingMessage, res:ServerRespo
await LoginProcess(req, res, packet, shared); await LoginProcess(req, res, packet, shared);
shared.database.query("UPDATE osu_info SET value = ? WHERE name = 'online_now'", [shared.users.getLength() - 1]); shared.database.query("UPDATE osu_info SET value = ? WHERE name = 'online_now'", [shared.users.getLength() - 1]);
} else { } else {
let responseData = EMPTY_BUFFER; let responseData = Buffer.allocUnsafe(0);
// Client has a token, let's see what they want. // Client has a token, let's see what they want.
try { try {

View file

@ -1,269 +1,261 @@
enum CountryCodes { const countryCodes:{ [id: string]: number } = {
LV = 132, "LV": 132,
AD = 3, "AD": 3,
LT = 130, "LT": 130,
KM = 116, "KM": 116,
QA = 182, "QA": 182,
VA = 0, "VA": 0,
PK = 173, "PK": 173,
KI = 115, "KI": 115,
SS = 0, "SS": 0,
KH = 114, "KH": 114,
NZ = 166, "NZ": 166,
TO = 215, "TO": 215,
KZ = 122, "KZ": 122,
BW = 35, "BW": 35,
GA = 76, "GA": 76,
AX = 247, "AX": 247,
GE = 79, "GE": 79,
UA = 222, "UA": 222,
CR = 50, "CR": 50,
AE = 0, "AE": 0,
NE = 157, "NE": 157,
ZA = 240, "ZA": 240,
SK = 196, "SK": 196,
BV = 34, "BV": 34,
SH = 0, "SH": 0,
PT = 179, "PT": 179,
SC = 189, "SC": 189,
CO = 49, "CO": 49,
GP = 86, "GP": 86,
GY = 93, "GY": 93,
CM = 47, "CM": 47,
TJ = 211, "TJ": 211,
AF = 5, "AF": 5,
IE = 101, "IE": 101,
AL = 8, "AL": 8,
BG = 24, "BG": 24,
JO = 110, "JO": 110,
MU = 149, "MU": 149,
PM = 0, "PM": 0,
LA = 0, "LA": 0,
IO = 104, "IO": 104,
KY = 121, "KY": 121,
SA = 187, "SA": 187,
KN = 0, "KN": 0,
OM = 167, "OM": 167,
CY = 54, "CY": 54,
BQ = 0, "BQ": 0,
BT = 33, "BT": 33,
WS = 236, "WS": 236,
ES = 67, "ES": 67,
LR = 128, "LR": 128,
RW = 186, "RW": 186,
AQ = 12, "AQ": 12,
PW = 180, "PW": 180,
JE = 250, "JE": 250,
TN = 214, "TN": 214,
ZW = 243, "ZW": 243,
JP = 111, "JP": 111,
BB = 20, "BB": 20,
VN = 233, "VN": 233,
HN = 96, "HN": 96,
KP = 0, "KP": 0,
WF = 235, "WF": 235,
EC = 62, "EC": 62,
HU = 99, "HU": 99,
GF = 80, "GF": 80,
GQ = 87, "GQ": 87,
TW = 220, "TW": 220,
MC = 135, "MC": 135,
BE = 22, "BE": 22,
PN = 176, "PN": 176,
SZ = 205, "SZ": 205,
CZ = 55, "CZ": 55,
LY = 0, "LY": 0,
IN = 103, "IN": 103,
FM = 0, "FM": 0,
PY = 181, "PY": 181,
PH = 172, "PH": 172,
MN = 142, "MN": 142,
GG = 248, "GG": 248,
CC = 39, "CC": 39,
ME = 242, "ME": 242,
DO = 60, "DO": 60,
KR = 0, "KR": 0,
PL = 174, "PL": 174,
MT = 148, "MT": 148,
MM = 141, "MM": 141,
AW = 17, "AW": 17,
MV = 150, "MV": 150,
BD = 21, "BD": 21,
NR = 164, "NR": 164,
AT = 15, "AT": 15,
GW = 92, "GW": 92,
FR = 74, "FR": 74,
LI = 126, "LI": 126,
CF = 41, "CF": 41,
DZ = 61, "DZ": 61,
MA = 134, "MA": 134,
VG = 0, "VG": 0,
NC = 156, "NC": 156,
IQ = 105, "IQ": 105,
BN = 0, "BN": 0,
BF = 23, "BF": 23,
BO = 30, "BO": 30,
GB = 77, "GB": 77,
CU = 51, "CU": 51,
LU = 131, "LU": 131,
YT = 238, "YT": 238,
NO = 162, "NO": 162,
SM = 198, "SM": 198,
GL = 83, "GL": 83,
IS = 107, "IS": 107,
AO = 11, "AO": 11,
MH = 138, "MH": 138,
SE = 191, "SE": 191,
ZM = 241, "ZM": 241,
FJ = 70, "FJ": 70,
SL = 197, "SL": 197,
CH = 43, "CH": 43,
RU = 0, "RU": 0,
CW = 0, "CW": 0,
CX = 53, "CX": 53,
TF = 208, "TF": 208,
NL = 161, "NL": 161,
AU = 16, "AU": 16,
FI = 69, "FI": 69,
MS = 147, "MS": 147,
GH = 81, "GH": 81,
BY = 36, "BY": 36,
IL = 102, "IL": 102,
VC = 0, "VC": 0,
NG = 159, "NG": 159,
HT = 98, "HT": 98,
LS = 129, "LS": 129,
MR = 146, "MR": 146,
YE = 237, "YE": 237,
MP = 144, "MP": 144,
SX = 0, "SX": 0,
RE = 183, "RE": 183,
RO = 184, "RO": 184,
NP = 163, "NP": 163,
CG = 0, "CG": 0,
FO = 73, "FO": 73,
CI = 0, "CI": 0,
TH = 210, "TH": 210,
HK = 94, "HK": 94,
TK = 212, "TK": 212,
XK = 0, "XK": 0,
DM = 59, "DM": 59,
LC = 0, "LC": 0,
ID = 100, "ID": 100,
MG = 137, "MG": 137,
JM = 109, "JM": 109,
IT = 108, "IT": 108,
CA = 38, "CA": 38,
TZ = 221, "TZ": 221,
GI = 82, "GI": 82,
KG = 113, "KG": 113,
NU = 165, "NU": 165,
TV = 219, "TV": 219,
LB = 124, "LB": 124,
SY = 0, "SY": 0,
PR = 177, "PR": 177,
NI = 160, "NI": 160,
KE = 112, "KE": 112,
MO = 0, "MO": 0,
SR = 201, "SR": 201,
VI = 0, "VI": 0,
SV = 203, "SV": 203,
HM = 0, "HM": 0,
CD = 0, "CD": 0,
BI = 26, "BI": 26,
BM = 28, "BM": 28,
MW = 151, "MW": 151,
TM = 213, "TM": 213,
GT = 90, "GT": 90,
AG = 0, "AG": 0,
UM = 0, "UM": 0,
US = 225, "US": 225,
AR = 13, "AR": 13,
DJ = 57, "DJ": 57,
KW = 120, "KW": 120,
MY = 153, "MY": 153,
FK = 71, "FK": 71,
EG = 64, "EG": 64,
BA = 0, "BA": 0,
CN = 48, "CN": 48,
GN = 85, "GN": 85,
PS = 178, "PS": 178,
SO = 200, "SO": 200,
IM = 249, "IM": 249,
GS = 0, "GS": 0,
BR = 31, "BR": 31,
GM = 84, "GM": 84,
PF = 170, "PF": 170,
PA = 168, "PA": 168,
PG = 171, "PG": 171,
BH = 25, "BH": 25,
TG = 209, "TG": 209,
GU = 91, "GU": 91,
CK = 45, "CK": 45,
MF = 252, "MF": 252,
VE = 230, "VE": 230,
CL = 46, "CL": 46,
TR = 217, "TR": 217,
UG = 223, "UG": 223,
GD = 78, "GD": 78,
TT = 218, "TT": 218,
TL = 0, "TL": 0,
MD = 0, "MD": 0,
MK = 0, "MK": 0,
ST = 202, "ST": 202,
CV = 52, "CV": 52,
MQ = 145, "MQ": 145,
GR = 88, "GR": 88,
HR = 97, "HR": 97,
BZ = 37, "BZ": 37,
UZ = 227, "UZ": 227,
DK = 58, "DK": 58,
SN = 199, "SN": 199,
ET = 68, "ET": 68,
VU = 234, "VU": 234,
ER = 66, "ER": 66,
BJ = 27, "BJ": 27,
LK = 127, "LK": 127,
NA = 155, "NA": 155,
AS = 14, "AS": 14,
SG = 192, "SG": 192,
PE = 169, "PE": 169,
IR = 0, "IR": 0,
MX = 152, "MX": 152,
TD = 207, "TD": 207,
AZ = 18, "AZ": 18,
AM = 9, "AM": 9,
BL = 0, "BL": 0,
SJ = 195, "SJ": 195,
SB = 188, "SB": 188,
NF = 158, "NF": 158,
RS = 239, "RS": 239,
DE = 56, "DE": 56,
EH = 65, "EH": 65,
EE = 63, "EE": 63,
SD = 190, "SD": 190,
ML = 140, "ML": 140,
TC = 206, "TC": 206,
MZ = 154, "MZ": 154,
BS = 32, "BS": 32,
UY = 226, "UY": 226,
SI = 194, "SI": 194,
AI = 7 "AI": 7
} };
const keys = Object.keys(CountryCodes); // Get id of a country from a 2 char code
const values = Object.values(CountryCodes); export function getCountryID(code:string) : number {
const upperCode = code.toUpperCase();
export default function getCountryID(code:string) : number { if (upperCode in countryCodes) {
// Get id of a country from a 2 char code return countryCodes[upperCode];
const upperCode:string = code.toUpperCase();
if (upperCode in CountryCodes) {
const code = values[keys.indexOf(upperCode)];
if (typeof(code) === "string") {
return 0;
}
return code;
} }
return 0; return 0;

View file

@ -1,6 +1,6 @@
import { ConsoleHelper } from "../ConsoleHelper"; import { ConsoleHelper } from "../ConsoleHelper";
import fetch from "node-fetch"; import fetch from "node-fetch";
import getCountryID from "./Country"; import { getCountryID } from "./Country";
import { generateSession } from "./Util"; import { generateSession } from "./Util";
import LatLng from "./objects/LatLng"; import LatLng from "./objects/LatLng";
import LoginInfo from "./objects/LoginInfo"; import LoginInfo from "./objects/LoginInfo";
@ -14,6 +14,7 @@ import Shared from "./objects/Shared";
import osu from "../osuTyping"; import osu from "../osuTyping";
import IpZxqResponse from "./interfaces/IpZxqResponse"; import IpZxqResponse from "./interfaces/IpZxqResponse";
import { IncomingMessage, ServerResponse } from "http"; import { IncomingMessage, ServerResponse } from "http";
import UserInfo from "./objects/database/UserInfo";
const { decrypt: aesDecrypt } = require("aes256"); const { decrypt: aesDecrypt } = require("aes256");
const incorrectLoginResponse:Buffer = osu.Bancho.Writer().LoginReply(-1).toBuffer; const incorrectLoginResponse:Buffer = osu.Bancho.Writer().LoginReply(-1).toBuffer;
@ -36,7 +37,7 @@ enum LoginResult {
function TestLogin(loginInfo:LoginInfo, shared:Shared) { function TestLogin(loginInfo:LoginInfo, shared:Shared) {
return new Promise<LoginResult>(async (resolve, reject) => { return new Promise<LoginResult>(async (resolve, reject) => {
const userDBData:any = await shared.database.query("SELECT * FROM users_info WHERE username = ? LIMIT 1", [loginInfo.username]); const userDBData:UserInfo = await shared.database.query("SELECT * FROM users_info WHERE username = ? LIMIT 1", [loginInfo.username]);
// Make sure a user was found in the database // Make sure a user was found in the database
if (userDBData == null) return resolve(LoginResult.INCORRECT); if (userDBData == null) return resolve(LoginResult.INCORRECT);
@ -122,7 +123,7 @@ export default async function LoginProcess(req:IncomingMessage, res:ServerRespon
} }
// Get information about the user from the database // Get information about the user from the database
const userDB = await shared.database.query("SELECT id FROM users_info WHERE username = ? LIMIT 1", [loginInfo.username]); const userId:number = (await shared.database.query("SELECT id FROM users_info WHERE username = ? LIMIT 1", [loginInfo.username])).id;
// Create a token for the client // Create a token for the client
const newClientToken:string = await generateSession(); const newClientToken:string = await generateSession();
@ -135,7 +136,7 @@ export default async function LoginProcess(req:IncomingMessage, res:ServerRespon
} }
// Retreive the newly created user // Retreive the newly created user
newUser = shared.users.add(newClientToken, new User(userDB.id, loginInfo.username, newClientToken, shared)); newUser = shared.users.add(newClientToken, new User(userId, loginInfo.username, newClientToken, shared));
// Set tourney client flag // Set tourney client flag
newUser.isTourneyUser = isTourneyClient; newUser.isTourneyUser = isTourneyClient;
newUser.location = userLocation; newUser.location = userLocation;
@ -203,7 +204,7 @@ export default async function LoginProcess(req:IncomingMessage, res:ServerRespon
const writerBuffer:Buffer = osuPacketWriter.toBuffer; const writerBuffer:Buffer = osuPacketWriter.toBuffer;
if (newUser === undefined) { if (newUser === undefined) {
res.writeHead(200, { res.writeHead(200, {
"cho-token": "no", "cho-token": "no", // NOTE: You have to specify a token even if it's an incorrect login for some reason.
"Connection": "keep-alive", "Connection": "keep-alive",
"Keep-Alive": "timeout=5, max=100" "Keep-Alive": "timeout=5, max=100"
}); });

View file

@ -14,6 +14,6 @@ export default class BaseCommand implements ICommand {
} }
public exec(channel:Channel, sender:User, args:Array<string>) { public exec(channel:Channel, sender:User, args:Array<string>) {
channel.SendBotMessage(`Sorry ${sender.username}! This command has no functionality yet. Args: ["${args.join('", "')}"]`);
} }
} }

View file

@ -6,8 +6,7 @@ import BaseCommand from "./BaseCommand";
export default class MultiplayerCommands extends BaseCommand { export default class MultiplayerCommands extends BaseCommand {
public readonly helpText:string = `Multiplayer Subcommands: public readonly helpText:string = `Multiplayer Subcommands:
!mp start - Starts a multiplayer match with a delay (optional) !mp start - Starts a multiplayer match with a delay (optional)
!mp abort - Aborts the currently running round / countdown !mp abort - Aborts the currently running round / countdown`;
!mp obr - Toggles Battle Royale mode`;
public readonly helpDescription:string = "Command for use in multiplayer matches."; public readonly helpDescription:string = "Command for use in multiplayer matches.";
public readonly helpArguments:Array<string> = ["subCommand"]; public readonly helpArguments:Array<string> = ["subCommand"];
@ -36,9 +35,6 @@ export default class MultiplayerCommands extends BaseCommand {
case "abort": case "abort":
return mpAbort(channel, sender.match); return mpAbort(channel, sender.match);
case "obr":
return mpOBR(channel, sender.match);
} }
} }
} }
@ -90,7 +86,3 @@ function mpAbort(channel:Channel, match:Match) {
channel.SendBotMessage("Aborted current round"); channel.SendBotMessage("Aborted current round");
} }
} }
function mpOBR(channel:Channel, match:Match) {
}

View file

@ -1,5 +1,7 @@
import MatchData from "./MatchData" import MatchData from "./MatchData"
import MatchScoreData from "./MatchScoreData"
import MessageData from "./MessageData" import MessageData from "./MessageData"
import StatusUpdateData from "./StatusUpdateData"
export default interface OsuPacketWriter { export default interface OsuPacketWriter {
// Functions // Functions
@ -9,7 +11,7 @@ export default interface OsuPacketWriter {
Ping() : OsuPacketWriter, Ping() : OsuPacketWriter,
HandleIrcChangeUsername(data:any) : OsuPacketWriter, HandleIrcChangeUsername(data:any) : OsuPacketWriter,
HandleIrcQuit() : OsuPacketWriter, HandleIrcQuit() : OsuPacketWriter,
HandleOsuUpdate(data:any) : OsuPacketWriter, HandleOsuUpdate(data:StatusUpdateData) : OsuPacketWriter,
HandleUserQuit(data:any) : OsuPacketWriter, HandleUserQuit(data:any) : OsuPacketWriter,
SpectatorJoined(data:any) : OsuPacketWriter, SpectatorJoined(data:any) : OsuPacketWriter,
SpectatorLeft(data:any) : OsuPacketWriter, SpectatorLeft(data:any) : OsuPacketWriter,
@ -19,14 +21,14 @@ export default interface OsuPacketWriter {
GetAttention() : OsuPacketWriter, GetAttention() : OsuPacketWriter,
Announce(data:string) : OsuPacketWriter, Announce(data:string) : OsuPacketWriter,
MatchUpdate(data:MatchData) : OsuPacketWriter, MatchUpdate(data:MatchData) : OsuPacketWriter,
MatchNew(data:any) : OsuPacketWriter, MatchNew(data:MatchData) : OsuPacketWriter,
MatchDisband(data:any) : OsuPacketWriter, MatchDisband(data:any) : OsuPacketWriter,
MatchJoinSuccess(data:any) : OsuPacketWriter, MatchJoinSuccess(data:MatchData) : OsuPacketWriter,
MatchJoinFail() : OsuPacketWriter, MatchJoinFail() : OsuPacketWriter,
FellowSpectatorJoined(data:any) : OsuPacketWriter, FellowSpectatorJoined(data:number) : OsuPacketWriter,
FellowSpectatorLeft(data:any) : OsuPacketWriter, FellowSpectatorLeft(data:number) : OsuPacketWriter,
MatchStart(data:any) : OsuPacketWriter, MatchStart(data:MatchData) : OsuPacketWriter,
MatchScoreUpdate(data:any) : OsuPacketWriter, MatchScoreUpdate(data:MatchScoreData) : OsuPacketWriter,
MatchTransferHost(data:any) : OsuPacketWriter, MatchTransferHost(data:any) : OsuPacketWriter,
MatchAllPlayersLoaded() : OsuPacketWriter, MatchAllPlayersLoaded() : OsuPacketWriter,
MatchPlayerFailed(data:any) : OsuPacketWriter, MatchPlayerFailed(data:any) : OsuPacketWriter,
@ -43,9 +45,9 @@ export default interface OsuPacketWriter {
ProtocolNegotiation(data:number) : OsuPacketWriter, ProtocolNegotiation(data:number) : OsuPacketWriter,
TitleUpdate(data:string) : OsuPacketWriter, TitleUpdate(data:string) : OsuPacketWriter,
Monitor() : OsuPacketWriter, Monitor() : OsuPacketWriter,
MatchPlayerSkipped(data:any) : OsuPacketWriter, MatchPlayerSkipped(data:number) : OsuPacketWriter,
UserPresence(data:any) : OsuPacketWriter, UserPresence(data:any) : OsuPacketWriter,
Restart(data:any) : OsuPacketWriter, Restart(data:number) : OsuPacketWriter,
Invite(data:any) : OsuPacketWriter, Invite(data:any) : OsuPacketWriter,
ChannelListingComplete() : OsuPacketWriter, ChannelListingComplete() : OsuPacketWriter,
MatchChangePassword(data:any) : OsuPacketWriter, MatchChangePassword(data:any) : OsuPacketWriter,
@ -58,7 +60,7 @@ export default interface OsuPacketWriter {
VersionUpdateForced() : OsuPacketWriter, VersionUpdateForced() : OsuPacketWriter,
SwitchServer(data:any) : OsuPacketWriter, SwitchServer(data:any) : OsuPacketWriter,
AccountRestricted() : OsuPacketWriter, AccountRestricted() : OsuPacketWriter,
RTX(data:any) : OsuPacketWriter, RTX(data:string) : OsuPacketWriter,
SwitchTourneyServer(data:any) : OsuPacketWriter SwitchTourneyServer(data:any) : OsuPacketWriter
toBuffer : Buffer toBuffer : Buffer

View file

@ -0,0 +1,8 @@
export default interface PresenceData {
status: number,
statusText: string,
beatmapId: number,
beatmapChecksum: string,
currentMods: number,
playMode: number,
}

View file

@ -0,0 +1,15 @@
export default interface StatusUpdateData {
userId: number,
status: number,
statusText: string,
beatmapChecksum: string,
currentMods: number,
playMode: number,
beatmapId: number,
rankedScore: number,
accuracy: number,
playCount: number,
totalScore: number,
rank: number,
performance: number
}

View file

@ -1,5 +1,5 @@
export default class FunkyArray<T> { export default class FunkyArray<T> {
private items:any = {}; private items:{ [id: string]: T } = {};
private itemKeys:Array<string> = Object.keys(this.items); private itemKeys:Array<string> = Object.keys(this.items);
private iterableArray:Array<T> = new Array<T>(); private iterableArray:Array<T> = new Array<T>();

View file

@ -397,11 +397,16 @@ export default class Match {
allSkipped = false; allSkipped = false;
} }
const slotId = user.matchSlot?.slotId ?? Number.MIN_VALUE;
if (slotId === Number.MIN_VALUE) {
return;
}
// All players have finished playing, finish the match // All players have finished playing, finish the match
if (allSkipped) { if (allSkipped) {
const osuPacketWriter = osu.Bancho.Writer(); const osuPacketWriter = osu.Bancho.Writer();
osuPacketWriter.MatchPlayerSkipped(user.id); osuPacketWriter.MatchPlayerSkipped(slotId);
osuPacketWriter.MatchSkip(); osuPacketWriter.MatchSkip();
this.matchStream.Send(osuPacketWriter.toBuffer); this.matchStream.Send(osuPacketWriter.toBuffer);
@ -410,7 +415,7 @@ export default class Match {
} else { } else {
const osuPacketWriter = osu.Bancho.Writer(); const osuPacketWriter = osu.Bancho.Writer();
osuPacketWriter.MatchPlayerSkipped(user.id); osuPacketWriter.MatchPlayerSkipped(slotId);
this.matchStream.Send(osuPacketWriter.toBuffer); this.matchStream.Send(osuPacketWriter.toBuffer);
} }
@ -593,7 +598,7 @@ export default class Match {
const osuPacketWriter = osu.Bancho.Writer(); const osuPacketWriter = osu.Bancho.Writer();
let queryData:Array<any> = [ const queryData:Array<string | number | null> = [
this.matchId, this.matchId,
this.roundId++, this.roundId++,
this.playMode, this.playMode,

View file

@ -6,6 +6,7 @@ import StatusUpdate from "../packets/StatusUpdate";
import Shared from "../objects/Shared"; import Shared from "../objects/Shared";
import Slot from "./Slot"; import Slot from "./Slot";
import Channel from "./Channel"; import Channel from "./Channel";
import PresenceData from "../interfaces/PresenceData";
const rankingModes = [ const rankingModes = [
"pp_raw", "pp_raw",
@ -14,8 +15,6 @@ const rankingModes = [
]; ];
export default class User { export default class User {
private static readonly EMPTY_BUFFER = Buffer.alloc(0);
public shared:Shared; public shared:Shared;
public id:number; public id:number;
@ -23,7 +22,7 @@ export default class User {
public uuid:string; public uuid:string;
public readonly connectTime:number = Date.now(); public readonly connectTime:number = Date.now();
public timeoutTime:number = Date.now() + 30000; public timeoutTime:number = Date.now() + 30000;
public queue:Buffer = User.EMPTY_BUFFER; public queue:Buffer = Buffer.allocUnsafe(0);
// Binato data // Binato data
public rankingMode:RankingModes = RankingModes.PP; public rankingMode:RankingModes = RankingModes.PP;
@ -80,11 +79,11 @@ export default class User {
} }
clearQueue() { clearQueue() {
this.queue = User.EMPTY_BUFFER; this.queue = Buffer.allocUnsafe(0);
} }
// Updates the user's current action // Updates the user's current action
updatePresence(action:any) { updatePresence(action:PresenceData) {
this.actionID = action.status; this.actionID = action.status;
this.actionText = action.statusText; this.actionText = action.statusText;
this.beatmapChecksum = action.beatmapChecksum; this.beatmapChecksum = action.beatmapChecksum;

View file

@ -1,7 +1,8 @@
import PresenceData from "../interfaces/PresenceData";
import User from "../objects/User"; import User from "../objects/User";
import StatusUpdate from "./StatusUpdate"; import StatusUpdate from "./StatusUpdate";
export default function ChangeAction(user:User, data:any) { export default function ChangeAction(user:User, data:PresenceData) {
user.updatePresence(data); user.updatePresence(data);
if (user.spectatorStream != null) { if (user.spectatorStream != null) {