mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-03 05:26:07 +00:00
feat: editProfile()
This commit is contained in:
parent
425a80eee3
commit
7ac20b2a27
@ -3,7 +3,8 @@ import type { Snowflake } from "./Snowflake.ts";
|
|||||||
// cdn endpoints
|
// cdn endpoints
|
||||||
export * from "./Cdn.ts";
|
export * from "./Cdn.ts";
|
||||||
|
|
||||||
export function USER(userId: Snowflake): string {
|
export function USER(userId?: Snowflake): string {
|
||||||
|
if (!userId) return "/users/@me";
|
||||||
return `/users/${userId}`;
|
return `/users/${userId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import {
|
|||||||
} from "../discordeno/mod.ts";
|
} from "../discordeno/mod.ts";
|
||||||
|
|
||||||
import User from "./structures/User.ts";
|
import User from "./structures/User.ts";
|
||||||
|
import { urlToBase64 } from "./util/urlToBase64.ts";
|
||||||
|
|
||||||
import * as Routes from "./Routes.ts";
|
import * as Routes from "./Routes.ts";
|
||||||
import * as Actions from "./Actions.ts";
|
import * as Actions from "./Actions.ts";
|
||||||
@ -200,6 +201,15 @@ export class Session extends EventEmitter {
|
|||||||
return super.emit(event, ...params);
|
return super.emit(event, ...params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async editProfile(nick?: string, avatarURL?: string | null ): Promise<User> {
|
||||||
|
const avatar = avatarURL ? await urlToBase64(avatarURL) : avatarURL;
|
||||||
|
const user = await this.rest.runMethod<DiscordUser>(this.rest, 'PATCH', Routes.USER(), {
|
||||||
|
username: nick,
|
||||||
|
avatar: avatar
|
||||||
|
});
|
||||||
|
return new User(this, user);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit bot's status
|
* Edit bot's status
|
||||||
* tip: execute this on the ready event if possible
|
* tip: execute this on the ready event if possible
|
||||||
|
Loading…
x
Reference in New Issue
Block a user