public SelfUpdateNameEvent(JDA api, long responseNumber, String oldName) { super(api, responseNumber, oldName, api.getSelfUser().getName(), IDENTIFIER); }
@Override protected RequestBody finalizeData() { boolean isClient = getJDA().getAccountType() == AccountType.CLIENT; Checks.check(!isClient || (currentPassword != null && !currentPassword.isEmpty()), "Provided client account password to be used in auth is null or empty!"); JSONObject body = new JSONObject(); //Required fields. Populate with current values.. body.put("username", getSelfUser().getName()); body.put("avatar", opt(getSelfUser().getAvatarId())); if (shouldUpdate(NAME)) body.put("username", name); if (shouldUpdate(AVATAR)) body.put("avatar", avatar == null ? JSONObject.NULL : avatar.getEncoding()); if (isClient) { //Required fields. Populate with current values. body.put("password", currentPassword); body.put("email", email); if (shouldUpdate(EMAIL)) body.put("email", email); if (shouldUpdate(PASSWORD)) body.put("new_password", password); } reset(); return getRequestBody(body); }
public String getUserName() { return getJda().getSelfUser().getName(); }
private String buildPayload(SelfUser selfUser) { JSONObject main = new JSONObject(); JSONObject bot = new JSONObject(); bot.put("name", selfUser.getName()); bot.put("avatar", selfUser.getAvatarId()); main.put("bot", bot); JSONArray shards = new JSONArray(); for (JDA shard : avaire.getShardManager().getShards()) { JSONObject shardObj = new JSONObject(); shardObj.put("id", shard.getShardInfo().getShardId()); shardObj.put("latency", shard.getPing()); shardObj.put("users", shard.getUsers().size()); shardObj.put("channels", getTotalChannels(shard)); shardObj.put("guilds", shard.getGuilds().size()); shards.put(shardObj); } main.put("shards", shards); return main.toString(); }
private String parseContent(String content) { String[] parts = content.split(" "); if (!isMentionableCommand()) { return String.join(" ", Arrays.copyOfRange(parts, 1, parts.length)); } int nameSize = (isGuildMessage() ? message.getGuild().getSelfMember().getEffectiveName() : message.getJDA().getSelfUser().getName() ).split(" ").length + 1; return String.join(" ", Arrays.copyOfRange(parts, nameSize, parts.length)); }
@Override protected void execute(CommandEvent event) { String title = event.getArgs().toLowerCase().startsWith("playing") ? event.getArgs().substring(7).trim() : event.getArgs(); try { event.getJDA().getPresence().setGame(title.isEmpty() ? null : Game.playing(title)); event.reply(event.getClient().getSuccess()+" **"+event.getSelfUser().getName() +"** is "+(title.isEmpty() ? "no longer playing anything." : "now playing `"+title+"`")); } catch(Exception e) { event.reply(event.getClient().getError()+" The game could not be set!"); } }
@Override protected void execute(CommandEvent event) { if(event.getArgs().isEmpty()) { event.replyError("Please include a title to listen to!"); return; } String title = event.getArgs().toLowerCase().startsWith("to") ? event.getArgs().substring(2).trim() : event.getArgs(); try { event.getJDA().getPresence().setGame(Game.listening(title)); event.replySuccess("**"+event.getSelfUser().getName()+"** is now listening to `"+title+"`"); } catch(Exception e) { event.reply(event.getClient().getError()+" The game could not be set!"); } } }
jda.getSelfUser().getName(), jda.getShardInfo(), oldStatus.name(), status.name());
public void initOnce() { CBanks.init(getJda().getSelfUser().getIdLong(), getJda().getSelfUser().getName()); } }
@Override public void run() { int roll = rng.nextInt(100); TextChannel inviteChannel = bot.getShardFor(BotConfig.BOT_GUILD_ID).getJda().getTextChannelById(BotConfig.BOT_CHANNEL_ID); if (inviteChannel != null && roll < 10) { String fallback = "Feedback @ https://discord.gg/eaywDDt | #%s"; bot.getShardFor(BotConfig.BOT_GUILD_ID).queue.add(inviteChannel.getInvites(), invites -> { if (invites != null && !invites.isEmpty()) { setGameOnShards(bot, "Feedback @ https://discord.gg/" + invites.get(0).getCode() + " | %s"); } else { setGameOnShards(bot, fallback); } }); } else if (roll < 50) { String username = bot.getShards()[0].getJda().getSelfUser().getName(); setGameOnShards(bot, "@" + username + " help | @" + username + " invite | #%s"); } else { setGameOnShards(bot, statusList[new Random().nextInt(statusList.length)]); } }
@Override protected void execute(CommandEvent event) { String[] parts = event.getArgs().split("\\s+", 2); if(parts.length<2) { event.replyError("Please include a twitch username and the name of the game to 'stream'"); return; } try { event.getJDA().getPresence().setGame(Game.streaming(parts[1], "https://twitch.tv/"+parts[0])); event.replySuccess("**"+event.getSelfUser().getName() +"** is now streaming `"+parts[1]+"`"); } catch(Exception e) { event.reply(event.getClient().getError()+" The game could not be set!"); } } }
@Override protected void execute(CommandEvent event) { if(event.getArgs().isEmpty()) { event.replyError("Please include a title to watch!"); return; } String title = event.getArgs(); try { event.getJDA().getPresence().setGame(Game.watching(title)); event.replySuccess("**"+event.getSelfUser().getName()+"** is now watching `"+title+"`"); } catch(Exception e) { event.reply(event.getClient().getError()+" The game could not be set!"); } } }
private void sendTagInformationMessage(MessageReceivedEvent event) { String author = "**Senither#0001**"; if (event.getMessage().getChannelType().isGuild() && event.getGuild().getMemberById(88739639380172800L) != null) { author = "<@88739639380172800>"; } MessageFactory.makeEmbeddedMessage(event.getMessage().getChannel(), Color.decode("#E91E63"), String.format(mentionMessage, avaire.getSelfUser().getName(), author, CommandHandler.getLazyCommand("help").getCommand().generateCommandTrigger(event.getMessage()), AppInfo.getAppInfo().version )) .setFooter("This message will be automatically deleted in one minute.") .queue(message -> message.delete().queueAfter(1, TimeUnit.MINUTES, null, RestActionUtil.ignore)); }
"You can reset by typing `@" + channel.getJDA().getSelfUser().getName() + " reset yesimsure`"));
@Override protected void execute(CommandEvent event) { Settings s = event.getClient().getSettingsFor(event.getGuild()); MessageBuilder builder = new MessageBuilder() .append(EMOJI + " **") .append(event.getSelfUser().getName()) .append("** settings:"); TextChannel tchan = s.getTextChannel(event.getGuild()); VoiceChannel vchan = s.getVoiceChannel(event.getGuild()); Role role = s.getRole(event.getGuild()); EmbedBuilder ebuilder = new EmbedBuilder() .setColor(event.getSelfMember().getColor()) .setDescription("Text Channel: "+(tchan==null ? "Any" : "**#"+tchan.getName()+"**") + "\nVoice Channel: "+(vchan==null ? "Any" : "**"+vchan.getName()+"**") + "\nDJ Role: "+(role==null ? "None" : "**"+role.getName()+"**") + "\nRepeat Mode: **"+(s.getRepeatMode() ? "On" : "Off")+"**" + "\nDefault Playlist: "+(s.getDefaultPlaylist()==null ? "None" : "**"+s.getDefaultPlaylist()+"**") ) .setFooter(event.getJDA().getGuilds().size()+" servers | " +event.getJDA().getGuilds().stream().filter(g -> g.getSelfMember().getVoiceState().inVoiceChannel()).count() +" audio connections", null); event.getChannel().sendMessage(builder.setEmbed(ebuilder.build()).build()).queue(); }
@Override protected void execute(CommandEvent event) { try { String oldname = event.getSelfUser().getName(); event.getSelfUser().getManager().setName(event.getArgs()).complete(false); event.reply(event.getClient().getSuccess()+" Name changed from `"+oldname+"` to `"+event.getArgs()+"`"); } catch(RateLimitedException e) { event.reply(event.getClient().getError()+" Name can only be changed twice per hour!"); } catch(Exception e) { event.reply(event.getClient().getError()+" That name is not valid!"); } } }