async function editBotProfile(username, botAvatarURL) {
  // Nothing was edited
  if (!username && !botAvatarURL) return;
  // Check username requirements if username was provided
  if (username) {
    if (username.length > 32) {
      throw new Error(Errors.USERNAME_MAX_LENGTH);
    }
    if (username.length < 2) {
      throw new Error(Errors.USERNAME_MIN_LENGTH);
    }
    if (
      [
        "@",
        "#",
        ":",
        "```",
      ].some((char) => username.includes(char))
    ) {
      throw new Error(Errors.USERNAME_INVALID_CHARACTER);
    }
    if (
      [
        "discordtag",
        "everyone",
        "here",
      ].includes(username)
    ) {
      throw new Error(Errors.USERNAME_INVALID_USERNAME);
    }
  }
  const avatar = botAvatarURL ? await urlToBase64(botAvatarURL) : undefined;
  return await rest.runMethod("patch", endpoints.USER_BOT, {
    username: username?.trim(),
    avatar,
  });
}
/** Modifies the bot's username or avatar.
 * NOTE: username: if changed may cause the bot's discriminator to be randomized.
 */
Modifies the bot's username or avatar.
NOTE: username: if changed may cause the bot's discriminator to be randomized.
Modifies the bot ' s username or avatar . NOTE : username : if changed may cause the bot ' s discriminator to be randomized .
async function editBotProfile(username, botAvatarURL) {
  if (!username && !botAvatarURL) return;
  if (username) {
    if (username.length > 32) {
      throw new Error(Errors.USERNAME_MAX_LENGTH);
    }
    if (username.length < 2) {
      throw new Error(Errors.USERNAME_MIN_LENGTH);
    }
    if (
      [
        "@",
        "#",
        ":",
        "```",
      ].some((char) => username.includes(char))
    ) {
      throw new Error(Errors.USERNAME_INVALID_CHARACTER);
    }
    if (
      [
        "discordtag",
        "everyone",
        "here",
      ].includes(username)
    ) {
      throw new Error(Errors.USERNAME_INVALID_USERNAME);
    }
  }
  const avatar = botAvatarURL ? await urlToBase64(botAvatarURL) : undefined;
  return await rest.runMethod("patch", endpoints.USER_BOT, {
    username: username?.trim(),
    avatar,
  });
}
async function editBotProfile ( username , botAvatarURL ) { if ( ! username && ! botAvatarURL ) return ; if ( username ) { if ( username . length > 32 ) { throw new Error ( Errors . USERNAME_MAX_LENGTH ) ; } if ( username . length < 2 ) { throw new Error ( Errors . USERNAME_MIN_LENGTH ) ; } if ( [ "@" , "#" , ":" , "```" , ] . some ( ( char ) => username . includes ( char ) ) ) { throw new Error ( Errors . USERNAME_INVALID_CHARACTER ) ; } if ( [ "discordtag" , "everyone" , "here" , ] . includes ( username ) ) { throw new Error ( Errors . USERNAME_INVALID_USERNAME ) ; } } const avatar = botAvatarURL ? await urlToBase64 ( botAvatarURL ) : undefined ; return await rest . runMethod ( "patch" , endpoints . USER_BOT , { username : username ?. trim ( ) , avatar , } ) ; }
Modifies the bot's username or avatar.
Modifies the bot ' s username or avatar .
// Nothing was edited // Check username requirements if username was provided