net.dv8tion.jda.core.entities.User Java Examples
The following examples show how to use
net.dv8tion.jda.core.entities.User.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LogsCommand.java From FlareBot with MIT License | 7 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { int lineCount = DEFAULT_LINE_COUNT; if (args.length == 1) { lineCount = GeneralUtils.getInt(args[0], DEFAULT_LINE_COUNT); } try { ReversedLinesFileReader rlfr = new ReversedLinesFileReader(new File("latest.log"), Charset.forName("UTF-8")); StringBuilder sb = new StringBuilder(); String line; for (int i = 0; i < lineCount; i++) { line = rlfr.readLine(); if (line == null) break; sb.append(line).append("\n"); } String pasteUrl = MessageUtils.paste(sb.toString()); MessageUtils.sendPM(channel, sender, pasteUrl == null ? "null" : pasteUrl, "Could not DM you the logs! " + "Please make sure the privacy settings allow me :( dis is pwivate, me need to send pwivately."); } catch (IOException e) { FlareBot.LOGGER.error("Failed to read latest.log", e); MessageUtils.sendException("Failed to read latest.log", e, channel); } }
Example #2
Source File: DeleteCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length == 0) { MessageUtils.sendUsage(this, channel, sender, args); return; } channel.sendTyping().complete(); String name = MessageUtils.getMessage(args, 0); CassandraController.runTask(session -> { ResultSet set = session.execute(session .prepare("SELECT playlist_name FROM flarebot.playlist WHERE playlist_name = ? AND guild_id = ?") .bind().setString(0, name).setString(1, channel.getGuild().getId())); if (set.one() != null) { session.execute(session .prepare("DELETE FROM flarebot.playlist WHERE playlist_name = ? AND guild_id = ?").bind() .setString(0, name).setString(1, channel.getGuild().getId())); channel.sendMessage(MessageUtils.getEmbed(sender) .setDescription(String .format("Removed the playlist '%s'", name)).setColor(Color.green) .build()).queue(); } else { MessageUtils.sendErrorMessage(String.format("The playlist '%s' does not exist!", name), channel, sender); } }); }
Example #3
Source File: YoMommaJokeCommand.java From DiscordBlueBot with MIT License | 6 votes |
@Override public void action(String[] args, MessageReceivedEvent event) { if (event.getMessage().getMentionedUsers().isEmpty()) { event.getTextChannel().sendMessage("No user mentioned."); } else { String joke; OkHttpClient caller = new OkHttpClient(); Request request = new Request.Builder().url("http://api.yomomma.info/").build(); List<User> mentionedUsers = event.getMessage().getMentionedUsers(); for(User u : mentionedUsers) { try { Response response = caller.newCall(request).execute(); JSONObject json = new JSONObject(response.body().string()); joke = (String) json.get("joke"); event.getTextChannel().sendMessage(u.getAsMention() + " " + joke).queue(); } catch (IOException | NullPointerException e) { event.getTextChannel().sendMessage("No joke found").queue(); } } } }
Example #4
Source File: ModlogCommand.java From FlareBot with MIT License | 6 votes |
private void listEvents(TextChannel channel, int page, User user) { StringBuilder sb = new StringBuilder(); String groupKey = null; for (ModlogEvent modlogEvent : ModlogEvent.events) { String name = modlogEvent.getName(); String[] split = name.split(" "); if (groupKey == null || groupKey.isEmpty()) groupKey = split[0]; if (!groupKey.equals(split[0])) { sb.append('\n'); groupKey = split[0]; } sb.append("`").append(modlogEvent.getTitle()).append("` - ").append(modlogEvent.getDescription()).append('\n'); } sb.append("`Default` - Is for all the normal default events\n"); sb.append("`All` - Is for targeting all events"); PaginationUtil.sendEmbedPagedMessage( new PagedEmbedBuilder<>(PaginationUtil.splitStringToList(sb.toString(), PaginationUtil.SplitMethod.CHAR_COUNT, 1024)) .setTitle("Modlog Events") .build(), page - 1, channel, user, ButtonGroupConstants.MODLOG_FEATURES); }
Example #5
Source File: ForceBanCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length >= 1) { User user = GuildUtils.getUser(args[0], true); if (user == null) { MessageUtils.sendErrorMessage("We cannot find that user!", channel, sender); return; } String reason = null; if (args.length >= 2) reason = MessageUtils.getMessage(args, 1); ModlogHandler.getInstance().handleAction(guild, channel, sender, user, ModAction.FORCE_BAN, reason); } else { MessageUtils.sendUsage(this, channel, sender, args); } }
Example #6
Source File: KickCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length >= 1) { User user = GuildUtils.getUser(args[0], guild.getGuildId()); if (user == null) { MessageUtils.sendErrorMessage("We cannot find that user! Try their ID if you didn't already.", channel, sender); return; } Member target = guild.getGuild().getMember(user); if (target == null) { MessageUtils.sendErrorMessage("That user is not on this server therefore cannot be kicked!", channel, sender); return; } String reason = null; if (args.length >= 2) reason = MessageUtils.getMessage(args, 1); ModlogHandler.getInstance().handleAction(guild, channel, sender, user, ModAction.KICK, reason); } else { MessageUtils.sendUsage(this, channel, sender, args); } }
Example #7
Source File: MuteCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length == 0) { MessageUtils.sendUsage(this, channel, sender, args); } else { User user = GuildUtils.getUser(args[0], guild.getGuildId()); if (user == null) { MessageUtils.sendErrorMessage("Invalid user!!", channel); return; } if (guild.getMutedRole() == null) { MessageUtils.sendErrorMessage("Error getting the \"Muted\" role! Check FlareBot has permissions to create it!", channel); return; } String reason = args.length > 1 ? MessageUtils.getMessage(args, 1) : null; ModlogHandler.getInstance().handleAction(guild, channel, sender, user, ModAction.MUTE, reason); } }
Example #8
Source File: MuteHanlder.java From DiscordBot with Apache License 2.0 | 6 votes |
@Override public void onMessageReceived(MessageReceivedEvent e) { User sender = e.getAuthor(); HashMap<String, String> mutes = commands.guildAdministration.Mute.getMuted(); if (mutes.containsKey(sender.getId())) { sender.openPrivateChannel().queue(pc -> pc.sendMessage( new EmbedBuilder().setColor(Color.orange).setDescription( "You can not write on this server, because you are muted in text channels!\n" + "Please contact an Supporter, Moderator or Admin to unmute.\n\n" + "Mute Reason: `" + mutes.get(sender.getId()) + "`" ).build() ).queue()); e.getMessage().delete().queue(); } }
Example #9
Source File: TempMuteCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length < 2) { MessageUtils.sendUsage(this, channel, sender, args); } else { User user = GuildUtils.getUser(args[0], guild.getGuildId()); if (user == null) { MessageUtils.sendErrorMessage("Invalid user!!", channel); return; } if (guild.getMutedRole() == null) { MessageUtils.sendErrorMessage("Error getting the \"Muted\" role! Check FlareBot has permissions to create it!", channel); return; } Period period; if ((period = GeneralUtils.getTimeFromInput(args[1], channel)) == null) return; String reason = args.length >= 3 ? MessageUtils.getMessage(args, 2) : null; ModlogHandler.getInstance().handleAction(guild, channel, sender, user, ModAction.TEMP_MUTE, reason, period.toStandardDuration().getMillis()); } }
Example #10
Source File: Main.java From DiscordBot with Apache License 2.0 | 6 votes |
public static void handleCommand(CommandParser.CommandContainer cmd) throws ParseException, IOException { if (commands.containsKey(cmd.invoke.toLowerCase())) { BotStats.commandsExecuted++; boolean safe = commands.get(cmd.invoke.toLowerCase()).called(cmd.args, cmd.event); if (!safe) { commands.get(cmd.invoke.toLowerCase()).action(cmd.args, cmd.event); commands.get(cmd.invoke.toLowerCase()).executed(safe, cmd.event); } else { commands.get(cmd.invoke.toLowerCase()).executed(safe, cmd.event); } List<TextChannel> tcs = cmd.event.getGuild().getTextChannelsByName("cmdlog", true); if (tcs.size() > 0) { User author = cmd.event.getAuthor(); EmbedBuilder eb = new EmbedBuilder() .setColor(Color.orange) .setAuthor(author.getName() + "#" + author.getDiscriminator(), null, author.getAvatarUrl()) .setDescription("```" + cmd.event.getMessage().getContent() + "```") .setFooter(CoreCommands.getCurrentSystemTime(), null); tcs.get(0).sendMessage(eb.build()).queue(); } } }
Example #11
Source File: SoftBanCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length >= 1) { User target = GuildUtils.getUser(args[0], guild.getGuildId()); if (target == null) { MessageUtils.sendErrorMessage("We cannot find that user! Try their ID if you didn't already.", channel, sender); return; } String reason = null; if (args.length >= 2) reason = MessageUtils.getMessage(args, 1); ModlogHandler.getInstance().handleAction(guild, channel, sender, target, ModAction.SOFTBAN, reason); } else { MessageUtils.sendUsage(this, channel, sender, args); } }
Example #12
Source File: WarnCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length == 0) { MessageUtils.sendUsage(this, channel, sender, args); } else { User user = GuildUtils.getUser(args[0]); if (user == null) { MessageUtils.sendErrorMessage("We couldn't find that user!!", channel); return; } String reason = null; if (args.length >= 2) reason = MessageUtils.getMessage(args, 1); ModlogHandler.getInstance().handleAction(guild, channel, sender, user, ModAction.WARN, reason); } }
Example #13
Source File: FlareBotManager.java From FlareBot with MIT License | 6 votes |
public ArrayList<String> loadPlaylist(TextChannel channel, User sender, String name) { final ArrayList<String> list = new ArrayList<>(); CassandraController.runTask(session -> { if (loadPlaylistStatement == null) loadPlaylistStatement = session.prepare("SELECT songs FROM " + "flarebot.playlist WHERE playlist_name = ? AND guild_id = ?"); ResultSet set = session.execute(loadPlaylistStatement.bind().setString(0, name).setString(1, channel.getGuild().getId())); Row row = set.one(); if (row != null) { list.addAll(row.getList("songs", String.class)); } else channel.sendMessage(MessageUtils.getEmbed(sender) .setDescription("That playlist does not exist!").build()).queue(); }); return list; }
Example #14
Source File: BanCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length >= 1) { User target = GuildUtils.getUser(args[0], guild.getGuildId()); if (target == null) { MessageUtils.sendErrorMessage("We cannot find that user! Try their ID if you didn't already.", channel, sender); return; } String reason = null; if (args.length >= 2) reason = MessageUtils.getMessage(args, 1); ModlogHandler.getInstance().handleAction(guild, channel, sender, target, ModAction.BAN, reason); } else { MessageUtils.sendUsage(this, channel, sender, args); } }
Example #15
Source File: UnmuteCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length >= 1) { User target = GuildUtils.getUser(args[0]); if (target == null) { MessageUtils.sendErrorMessage("We cannot find that user! Try their ID if you didn't already.", channel, sender); return; } String reason = null; if (args.length >= 2) reason = MessageUtils.getMessage(args, 1); ModlogHandler.getInstance().handleAction(guild, channel, sender, target, ModAction.UNMUTE, reason); } else { MessageUtils.sendUsage(this, channel, sender, args); } }
Example #16
Source File: UnbanCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length >= 1) { User target = GuildUtils.getUser(MessageUtils.getMessage(args, 0), null, true); if (target == null) { MessageUtils.sendErrorMessage("We cannot find that user! Try their ID if you didn't already.\n" + "To get a User ID simply enable developer mode by going to User Settings > Appearance " + "> Developer Mode then just right click the user and click Copy ID", channel, sender); return; } ModlogHandler.getInstance().handleAction(guild, channel, sender, target, ModAction.UNBAN, null); } else { MessageUtils.sendUsage(this, channel, sender, args); } }
Example #17
Source File: ChangelogCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message msg, String[] args, Member member) { if (PerGuildPermissions.isAdmin(sender)) { if (args.length == 0) { channel.sendMessage("Specify a version or PR to post about!").queue(); return; } if (args[0].startsWith("pr:")) { channel.sendMessage(new MessageBuilder().setEmbed(GitHubUtils.getEmbedForPR(args[0].substring(3)) .build()).build()).queue(); } else { String message = msg.getContentRaw(); message = message.substring(message.indexOf(" ") + 1); channel.sendMessage(message).queue(); } } }
Example #18
Source File: HelpCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length == 1) { CommandType type; try { type = CommandType.valueOf(args[0].toUpperCase()); } catch (IllegalArgumentException ignored) { channel.sendMessage(MessageUtils.getEmbed(sender).setDescription("No such category!").build()).queue(); return; } if (type.isInternal() && !GeneralUtils.canRunInternalCommand(type, sender)) { channel.sendMessage(MessageUtils.getEmbed(sender).setDescription("No such category!").build()).queue(); return; } sendCommands(guild, channel, member, type); } else sendCommands(channel.getGuild(), channel, sender); }
Example #19
Source File: SetPrefixCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length == 1) { if (args[0].equalsIgnoreCase("reset")) { guild.setPrefix('_'); MessageUtils.sendInfoMessage("Reset the prefix back to `_`!", channel, sender); } else if (args[0].length() == 1) { guild.setPrefix(args[0].charAt(0)); channel.sendMessage(MessageUtils.getEmbed(sender) .setDescription(String.format("Set the prefix to `%s`", args[0])).build()) .queue(); } else { MessageUtils.sendErrorMessage("Cannot set the prefix to be more that one character long!", channel, sender); } } else { channel.sendMessage(MessageUtils.getEmbed(sender) .setDescription(String.format("Current guild prefix is `%s`!", guild.getPrefix())).build()).queue(); } }
Example #20
Source File: JoinCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (member.getVoiceState().inVoiceChannel()) { if (channel.getGuild().getAudioManager().isAttemptingToConnect()) { MessageUtils.sendErrorMessage("Currently connecting to a voice channel! Try again soon!", channel); return; } if (channel.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && !channel.getGuild() .getSelfMember() .getVoiceState() .getAudioChannel() .getId() .equals(member .getVoiceState() .getAudioChannel() .getId()) && !getPermissions(channel).hasPermission(member, Permission.JOIN_OTHER)) { MessageUtils.sendErrorMessage("You need the permission `" + Permission.JOIN_OTHER + "` for me to join your voice channel while I'm in one!", channel); return; } GuildUtils.joinChannel(channel, member); } }
Example #21
Source File: BetaCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { String betaInfo = FormatUtils.formatCommandPrefix(guild, FlareBot.getCommandManager().getCommands() .stream() .filter(Command::isBetaTesterCommand) .map(c -> "`{%}" + c.getCommand() + "` - " + c.getDescription()) .collect(Collectors.joining("\n"))); String betaMessage = guild.hasBetaAccess() ? "Thank you for being apart of our beta program! Please report any bugs or give us suggestions over at the [support discord](" + Constants.INVITE_URL + ")!" : "Listed below are the commands you can gain access to by being a part of our beta program! To join the beta program, you will either need to win " + "beta access through a giveaway (Make sure you are in the [support server](" + Constants.INVITE_URL + ") to hear of these!) or you can become apart of the " + "Donator tier or higher on our [patreon page](https://www.patreon.com/flarebot)!"; EmbedBuilder builder = MessageUtils.getEmbed(sender); builder.setColor(Color.CYAN); builder.setDescription(betaMessage); builder.addField("Beta Commands", betaInfo, false); channel.sendMessage(builder.build()).queue(); }
Example #22
Source File: Say.java From DiscordBot with Apache License 2.0 | 6 votes |
@Override public void action(String[] args, MessageReceivedEvent event) { if (core.Perms.check(1, event)) return; String msg = String.join(" ", args); User author = event.getMessage().getAuthor(); event.getMessage().delete().queue(); event.getTextChannel().sendMessage(new EmbedBuilder() .setColor(Color.cyan) .setAuthor(author.getName(), null, author.getAvatarUrl()) .setDescription(msg) .build() ).queue(); }
Example #23
Source File: ShardInfoCommand.java From FlareBot with MIT License | 6 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { PagedTableBuilder tb = new PagedTableBuilder(); tb.addColumn("Shard ID"); tb.addColumn("Status"); tb.addColumn("Ping"); tb.addColumn("Guild Count"); tb.addColumn("Connected VCs"); List<JDA> shards = new ArrayList<>(Getters.getShards()); Collections.reverse(shards); for (JDA jda : shards) { List<String> row = new ArrayList<>(); row.add(ShardUtils.getDisplayShardId(jda) + (ShardUtils.getShardId(channel.getJDA()) == ShardUtils.getShardId(jda) ? " (You)" : "")); row.add(WordUtils.capitalizeFully(jda.getStatus().toString().replace("_", " "))); row.add(String.valueOf(jda.getPing())); row.add(String.valueOf(jda.getGuilds().size())); row.add(String.valueOf(jda.getVoiceChannels().stream().filter(vc -> vc.getMembers().contains(vc.getGuild() .getSelfMember())).count())); tb.addRow(row); } PaginationUtil.sendPagedMessage(channel, tb.build(), 0, sender, ButtonGroupConstants.SHARDINFO); }
Example #24
Source File: UpdateJDACommand.java From FlareBot with MIT License | 5 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length == 1) { String version = args[0]; try { File f = new File("pom.xml"); Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f); Node jdaNode = doc.getElementsByTagName("dependency").item(0); NodeList children = jdaNode.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node node = children.item(i); if (node.getNodeName().equalsIgnoreCase("version")) node.setTextContent(version); } DOMSource source = new DOMSource(doc); TransformerFactory.newInstance().newTransformer().transform(source, new StreamResult(f)); channel.sendMessage("Updated to JDA version `" + version + "`\n" + "I will now restart in 10 minutes and apply the update!").queue(); new FlareBotTask("JDA-Update") { @Override public void run() { FlareBot.instance().quit(true); } }.delay(TimeUnit.MINUTES.toMillis(10)); // _update-jda 3.3.1_306 } catch (SAXException | IOException | ParserConfigurationException | TransformerException e) { FlareBot.LOGGER.error("Failed to parse the pom file!", e); channel.sendMessage("Parsing failed! " + e.getMessage()).queue(); } } }
Example #25
Source File: DonateCommand.java From FlareBot with MIT License | 5 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { EmbedBuilder builder = MessageUtils.getEmbed(sender); builder.setColor(Color.CYAN); builder.setDescription("Thank for you taking the time to see how you can donate to the project! This project relies heavily upon user donations so every little helps! \uD83D\uDE0A"); builder.addField("Patreon", "The most common way to donate is through our [Patreon page](https://www.patreon.com/flarebot)! Through here you can donate the amount you want and also get rewarded for it!", false); builder.addField("PayPal", "If you cannot donate through Patreon or don't like the idea of a monthly subscription then this option is for you! Simply join our [support server](" + Constants.INVITE_URL + ") and our amazing staff will assist you in doing this!\n\nShould you want to donate anonymously or you don't want to receive a reward, you can simply send money to `[email protected]` via PayPal to donate!", false); channel.sendMessage(builder.build()).queue(); }
Example #26
Source File: InfoCommand.java From FlareBot with MIT License | 5 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length == 0) { EmbedBuilder bld = MessageUtils.getEmbed() .setThumbnail(MessageUtils.getAvatar(channel.getJDA().getSelfUser())) .setFooter("Made by Walshy#9060 and BinaryOverload#2382", channel.getJDA().getSelfUser().getEffectiveAvatarUrl()); bld.setDescription("FlareBot v" + FlareBot.getVersion() + " info") .setColor(Color.CYAN); for (Content content : Content.values) { bld.addField(content.getName(), content.getReturn(), content.isAlign()); } channel.sendMessage(bld.build()).queue(); } else GeneralUtils.handleMultiSelectionCommand(sender, channel, args, Content.values); }
Example #27
Source File: Broadcast.java From DiscordBot with Apache License 2.0 | 5 votes |
@Override public void action(String[] args, MessageReceivedEvent event) throws ParseException, IOException { if (!Perms.isOwner(event.getAuthor(), event.getTextChannel())) return; if (args.length < 1) { event.getTextChannel().sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(help()).build()).queue(); return; } String message = String.join(" ", args); User author = event.getAuthor(); EmbedBuilder eb = new EmbedBuilder() .setColor(Color.cyan) .setAuthor(author.getName(), null, author.getAvatarUrl()) .setDescription(message) .setFooter("This is a broadcast message send by bots host user.", "https://raw.githubusercontent.com/zekroTJA/DiscordBot/dev/.websrc/zekrobot_message.png"); List<Guild> ignores = getIgnores(event.getJDA()); event.getJDA().getGuilds().stream() .filter(g -> !ignores.contains(g)) .forEach(g -> { try { g.getPublicChannel().sendMessage(eb.build()).queue(); } catch (Exception e) { } }); }
Example #28
Source File: ResumeCommand.java From FlareBot with MIT License | 5 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { Player player = FlareBot.instance().getMusicManager().getPlayer(guild.getGuildId()); if (player.getPlayingTrack() == null) { MessageUtils.sendErrorMessage("There is no music playing!", channel); } else if (!player.getPaused()) { MessageUtils.sendErrorMessage("The music is already playing!", channel); } else { player.play(); MessageUtils.sendSuccessMessage("Resuming...!", channel); } }
Example #29
Source File: SeekCommand.java From FlareBot with MIT License | 5 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { if (args.length == 1) { Long millis = GeneralUtils.parseTime(args[0]); if (millis == null || millis > Integer.MAX_VALUE) { MessageUtils.sendErrorMessage("You have entered an invalid duration to skip to!\n" + getExtraInfo(), channel); return; } Track t = FlareBot.instance().getMusicManager().getPlayer(guild.getGuildId()).getPlayingTrack(); if (t == null) { MessageUtils.sendErrorMessage("There is no song currently playing!", channel); return; } else { if (t.getTrack().getInfo().isStream) { MessageUtils.sendErrorMessage("Cannot seek on a livestream!", channel); return; } else if (!t.getTrack().isSeekable()) { MessageUtils.sendErrorMessage("Cannot seek on this track!", channel); return; } else { if (millis >= t.getTrack().getDuration()) { MessageUtils.sendErrorMessage("The duration specified is bigger than the length of the video!", channel); return; } else { t.getTrack().setPosition(millis); MessageUtils.sendSuccessMessage("The track has been skipped to: " + FormatUtils.formatJodaTime(new Duration(millis).toPeriod()), channel); return; } } } } MessageUtils.sendUsage(this, channel, sender, args); }
Example #30
Source File: LoopCommand.java From FlareBot with MIT License | 5 votes |
@Override public void onCommand(User sender, GuildWrapper guild, TextChannel channel, Message message, String[] args, Member member) { Player player = FlareBot.instance().getMusicManager().getPlayer(channel.getGuild().getId()); if (!player.getLooping()) { player.setLooping(true); channel.sendMessage("Looping: **ON**").queue(); } else { player.setLooping(false); channel.sendMessage("Looping: **OFF**").queue(); } }