Skip to content

Commit

Permalink
Merge pull request #24 from FNLB-Project/main
Browse files Browse the repository at this point in the history
bun support
  • Loading branch information
tnfAngel committed Jun 30, 2024
2 parents 4a42eee + cbe2f48 commit 219a446
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 36 deletions.
10 changes: 5 additions & 5 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,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 @@ -456,7 +456,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 @@ -497,7 +497,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 @@ -520,7 +520,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/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
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 override content!: string;
public override content: string;

/**
* The message's author
*/
public override 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
14 changes: 13 additions & 1 deletion 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,7 +10,17 @@ class ReceivedFriendMessage extends BaseFriendMessage {
/**
* The message's author
*/
public override 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
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 override 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;
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 override sender!: Friend;
public override 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 override receiver!: ClientUser;
public override 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
21 changes: 19 additions & 2 deletions src/structures/party/SentPartyInvitation.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 sent party invitation
*/
class SentPartyInvitation extends BasePartyInvitation {
public override sender!: ClientUser;
public override receiver!: Friend;
public override sender: ClientUser;
public override receiver: Friend;

/**
* @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: ClientUser, receiver: Friend, data: any) {
super(client, party, sender, receiver, data);

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

/**
* Declines this invitation
Expand Down
18 changes: 16 additions & 2 deletions src/structures/party/SentPartyJoinRequest.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 outgoing party join request
*/
class SentPartyJoinRequest extends BasePartyJoinRequest {
public override receiver!: Friend;
public override sender!: ClientUser;
public override receiver: Friend;
public override sender: ClientUser;

/**
* @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: ClientUser, receiver: Friend, data: any) {
super(client, sender, receiver, data);

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

export default SentPartyJoinRequest;
22 changes: 19 additions & 3 deletions src/structures/stw/STWMeleeWeaponSchematic.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import STWWeaponSchematic from './STWWeaponSchematic';
import type { STWSchematicMeleeSubType } from '../../../resources/structs';
import { parseSTWSchematicTemplateId } from '../../util/Util';
import type { STWSchematicEvoType, STWSchematicMeleeSubType } from '../../../resources/structs';
import type { STWProfileSchematicData } from '../../../resources/httpResponses';
import type Client from '../../Client';

class STWMeleeWeaponSchematic extends STWWeaponSchematic {
public override type!: 'melee';
public override subType!: STWSchematicMeleeSubType;
public override type: 'melee';
public override subType: STWSchematicMeleeSubType;

constructor(client: Client, id: string, data: STWProfileSchematicData & {
type: 'melee';
subType: STWSchematicMeleeSubType;
evoType: STWSchematicEvoType;
}) {
super(client, id, data);

const parsedSchematic = parseSTWSchematicTemplateId(data.templateId);

this.type = parsedSchematic.type as | 'melee';
this.subType = parsedSchematic.subType as STWSchematicMeleeSubType;
}
}

export default STWMeleeWeaponSchematic;
22 changes: 19 additions & 3 deletions src/structures/stw/STWProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import User from '../user/User';
import type Client from '../../Client';
import type {
STWFORTStats,
STWSchematicEvoType,
STWSchematicMeleeSubType,
STWSchematicRangedSubType,
STWSchematicTrapSubType,
STWSurvivorSquads,
UserData,
} from '../../../resources/structs';
Expand Down Expand Up @@ -122,13 +126,25 @@ class STWProfile extends User {
case 'Schematic':
switch (parseSTWSchematicTemplateId(item.templateId).type) {
case 'melee':
this.items.push(new STWMeleeWeaponSchematic(this.client, itemId, item as STWProfileSchematicData));
this.items.push(new STWMeleeWeaponSchematic(this.client, itemId, item as STWProfileSchematicData & {
type: 'melee';
subType: STWSchematicMeleeSubType;
evoType: STWSchematicEvoType;
}));
break;
case 'ranged':
this.items.push(new STWRangedWeaponSchematic(this.client, itemId, item as STWProfileSchematicData));
this.items.push(new STWRangedWeaponSchematic(this.client, itemId, item as STWProfileSchematicData & {
type: 'ranged';
subType: STWSchematicRangedSubType
evoType: STWSchematicEvoType;
}));
break;
case 'trap':
this.items.push(new STWTrapSchematic(this.client, itemId, item as STWProfileSchematicData));
this.items.push(new STWTrapSchematic(this.client, itemId, item as STWProfileSchematicData & {
type: 'trap';
subType: STWSchematicTrapSubType
evoType: never;
}));
break;
default:
this.items.push(new STWSchematic(this.client, itemId, item as STWProfileSchematicData));
Expand Down
22 changes: 19 additions & 3 deletions src/structures/stw/STWRangedWeaponSchematic.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import STWWeaponSchematic from './STWWeaponSchematic';
import type { STWSchematicRangedSubType } from '../../../resources/structs';
import { parseSTWSchematicTemplateId } from '../../util/Util';
import type { STWSchematicEvoType, STWSchematicRangedSubType } from '../../../resources/structs';
import type { STWProfileSchematicData } from '../../../resources/httpResponses';
import type Client from '../../Client';

class STWRangedWeaponSchematic extends STWWeaponSchematic {
public override type!: 'ranged';
public override subType!: STWSchematicRangedSubType;
public override type: 'ranged';
public override subType: STWSchematicRangedSubType;

constructor(client: Client, id: string, data: STWProfileSchematicData & {
type: 'ranged';
subType: STWSchematicRangedSubType
evoType: STWSchematicEvoType;
}) {
super(client, id, data);

const parsedSchematic = parseSTWSchematicTemplateId(data.templateId);

this.type = parsedSchematic.type as 'ranged';
this.subType = parsedSchematic.subType as STWSchematicRangedSubType;
}
}

export default STWRangedWeaponSchematic;
Loading

0 comments on commit 219a446

Please sign in to comment.