Skip to content

Commit

Permalink
Merge branch 'main' into pr/26
Browse files Browse the repository at this point in the history
  • Loading branch information
tnfAngel committed Jul 25, 2024
2 parents c78a0b3 + 219a446 commit f9a8e10
Show file tree
Hide file tree
Showing 34 changed files with 277 additions and 83 deletions.
6 changes: 3 additions & 3 deletions resources/PowerLevelCurves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function mapCurveTables<T extends { [k: keyof any]: { Keys: CurveKey[] } }>(stru
}

export default Object.freeze({
homebaseRating: Object.freeze(new CurveTable(HomebaseRatingMapping[0].ExportValue.UIMonsterRating.Keys)),
baseItemRating: mapCurveTables(BaseItemRating[0].ExportValue),
survivorItemRating: mapCurveTables(SurvivorItemRating[0].ExportValue),
homebaseRating: Object.freeze(new CurveTable(HomebaseRatingMapping[0]!.ExportValue.UIMonsterRating.Keys)),
baseItemRating: mapCurveTables(BaseItemRating[0]!.ExportValue),
survivorItemRating: mapCurveTables(SurvivorItemRating[0]!.ExportValue),
});
16 changes: 8 additions & 8 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ class Client extends EventEmitter {
* Timeouts set by {@link Client#setTimeout} that are still active
*/
// eslint-disable-next-line no-undef
private timeouts: Set<NodeJS.Timeout>;
private timeouts: Set<any>;

/**
* Intervals set by {@link Client#setInterval} that are still active
*/
// eslint-disable-next-line no-undef
private intervals: Set<NodeJS.Timeout>;
private intervals: Set<any>;

/**
* All client configuration options
Expand Down Expand Up @@ -228,15 +228,15 @@ class Client extends EventEmitter {
}

// Events
public on<U extends keyof ClientEvents>(event: U, listener: ClientEvents[U]): this {
public override on<U extends keyof ClientEvents>(event: U, listener: ClientEvents[U]): this {
return super.on(event, listener);
}

public once<U extends keyof ClientEvents>(event: U, listener: ClientEvents[U]): this {
public override once<U extends keyof ClientEvents>(event: U, listener: ClientEvents[U]): this {
return super.once(event, listener);
}

public emit<U extends keyof ClientEvents>(event: U, ...args: Parameters<ClientEvents[U]>): boolean {
public override emit<U extends keyof ClientEvents>(event: U, ...args: Parameters<ClientEvents[U]>): boolean {
return super.emit(event, ...args);
}

Expand Down Expand Up @@ -473,7 +473,7 @@ class Client extends EventEmitter {
): Promise<Parameters<ClientEvents[U]>> {
return new Promise<any>((res, rej) => {
// eslint-disable-next-line no-undef
let rejectionTimeout: NodeJS.Timeout;
let rejectionTimeout: any;

const handler = (...data: any) => {
if (!filter || filter(...data)) {
Expand Down Expand Up @@ -514,7 +514,7 @@ class Client extends EventEmitter {
* @param timeout Timeout to cancel
*/
// eslint-disable-next-line no-undef
public clearTimeout(timeout: NodeJS.Timeout) {
public clearTimeout(timeout: any) {
clearTimeout(timeout);
this.timeouts.delete(timeout);
}
Expand All @@ -537,7 +537,7 @@ class Client extends EventEmitter {
* @param interval Interval to cancel
*/
// eslint-disable-next-line no-undef
public clearInterval(interval: NodeJS.Timeout) {
public clearInterval(interval: any) {
clearInterval(interval);
this.intervals.delete(interval);
}
Expand Down
2 changes: 1 addition & 1 deletion src/auth/Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Auth extends Base {
* Kills all active auth sessions
*/
public async revokeAllTokens() {
await Promise.all([...this.sessions.filter((s, k) => k !== AuthSessionStoreKey.Launcher).values()].map((s) => s.revoke()));
await Promise.all([...this.sessions.filter((_s, k) => k !== AuthSessionStoreKey.Launcher).values()].map((s) => s.revoke()));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/auth/FortniteAuthSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FortniteAuthSession extends AuthSession<AuthSessionType.Fortnite> {
/**
* The refresh timeout
*/
public refreshTimeout?: NodeJS.Timeout;
public refreshTimeout?: any;
constructor(client: Client, data: FortniteAuthData, clientSecret: string) {
super(client, data, clientSecret, AuthSessionType.Fortnite);

Expand Down
2 changes: 1 addition & 1 deletion src/auth/FortniteClientCredentialsAuthSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class FortniteClientCredentialsAuthSession extends AuthSession<AuthSessionType.F
public isInternalClient: boolean;
public productId: string;
public applicationId: string;
public refreshTimeout?: NodeJS.Timeout;
public refreshTimeout?: any;
constructor(client: Client, data: FortniteClientCredentialsAuthData, clientSecret: string) {
super(client, data, clientSecret, AuthSessionType.FortniteClientCredentials);

Expand Down
2 changes: 1 addition & 1 deletion src/auth/LauncherAuthSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class LauncherAuthSession extends AuthSession<AuthSessionType.Launcher> {
public scope: string[];
public refreshToken: string;
public refreshTokenExpiresAt: Date;
public refreshTimeout?: NodeJS.Timeout;
public refreshTimeout?: any;
constructor(client: Client, data: LauncherAuthData, clientSecret: string) {
super(client, data, clientSecret, AuthSessionType.Launcher);

Expand Down
2 changes: 1 addition & 1 deletion src/exceptions/SendMessageError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SendMessageError extends Error {
/**
* The message related to this error
*/
public message: string;
public override message: string;

/**
* The message's type
Expand Down
6 changes: 3 additions & 3 deletions src/structures/EventTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class EventTokens extends Base {
season = 'S9';
}

const divisionNumber = parseInt(division.replace('Division', ''), 10);
const divisionNumber = parseInt(division!.replace('Division', ''), 10);

if (!this.arenaDivisionData[season.toLowerCase()] || this.arenaDivisionData[season.toLowerCase()] < divisionNumber) {
this.arenaDivisionData[season.toLowerCase()] = divisionNumber;
if (!this.arenaDivisionData[season!.toLowerCase()] || this.arenaDivisionData[season!.toLowerCase()]! < divisionNumber) {
this.arenaDivisionData[season!.toLowerCase()] = divisionNumber;
}
} break;
case 'GroupIdentity':
Expand Down
2 changes: 1 addition & 1 deletion src/structures/Image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Image extends Base {
return res;
}

public toString() {
public override toString() {
return this.url;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/structures/Stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Stats extends Base {
: this.getPlaylistStatsType(playlistId);

if (playlistType !== 'other') {
const [parsedKey, parsedValue] = parseStatKey(statKey, data.stats[key]);
const [parsedKey, parsedValue] = parseStatKey(statKey, data.stats[key]!);

const inputTypePlaylistStats = this.stats[inputType][playlistType];
const inputTypeAllStats = this.stats[inputType].overall;
Expand Down Expand Up @@ -105,9 +105,9 @@ class Stats extends Base {
}
}
} else if (/^s\d\d?_social_bp_level$/.test(key)) {
this.levelData[key.split('_')[0]] = {
level: Math.round(data.stats[key] / 100),
progress: data.stats[key] % 100,
this.levelData[key.split('_')[0]!] = {
level: Math.round(data.stats[key]! / 100),
progress: data.stats[key]! % 100,
};
}
}
Expand Down
17 changes: 15 additions & 2 deletions src/structures/friend/BaseFriendMessage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import BaseMessage from '../BaseMessage';
import type ClientUser from '../user/ClientUser';
import type Friend from './Friend';
import type Client from '../../Client';
import type { MessageData } from '../../../resources/structs';

/**
* Represents a friend whisper message
Expand All @@ -9,12 +11,23 @@ class BaseFriendMessage extends BaseMessage {
/**
* The message's content
*/
public content!: string;
public override content: string;

/**
* The message's author
*/
public author!: Friend | ClientUser;
public override author: Friend | ClientUser;

/**
* @param client The main client
* @param data The message's data
*/
constructor(client: Client, data: MessageData & { author: Friend | ClientUser; }) {
super(client, data);

this.content = data.content;
this.author = data.author;
}

/**
* Replies to this whisper message
Expand Down
16 changes: 14 additions & 2 deletions src/structures/friend/ReceivedFriendMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import BaseFriendMessage from './BaseFriendMessage';
import type Friend from './Friend';
import type Client from '../../Client';
import type { MessageData } from '../../../resources/structs';

/**
* Represents a received friend whisper message
Expand All @@ -8,14 +10,24 @@ class ReceivedFriendMessage extends BaseFriendMessage {
/**
* The message's author
*/
public author!: Friend;
public override author: Friend;

/**
* @param client The main client
* @param data The message's data
*/
constructor(client: Client, data: MessageData & { author: Friend; }) {
super(client, data);

this.author = data.author;
}

/**
* Replies to this whisper message
* @param content The message that will be sent
* @throws {FriendNotFoundError} The user is not friends with the client
*/
public reply(content: string) {
public override reply(content: string) {
return this.client.friend.sendMessage(this.author.id, content);
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/structures/friend/SentFriendMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import BaseFriendMessage from './BaseFriendMessage';
import type ClientUser from '../user/ClientUser';
import type Client from '../../Client';
import type { MessageData } from '../../../resources/structs';

/**
* Represents a sent friend whisper message
Expand All @@ -8,7 +10,17 @@ class SentFriendMessage extends BaseFriendMessage {
/**
* The message's author
*/
public author!: ClientUser;
public override author: ClientUser;

/**
* @param client The main client
* @param data The message's data
*/
constructor(client: Client, data: MessageData & { author: ClientUser; }) {
super(client, data);

this.author = data.author;
}
}

export default SentFriendMessage;
4 changes: 2 additions & 2 deletions src/structures/party/ClientParty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ClientParty extends Party {
/**
* The party's meta
*/
public meta: ClientPartyMeta;
public override meta: ClientPartyMeta;

/**
* The hidden member ids
Expand Down Expand Up @@ -144,7 +144,7 @@ class ClientParty extends Party {
}, AuthSessionStoreKey.Fortnite);
} catch (e) {
if (e instanceof EpicgamesAPIError && e.code === 'errors.com.epicgames.social.party.stale_revision') {
this.revision = parseInt(e.messageVars[1], 10);
this.revision = parseInt(e.messageVars[1]!, 10);
this.patchQueue.shift();
return this.sendPatch(updated);
}
Expand Down
4 changes: 2 additions & 2 deletions src/structures/party/ClientPartyMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ClientPartyMember extends PartyMember {
/**
* The member's meta
*/
public meta: ClientPartyMemberMeta;
public override meta: ClientPartyMemberMeta;

/**
* @param party The party this member belongs to
Expand Down Expand Up @@ -61,7 +61,7 @@ class ClientPartyMember extends PartyMember {
}, AuthSessionStoreKey.Fortnite);
} catch (e) {
if (e instanceof EpicgamesAPIError && e.code === 'errors.com.epicgames.social.party.stale_revision') {
this.revision = parseInt(e.messageVars[1], 10);
this.revision = parseInt(e.messageVars[1]!, 10);
this.patchQueue.shift();
return this.sendPatch(updated);
}
Expand Down
2 changes: 1 addition & 1 deletion src/structures/party/ClientPartyMemberMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ClientPartyMemberMeta extends PartyMemberMeta {
'Default:CampaignHero_j': JSON.stringify({
CampaignHero: {
heroItemInstanceId: '',
heroType: `/Game/Athena/Heroes/${defaultCharacter.replace('CID', 'HID')}.${defaultCharacter.replace('CID', 'HID')}`,
heroType: `/Game/Athena/Heroes/${defaultCharacter?.replace('CID', 'HID')}.${defaultCharacter?.replace('CID', 'HID')}`,
},
}),
'Default:PlatformData_j': JSON.stringify({
Expand Down
2 changes: 1 addition & 1 deletion src/structures/party/PartyMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class PartyMember extends User {
/**
* Converts this party member into an object
*/
public toObject(): PartyMemberData {
public override toObject(): PartyMemberData {
return {
id: this.id,
account_id: this.id,
Expand Down
3 changes: 2 additions & 1 deletion src/structures/party/PartyMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PartyMessage extends BaseMessage {
/**
* The message's author
*/
public author!: PartyMember;
public override author: PartyMember;

/**
* The message's party
Expand All @@ -25,6 +25,7 @@ class PartyMessage extends BaseMessage {
constructor(client: Client, data: PartyMessageData) {
super(client, data);

this.author = data.author;
this.party = data.party;
}

Expand Down
21 changes: 19 additions & 2 deletions src/structures/party/ReceivedPartyInvitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,30 @@ import BasePartyInvitation from './BasePartyInvitation';
import { AuthSessionStoreKey } from '../../../resources/enums';
import type ClientUser from '../user/ClientUser';
import type Friend from '../friend/Friend';
import type Client from '../../Client';
import type Party from './Party';
import type ClientParty from './ClientParty';

/**
* Represents a recieved party invitation
*/
class ReceivedPartyInvitation extends BasePartyInvitation {
public sender!: Friend;
public receiver!: ClientUser;
public override sender: Friend;
public override receiver: ClientUser;

/**
* @param client The main client
* @param party The party this invitation belongs to
* @param sender The friend (or the client user) who sent this invitation
* @param receiver The friend (or the client user) who received this invitation
* @param data The invitation data
*/
constructor(client: Client, party: Party | ClientParty, sender: Friend, receiver: ClientUser, data: any) {
super(client, party, sender, receiver, data);

this.sender = sender;
this.receiver = receiver;
}

/**
* Accepts this invitation
Expand Down
18 changes: 16 additions & 2 deletions src/structures/party/ReceivedPartyJoinRequest.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
import BasePartyJoinRequest from './BasePartyJoinRequest';
import type ClientUser from '../user/ClientUser';
import type Friend from '../friend/Friend';
import type Client from '../../Client';

/**
* Represents an incoming party join request
*/
class ReceivedPartyJoinRequest extends BasePartyJoinRequest {
public receiver!: ClientUser;
public sender!: Friend;
public override receiver: ClientUser;
public override sender: Friend;

/**
* @param client The main client
* @param sender The user who requested to join the party
* @param receiver The user who received the join request
* @param data The party confirmation data
*/
constructor(client: Client, sender: Friend, receiver: ClientUser, data: any) {
super(client, sender, receiver, data);

this.sender = sender;
this.receiver = receiver;
}

/**
* Accepts the join request. If it expired, a normal invite will be sent
Expand Down
Loading

0 comments on commit f9a8e10

Please sign in to comment.