Skip to content

Commit

Permalink
fix badges API object handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Fischer committed Mar 16, 2019
1 parent 71d7733 commit ec24231
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/twitch/src/API/Badges/BadgesAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export default class BadgesAPI extends BaseAPI {
*/
@Cached(3600)
async getGlobalBadges() {
const data = await this._client.callAPI<ChatBadgeListData>({
const data = await this._client.callAPI<{ badge_sets: ChatBadgeListData }>({
url: 'https://badges.twitch.tv/v1/badges/global/display',
type: TwitchAPICallType.Custom
});

return new ChatBadgeList(data, this._client);
return new ChatBadgeList(data.badge_sets, this._client);
}

/**
Expand Down
8 changes: 3 additions & 5 deletions packages/twitch/src/API/Badges/ChatBadgeList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import TwitchClient from '../../TwitchClient';
import ChatBadgeSet, { ChatBadgeSetData } from './ChatBadgeSet';

/** @private */
export interface ChatBadgeListData {
versions: Record<string, ChatBadgeSetData>;
}
export type ChatBadgeListData = Record<string, ChatBadgeSetData>;

/**
* A list of badge sets.
Expand All @@ -23,7 +21,7 @@ export default class ChatBadgeList {
* Names of all badge sets in the list.
*/
get badgeSetNames() {
return Object.keys(this._data.versions);
return Object.keys(this._data);
}

/**
Expand All @@ -32,7 +30,7 @@ export default class ChatBadgeList {
* @param name The name of the badge set.
*/
getBadgeSet(name: string) {
return new ChatBadgeSet(this._data.versions[name], this._client);
return new ChatBadgeSet(this._data[name], this._client);
}

/** @private */
Expand Down

0 comments on commit ec24231

Please sign in to comment.