feat: set bot's nickname

This commit is contained in:
Yuzu 2022-07-01 10:25:37 -05:00
parent 71aa75c660
commit 44a9f11fd6
2 changed files with 18 additions and 0 deletions

View File

@ -90,6 +90,20 @@ export class Guild extends BaseGuild implements Model {
roles: Role[];
emojis: GuildEmoji[];
/**
* 'null' would reset the nickname
* */
async editBotNickname(options: { nick: string | null; reason?: string }) {
const result = await this.session.rest.runMethod<{ nick?: string } | undefined>(
this.session.rest,
"PATCH",
Routes.USER_NICK(this.id),
options,
);
return result?.nick;
}
async createEmoji(options: CreateGuildEmoji): Promise<GuildEmoji> {
if (options.image && !options.image.startsWith("data:image/")) {
options.image = await urlToBase64(options.image);

View File

@ -154,3 +154,7 @@ export function WEBHOOK(webhookId: Snowflake, token: string, options?: { wait?:
return url;
}
export function USER_NICK(guildId: Snowflake) {
return `/guilds/${guildId}/members/@me`;
}