Class AccountUpdater



  • public class AccountUpdater
    extends Object
    This class can be used to update the connected account (e.g. username or avatar).
    • Constructor Detail

      • AccountUpdater

        public AccountUpdater​(DiscordApi api)
        Creates a new account updater.
        Parameters:
        api - The discord api instance.
    • Method Detail

      • setUsername

        public AccountUpdater setUsername​(String username)
        Queues the username of the connected account to get updated.
        Parameters:
        username - The username to set.
        Returns:
        The current instance in order to chain call methods.
      • setAvatar

        public AccountUpdater setAvatar​(BufferedImage avatar)
        Queues the avatar of the connected account to get updated. This method assumes the file type is "png"!
        Parameters:
        avatar - The avatar to set.
        Returns:
        The current instance in order to chain call methods.
      • setAvatar

        public AccountUpdater setAvatar​(BufferedImage avatar,
                                        String fileType)
        Queues the avatar of the connected account to get updated.
        Parameters:
        avatar - The avatar to set.
        fileType - The type of the avatar, e.g. "png" or "jpg".
        Returns:
        The current instance in order to chain call methods.
      • setAvatar

        public AccountUpdater setAvatar​(File avatar)
        Queues the avatar of the connected account to get updated.
        Parameters:
        avatar - The avatar to set.
        Returns:
        The current instance in order to chain call methods.
      • setAvatar

        public AccountUpdater setAvatar​(Icon avatar)
        Queues the avatar of the connected account to get updated.
        Parameters:
        avatar - The avatar to set.
        Returns:
        The current instance in order to chain call methods.
      • setAvatar

        public AccountUpdater setAvatar​(URL avatar)
        Queues the avatar of the connected account to get updated.
        Parameters:
        avatar - The avatar to set.
        Returns:
        The current instance in order to chain call methods.
      • setAvatar

        public AccountUpdater setAvatar​(byte[] avatar)
        Queues the avatar of the connected account to get updated. This method assumes the file type is "png"!
        Parameters:
        avatar - The avatar to set.
        Returns:
        The current instance in order to chain call methods.
      • setAvatar

        public AccountUpdater setAvatar​(byte[] avatar,
                                        String fileType)
        Queues the avatar of the connected account to get updated.
        Parameters:
        avatar - The avatar to set.
        fileType - The type of the avatar, e.g. "png" or "jpg".
        Returns:
        The current instance in order to chain call methods.
      • setAvatar

        public AccountUpdater setAvatar​(InputStream avatar)
        Queues the avatar of the connected account to get updated. This method assumes the file type is "png"!
        Parameters:
        avatar - The avatar to set.
        Returns:
        The current instance in order to chain call methods.
      • setAvatar

        public AccountUpdater setAvatar​(InputStream avatar,
                                        String fileType)
        Queues the avatar of the connected account to get updated.
        Parameters:
        avatar - The avatar to set.
        fileType - The type of the avatar, e.g. "png" or "jpg".
        Returns:
        The current instance in order to chain call methods.
      • update

        public CompletableFuture<Void> update​()
        Performs the queued updates.
        Returns:
        A future to check if the update was successful.