Files
discordeno/helpers/misc/editBotProfile.ts
ITOH 03996c5f58 refactor: revert "feat: base plugin lib idea (#2308)" (#2336)
* Revert "feat: base plugin lib idea (#2308)"

This reverts commit ffe7cdbc6f.

* fmt
2022-07-02 14:24:43 +01:00

17 lines
669 B
TypeScript

import type { Bot } from "../../bot.ts";
import { DiscordUser } from "../../types/discord.ts";
/** Modifies the bot's username or avatar.
* NOTE: username: if changed may cause the bot's discriminator to be randomized.
*/
export async function editBotProfile(bot: Bot, options: { username?: string; botAvatarURL?: string | null }) {
const avatar = options?.botAvatarURL ? await bot.utils.urlToBase64(options?.botAvatarURL) : options?.botAvatarURL;
const result = await bot.rest.runMethod<DiscordUser>(bot.rest, "PATCH", bot.constants.routes.USER_BOT(), {
username: options.username?.trim(),
avatar,
});
return bot.transformers.user(bot, result);
}