diff --git a/lib/changelog.ts b/lib/changelog.ts index e35b73d..ac587e4 100644 --- a/lib/changelog.ts +++ b/lib/changelog.ts @@ -1,33 +1,33 @@ export interface ChangelogBuild { - created_at: Date, - display_version: string, - id: number, - update_stream: UpdateStream | null, + created_at: Date + display_version: string + id: number + update_stream: UpdateStream | null users: number - version: string | null, + version: string | null changelog_entries?: { - category: string, - created_at: Date | null, - github_pull_request_id: number | null, - github_url: string | null, - id: number | null, - major: Boolean, - repository: string | null, - title: string | null, - type: string, + category: string + created_at: Date | null + github_pull_request_id: number | null + github_url: string | null + id: number | null + major: Boolean + repository: string | null + title: string | null + type: string url: string | null - }, + } versions?: { - next: ChangelogBuild | null, + next: ChangelogBuild | null previous: ChangelogBuild | null } } export interface UpdateStream { - display_name: string | null, - id: number, - is_featured: Boolean, - name: string, - latest_build: ChangelogBuild | null, + display_name: string | null + id: number + is_featured: Boolean + name: string + latest_build: ChangelogBuild | null user_count: number } diff --git a/lib/chat.ts b/lib/chat.ts new file mode 100644 index 0000000..a7362c1 --- /dev/null +++ b/lib/chat.ts @@ -0,0 +1,42 @@ +import { CurrentUserAttributes, UserCompact } from "./user"; + +export type ChannelType = +"PUBLIC" | +"PRIVATE" | +"MULTIPLAYER" | +"SPECTATOR" | +"TEMPORARY" | +"PRIVATE" | +"PM" | +"GROUP" | +"ANNOUNCE"; + +export interface UserSilence { + id: number + user_id: number +} + +export interface ChatChannel { + channel_id: number + name: string + description: string | null + icon: string | null + type: ChannelType + moderated: Boolean + uuid: string | null + current_user_attributes?: CurrentUserAttributes | null + last_message_id?: number | null + users?: number[] | null +} + +export interface ChatMessage { + channel_id: number + content: string + is_action: Boolean + message_id: number + sender_id: number + timestamp: Date + type: string + uuid: string | null + sender?: UserCompact +} diff --git a/lib/comment.ts b/lib/comment.ts new file mode 100644 index 0000000..2222ecd --- /dev/null +++ b/lib/comment.ts @@ -0,0 +1,45 @@ +import { CurrentUserAttributes, UserCompact } from "./user" + +export interface Comment { + commentable_id: number + commentable_type: string + created_at: Date + deleted_at: Date | null + edited_at: Date | null + edited_by_id: number | null + id: number + legacy_name: string | null + message: string | null + message_html: string | null + parent_id: number | null + pinned: Boolean + replies_count: number + updated_at: Date + user_id: number + votes_count: number +} + +export interface CommentBundle { + commentable_meta: CommentableMeta[] + comments: Comment[] + has_more: Boolean + has_more_id: number | null + included_comments: Comment[] + pinned_comments: Comment[] + sort: string + top_level_count: number | null + total: number | null + user_follow: Boolean + user_votes: number[] + users: UserCompact[] +} + +export interface CommentableMeta { + current_user_attributes: CurrentUserAttributes + id: number + owner_id: number | null + owner_title: string | null + title: string + type: string + url: string +} diff --git a/lib/interactive_test.ts b/lib/tests/interactive_test.ts similarity index 75% rename from lib/interactive_test.ts rename to lib/tests/interactive_test.ts index e6f9512..d7bf0ff 100644 --- a/lib/interactive_test.ts +++ b/lib/tests/interactive_test.ts @@ -1,6 +1,6 @@ import "dotenv/config" import util = require('util') -import * as osu from "." +import * as osu from ".." const prompt = require("prompt-sync")({sigint: true}) @@ -15,8 +15,10 @@ async function test(id: string | undefined, secret: string | undefined, redirect let api = await osu.API.createAsync({id: Number(id), secret}, {code, redirect_uri}) if (api) { - let friends = await api.getFriends() - if (!(friends instanceof osu.APIError)) {console.log(friends[0].statistics?.level.current); console.log(util.inspect(friends[0], false, null, true))} + let match = await api.getRoom({id: 231069}) + if (match instanceof osu.APIError) {throw new Error("yeah no")} + let point = await api.getPlaylistItemScores(match.playlist[16]) + console.log(util.inspect(point, false, null, true)) } } diff --git a/lib/test.ts b/lib/tests/test.ts similarity index 98% rename from lib/test.ts rename to lib/tests/test.ts index b2f9835..d97332c 100644 --- a/lib/test.ts +++ b/lib/tests/test.ts @@ -1,4 +1,4 @@ -import * as osu from "." +import * as osu from ".." import "dotenv/config" import util = require('util') // console.log(util.inspect(users, false, null, true)) diff --git a/lib/user.ts b/lib/user.ts index c3b278d..4bce226 100644 --- a/lib/user.ts +++ b/lib/user.ts @@ -179,3 +179,14 @@ export interface KudosuHistory { title: string } } + +export interface CurrentUserAttributes { + can_destroy: Boolean + can_reopen: Boolean + can_moderate_kudosu: Boolean + can_resolve: Boolean + vote_score: number + can_message: Boolean + can_message_error: string | null + last_read_id: number +}