use of net.dv8tion.jda.core.managers.AccountManagerUpdatable in project Saber-Bot by notem.
the class AvatarCommand method action.
@Override
public void action(String head, String[] args, MessageReceivedEvent event) {
AccountManagerUpdatable manager = Main.getShardManager().getJDA().getSelfUser().getManagerUpdatable();
if (event.getMessage().getAttachments().isEmpty())
return;
Message.Attachment attachment = event.getMessage().getAttachments().get(0);
try {
File file = new File(attachment.getFileName());
attachment.download(file);
Icon icon = Icon.from(file);
manager.getAvatarField().setValue(icon).update().complete();
MessageUtilities.sendPrivateMsg("Updated bot avatar!", event.getAuthor(), null);
file.delete();
} catch (IOException e) {
Logging.exception(this.getClass(), e);
MessageUtilities.sendPrivateMsg("Failed to update bot avatar!", event.getAuthor(), null);
}
}
Aggregations