/** * Sets the provider that provides the {@link net.dv8tion.jda.core.OnlineStatus OnlineStatus} for all shards. * * <p>This will also change the provider for shards that are created in the future. * * @throws IllegalArgumentException * if the provided OnlineStatus is {@link net.dv8tion.jda.core.OnlineStatus#UNKNOWN UNKNOWN} * * @param statusProvider * the {@link net.dv8tion.jda.core.OnlineStatus OnlineStatus} * to be used (OFFLINE/null {@literal ->} INVISIBLE) */ default void setStatusProvider(final IntFunction<OnlineStatus> statusProvider) { this.getShardCache().forEach(jda -> jda.getPresence().setStatus(statusProvider.apply(jda.getShardInfo().getShardId()))); }
@Override protected void execute(CommandEvent event) { try { OnlineStatus status = OnlineStatus.fromKey(event.getArgs()); if(status==OnlineStatus.UNKNOWN) { event.replyError("Please include one of the following statuses: `ONLINE`, `IDLE`, `DND`, `INVISIBLE`"); } else { event.getJDA().getPresence().setStatus(status); event.replySuccess("Set the status to `"+status.getKey().toUpperCase()+"`"); } } catch(Exception e) { event.reply(event.getClient().getError()+" The status could not be set!"); } } }