Skip to content
Open
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
11 changes: 10 additions & 1 deletion src/classes/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { decodeTime } from "ulid";

import type { BotCollection } from "../collections/BotCollection.js";
import type { BotFlags } from "../hydration/bot.js";
import { hydrate } from "../hydration/index.js";

import { PublicBot } from "./PublicBot.js";
import type { User } from "./User.js";
Expand Down Expand Up @@ -139,7 +140,15 @@ export class Bot {
* @param data Changes
*/
async edit(data: DataEditBot): Promise<void> {
await this.#collection.client.api.patch(`/bots/${this.id as ""}`, data);
this.#collection.updateUnderlyingObject(
this.id,
hydrate(
"bot",
await this.#collection.client.api.patch(`/bots/${this.id as ""}`, data),
this.#collection.client,
false,
),
);
}

/**
Expand Down
19 changes: 14 additions & 5 deletions src/classes/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { User as APIUser, DataEditUser, Presence } from "stoat-api";
import { decodeTime } from "ulid";

import type { UserCollection } from "../collections/UserCollection.js";
import { hydrate } from "../hydration/index.js";
import { U32_MAX, UserPermission } from "../permissions/definitions.js";

import type { Channel } from "./Channel.js";
Expand Down Expand Up @@ -225,11 +226,19 @@ export class User {
* @param data Changes
*/
async edit(data: DataEditUser): Promise<void> {
await this.#collection.client.api.patch(
`/users/${
this.id === this.#collection.client.user?.id ? "@me" : this.id
}`,
data,
this.#collection.updateUnderlyingObject(
this.id,
hydrate(
"user",
await this.#collection.client.api.patch(
`/users/${
this.id === this.#collection.client.user?.id ? "@me" : this.id
}`,
data,
),
this.#collection.client,
false,
),
);
}

Expand Down
Loading