@Override public MessageAction sendMessage(CharSequence text) { checkVerification(); checkPermission(Permission.MESSAGE_READ); checkPermission(Permission.MESSAGE_WRITE); return TextChannel.super.sendMessage(text); }
@Override public MessageAction sendMessage(MessageEmbed embed) { checkVerification(); checkPermission(Permission.MESSAGE_READ); checkPermission(Permission.MESSAGE_WRITE); // this is checked because you cannot send an empty message checkPermission(Permission.MESSAGE_EMBED_LINKS); return TextChannel.super.sendMessage(embed); }
@Override public MessageAction sendMessage(Message msg) { Checks.notNull(msg, "Message"); checkVerification(); checkPermission(Permission.MESSAGE_READ); checkPermission(Permission.MESSAGE_WRITE); if (msg.getContentRaw().isEmpty() && !msg.getEmbeds().isEmpty()) checkPermission(Permission.MESSAGE_EMBED_LINKS); //Call MessageChannel's default return TextChannel.super.sendMessage(msg); }
@Override public void noMatches() { channel.sendMessage("Nothing found by " + trackUrl).queue(); }
@Override public void loadFailed(FriendlyException exception) { channel.sendMessage("Could not play: " + exception.getMessage()).queue(); } });
/** * Sends an embed button message with a set of buttons. * * @param channel The TextChannel to send it to. * @param embed The embed to send. * @param buttons The buttons to display. */ public static void sendButtonedMessage(TextChannel channel, MessageEmbed embed, ButtonGroup buttons) { channel.sendMessage(embed).queue(message -> handleSuccessConsumer(channel, message, buttons)); }
@Override public void loadFailed(FriendlyException exception) { TextChannel musicChannel = bot.getMusicChannel(guildId); if (musicChannel != null) { bot.queue.add(musicChannel.sendMessage(String.format("can't play `%s`. Reason: %s", trackToAdd.youtubecode, exception.getMessage()))); } if (finalKeepGoing) { trackEnded(); } } });
@Override public void trackLoaded(AudioTrack track) { channel.sendMessage("Adding to queue " + track.getInfo().title).queue(); play(channel.getGuild(), musicManager, track); }
@Override public void onTrackStart(AudioPlayer player, AudioTrack track) { TextChannel textChannel = musicBot.getShardManager().getTextChannelById(textChannelId); if (textChannel == null) { // todo what if the text channel is deleted logger.error("Error getting text channel with ID {} from shard manager", textChannelId); return; } textChannel.sendMessage(String.format("Now playing **%s** by **%s** `[%s]`", track.getInfo().title, track.getInfo().author, Utils.formatTrackDuration(track))).complete(); }
private static void doTheUpdate(TextChannel channel, String latestVersion, String currentVersion) { FlareBot.instance().setStatus("Updating.."); if (channel != null) channel.sendMessage("Updating to version `" + latestVersion + "` from `" + currentVersion + "`").queue(); FlareBot.UPDATING.set(true); FlareBot.instance().quit(true); }
private void skipTrack(TextChannel channel) { GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild()); musicManager.scheduler.nextTrack(); channel.sendMessage("Skipped to next track.").queue(); }
@Override public void playlistLoaded(AudioPlaylist playlist) { AudioTrack firstTrack = playlist.getSelectedTrack(); if (firstTrack == null) { firstTrack = playlist.getTracks().get(0); } channel.sendMessage("Adding to queue " + firstTrack.getInfo().title + " (first track of playlist " + playlist.getName() + ")").queue(); play(channel.getGuild(), musicManager, firstTrack); }
@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(); } }
public static void sendPM(TextChannel channel, User user, String message, String fail) { user.openPrivateChannel().queue(pc -> pc.sendMessage(message).queue(), t -> { channel.sendMessage(fail).queue(); }); }
protected void sendTo(TextChannel channel, MessageEmbed message) { if (PermissionUtil.checkPermission(channel, channel.getGuild().getSelfMember(), Permission.MESSAGE_EMBED_LINKS)) { bot.getShardFor(channel.getGuild().getId()).queue.add(channel.sendMessage(message)); } }
public static void sendPM(TextChannel channel, User user, EmbedBuilder message) { try { user.openPrivateChannel().complete().sendMessage(message.build()).complete(); } catch (ErrorResponseException e) { channel.sendMessage(message.build()).queue(); } }
@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 `walshydev@gmail.com` via PayPal to donate!", false); channel.sendMessage(builder.build()).queue(); }
@Override public void run() { tc.get().getPermissionOverride(guild.getGuild().getPublicRole()).getManager() .clear(Permission.MESSAGE_WRITE) .queue(); if (guild.getGuild().getSelfMember().hasPermission(tc.get(), Permission.MESSAGE_WRITE)) channel.sendMessage(new EmbedBuilder().setColor(ColorUtils.GREEN) .setDescription("The chat has been unlocked") .build()).queue(); } }.delay(time);
public static void logEG(String eg, Command command, Guild guild, User user) { EmbedBuilder builder = new EmbedBuilder().setTitle("Found `" + eg + "`") .addField("Guild", guild.getId() + " (`" + guild.getName() + "`) ", true) .addField("User", user.getAsMention() + " (`" + user.getName() + "#" + user.getDiscriminator() + "`)", true) .setTimestamp(LocalDateTime.now(Clock.systemUTC())); if (command != null) builder.addField("Command", command.getCommand(), true); Constants.getEGLogChannel().sendMessage(builder.build()).queue(); }
private void credit(JDA jda) { Guild dbots = jda.getGuildById(110373943822540800L); if(dbots==null) return; if(bot.getConfig().getDBots()) return; jda.getTextChannelById(119222314964353025L) .sendMessage("This account is running JMusicBot. Please do not list bot clones on this server, <@"+bot.getConfig().getOwnerId()+">.").complete(); dbots.leave().queue(); } }