congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
AccountManager.setAvatar
Code IndexAdd Tabnine to your IDE (free)

How to use
setAvatar
method
in
net.dv8tion.jda.core.managers.AccountManager

Best Java code snippets using net.dv8tion.jda.core.managers.AccountManager.setAvatar (Showing top 4 results out of 315)

origin: DV8FromTheWorld/JDA

/**
 * Sets the avatar for the currently logged in account
 *
 * <p><b>Client-Accounts ({@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT}) require the
 * current password to be updated. See {@link #setAvatar(net.dv8tion.jda.core.entities.Icon, String) #setAvatar(Icon, String)}</b>
 *
 * @param  avatar
 *         An {@link net.dv8tion.jda.core.entities.Icon Icon} instance representing
 *         the new Avatar for the current account, {@code null} to reset the avatar to the default avatar.
 *
 * @return AccountManager for chaining convenience
 */
@CheckReturnValue
public AccountManager setAvatar(Icon avatar)
{
  return setAvatar(avatar, null);
}
origin: FlareBot/FlareBot

@Override
public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) {
  if (args.length == 0) {
    if (!message.getAttachments().isEmpty()) {
      Message.Attachment attachment = message.getAttachments().get(0);
      try {
        sender.getJDA().getSelfUser().getManager().setAvatar(Icon.from(
            new URL(attachment.getUrl()).openStream()
        )).complete();
      } catch (IOException e) {
        channel.sendMessage("Failed to update avatar!! " + e).queue();
      }
      channel.sendMessage("Success!").queue();
    } else {
      channel.sendMessage("You must either attach an image or link to one!").queue();
    }
  } else {
    try {
      sender.getJDA().getSelfUser().getManager().setAvatar(Icon.from(
          new URL(args[0]).openStream()
      )).complete();
    } catch (IOException e) {
      channel.sendMessage("Failed to update avatar!! " + e).queue();
    }
    channel.sendMessage("Success!").queue();
  }
}
origin: Kaaz/DiscordBot

  @Override
  public String execute(DiscordBot bot, String[] args, MessageChannel channel, User author, Message inputMessage) {
    SimpleRank rank = bot.security.getSimpleRank(author);

    if (!rank.isAtLeast(SimpleRank.CREATOR)) {
      return Templates.no_permission.formatGuild(channel);
    }
    if (args.length <= 1) {
      try {
        Icon icon = Icon.from(Unirest.get(args[0]).asBinary().getBody());
        bot.queue.add(channel.getJDA().getSelfUser().getManager().setAvatar(icon));
      } catch (IOException | UnirestException e) {
        return "Error: " + e.getMessage();
      }
      return ":+1:";
    }
    return ":face_palm: I expected you to know how to use it";
  }
}
origin: jagrosh/MusicBot

  @Override
  protected void execute(CommandEvent event) 
  {
    String url;
    if(event.getArgs().isEmpty())
      if(!event.getMessage().getAttachments().isEmpty() && event.getMessage().getAttachments().get(0).isImage())
        url = event.getMessage().getAttachments().get(0).getUrl();
      else
        url = null;
    else
      url = event.getArgs();
    InputStream s = OtherUtil.imageFromUrl(url);
    if(s==null)
    {
      event.reply(event.getClient().getError()+" Invalid or missing URL");
    }
    else
    {
      try {
      event.getSelfUser().getManager().setAvatar(Icon.from(s)).queue(
          v -> event.reply(event.getClient().getSuccess()+" Successfully changed avatar."), 
          t -> event.reply(event.getClient().getError()+" Failed to set avatar."));
      } catch(IOException e) {
        event.reply(event.getClient().getError()+" Could not load from provided URL.");
      }
    }
  }
}
net.dv8tion.jda.core.managersAccountManagersetAvatar

Javadoc

Sets the avatar for the currently logged in account

Client-Accounts ( net.dv8tion.jda.core.AccountType#CLIENT) require the current password to be updated. See #setAvatar(net.dv8tion.jda.core.entities.Icon,String)

Popular methods of AccountManager

  • complete
  • setName
    Sets the username for the currently logged in account
  • <init>
    Creates a new AccountManager instance
  • getJDA
  • getRequestBody
  • getSelfUser
    The net.dv8tion.jda.core.entities.SelfUser that will be modified by this AccountManager. This repres
  • opt
  • queue
  • reset
    Resets the fields specified by the provided bit-flag patterns. You can specify a combination by usin
  • shouldUpdate

Popular in Java

  • Updating database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getContentResolver (Context)
  • compareTo (BigDecimal)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Option (scala)
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now