Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { batch, createSignal } from "solid-js";

import { AsyncEventEmitter } from "@vladfrangu/async_event_emitter";
import { API } from "stoat-api";
import type { DataLogin, RevoltConfig, Role } from "stoat-api";
import type { DataLogin, RevoltConfig, Role, UserLimits } from "stoat-api";

import type { Channel } from "./classes/Channel.js";
import type { Emoji } from "./classes/Emoji.js";
Expand Down Expand Up @@ -578,4 +578,12 @@ export class Client extends AsyncEventEmitter<Events> {

return data.id;
}

getLimits(): UserLimits | undefined {
if (!this.configured() || !this.user) {
return;
}

return this.user.getLimits();
}
}
29 changes: 28 additions & 1 deletion src/classes/User.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import type { User as APIUser, DataEditUser, Presence } from "stoat-api";
import type {
User as APIUser,
DataEditUser,
Presence,
UserLimits,
} from "stoat-api";
import { decodeTime } from "ulid";

import type { UserCollection } from "../collections/UserCollection.js";
Expand Down Expand Up @@ -47,6 +52,13 @@
return new Date(decodeTime(this.id));
}

/**
* How old this user is in milliseconds
*/
get age() {
return new Date().getTime() - this.createdAt.getTime();
}

/**
* Username
*/
Expand Down Expand Up @@ -325,4 +337,19 @@
`/users/${this.id as ""}/mutual`,
);
}

getLimits(): UserLimits | undefined {
if (!this.#collection.client.configured()) {
return;
}
if (
this.age <
(this.#collection.client.configuration?.features.limits.global
.new_user_hours ?? 72) *

Check failure on line 348 in src/classes/User.ts

View workflow job for this annotation

GitHub Actions / build

Property 'new_user_hours' does not exist on type '{ group_size: number; message_embeds: number; message_replies: number; message_reactions: number; server_emoji: number; server_roles: number; server_channels: number; body_limit_size: number; restrict_server_creation: string[]; }'.
3600_0000
) {
return this.#collection.client.configuration?.features.limits.new_user;
}
return this.#collection.client.configuration?.features.limits.default;
}
}
Loading