Files
discordeno/helpers/members/editBotMember.ts
T
LTS20050703andSkillz4Killz 16f109ad43 chore: WithReason type cleanup (#2449)
* type WithReason<T> = T & { reason?: string }

* deno fmt (1.25.2)

* WithReason: jsdoc comments for reason

Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>

* deno fmt

* types: WithReason type -> WithReason interface

* Fix: Some helpers missing support for reason

Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
2022-09-12 08:52:03 -05:00

38 lines
1.0 KiB
TypeScript

import type { Bot } from "../../bot.ts";
import { DiscordMember, Member, WithReason } from "../../mod.ts";
/**
* Edits the nickname of the bot user.
*
* @param bot - The bot instance to use to make the request.
* @param guildId - The ID of the guild to edit the nickname of the bot user in.
* @param options - The parameters for the edit of the nickname.
* @returns An instance of the edited {@link Member}
*
* @remarks
* Fires a _Guild Member Update_ gateway event.
*
* @see {@link https://discord.com/developers/docs/resources/guild#modify-current-member}
*/
export async function editBotMember(
bot: Bot,
guildId: bigint,
options: EditBotMemberOptions,
): Promise<Member> {
const result = await bot.rest.runMethod<DiscordMember>(
bot.rest,
"PATCH",
bot.constants.routes.USER_NICK(guildId),
{
nick: options.nick,
reason: options.reason,
},
);
return bot.transformers.member(bot, result, guildId, bot.id);
}
export interface EditBotMemberOptions extends WithReason {
nick?: string | null;
}