Skip to content

Commit

Permalink
🔨 refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed May 5, 2024
1 parent 16e110b commit 4173f85
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/classes/Friends.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import SteamID from 'steamid';
import axios, { AxiosError } from 'axios';
import Bot from './Bot';
import filterAxiosError from '@tf2autobot/filter-axios-error';
import { SteamRequestParams } from '../types/common';

export default class Friends {
maxFriends: number | undefined;
Expand Down Expand Up @@ -43,17 +44,12 @@ export default class Friends {

get getMaxFriends(): Promise<number> {
return new Promise((resolve, reject) => {
const params: {
steamid: string;
key?: string;
access_token?: string;
} = {
const params: SteamRequestParams = {
steamid: (this.bot.client.steamID === null
? this.bot.handler.getBotInfo.steamID
: this.bot.client.steamID
).getSteamID64()
};

const hasApiKey = !!this.bot.manager.apiKey;
params[hasApiKey ? 'key' : 'access_token'] = this.bot.manager[hasApiKey ? 'apiKey' : 'accessToken'];

Expand Down
8 changes: 2 additions & 6 deletions src/classes/TF2Inventory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import TradeOfferManager from '@tf2autobot/tradeoffer-manager';
import axios, { AxiosError } from 'axios';
import cheerio from 'cheerio';
import filterAxiosError from '@tf2autobot/filter-axios-error';
import { SteamRequestParams } from '../types/common';
// import { uid } from 'rand-token';

type TF2Attribute = {
Expand Down Expand Up @@ -99,12 +100,7 @@ export default class TF2Inventory {

private fetch(): Promise<void> {
return new Promise((resolve, reject) => {
const params: {
steamid: string;
key?: string;
access_token?: string;
} = { steamid: this.getSteamID.toString() };

const params: SteamRequestParams = { steamid: this.getSteamID.toString() };
const hasApiKey = !!this.manager.apiKey;
params[hasApiKey ? 'key' : 'access_token'] = this.manager[hasApiKey ? 'apiKey' : 'accessToken'];

Expand Down
6 changes: 6 additions & 0 deletions src/types/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ export interface UnknownDictionary<T> {
}

type UnknownDictionaryKnownValues = UnknownDictionary<any>;

export interface SteamRequestParams {
steamid: string;
key?: string;
access_token?: string;
}

0 comments on commit 4173f85

Please sign in to comment.