From 44a9f11fd6399e10c08930253149fc07ed49d826 Mon Sep 17 00:00:00 2001 From: Yuzu Date: Fri, 1 Jul 2022 10:25:37 -0500 Subject: [PATCH] feat: set bot's nickname --- structures/Guild.ts | 14 ++++++++++++++ util/Routes.ts | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/structures/Guild.ts b/structures/Guild.ts index 0fe06e5..9beee88 100644 --- a/structures/Guild.ts +++ b/structures/Guild.ts @@ -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 { if (options.image && !options.image.startsWith("data:image/")) { options.image = await urlToBase64(options.image); diff --git a/util/Routes.ts b/util/Routes.ts index 035042d..9ebfcb6 100644 --- a/util/Routes.ts +++ b/util/Routes.ts @@ -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`; +}