public MessageReceivedEvent(JDA api, long responseNumber, Message message) { super(api, responseNumber, message.getIdLong(), message.getChannel()); this.message = message; }
private CharSequence generateChannel(Message message) { if (!message.getChannelType().isGuild()) { return ConsoleColor.GREEN + "PRIVATE"; } return String.format(propertyOutput, message.getChannel().getName(), message.getChannel().getId() ); }
public MessageUpdateEvent(JDA api, long responseNumber, Message message) { super(api, responseNumber, message.getIdLong(), message.getChannel()); this.message = message; }
private CharSequence generateChannel(Message message) { if (!message.getChannelType().isGuild()) { return "PRIVATE"; } return String.format(propertyOutput, message.getChannel().getName(), message.getChannel().getId() ); }
@Override public MessageChannel getChannel() { return message.getChannel(); }
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)); }
@Override public MessageChannel getMessageChannel() { return message.getChannel(); }
public PlaceholderMessage makeEmbeddedMessage(Color color, MessageEmbed.Field... fields) { return MessageFactory.makeEmbeddedMessage(this.message.getChannel(), color, fields); }
public PlaceholderMessage makeEmbeddedMessage() { return MessageFactory.makeEmbeddedMessage(this.message.getChannel()); }
/** * Replies to a {@link Message}, usefull when interacting with private * message channels without having to open a new channel every time * * @param message The message you want to reply * @param reply The reply for that message */ public void replyTo(Message message, String reply) { message.getChannel().sendMessage(reply).queue(); }
public static PlaceholderMessage makeEmbeddedMessage(Message jdaMessage, Color color, String message) { return new PlaceholderMessage(jdaMessage.getChannel(), createEmbeddedBuilder().setColor(color), message ).setGlobalPlaceholderType(PlaceholderType.ALL, jdaMessage); }
public static void remove(UUID uuid, Guild guild) { VoteGroup group = groupMap.get(uuid + guild.getId()); if (group == null) return; long message = group.getMessageId(); groupMap.remove(uuid + guild.getId()); Scheduler.cancelTask("Vote-" + message); group.getVoteMessage().getChannel().deleteMessageById(group.getMessageId()).queue(); }
public static PlaceholderMessage makeError(Message jdaMessage, String message) { return new PlaceholderMessage(jdaMessage.getChannel(), createEmbeddedBuilder().setColor(MessageType.ERROR.getColor()), message ).setGlobalPlaceholderType(PlaceholderType.ALL, jdaMessage); }
public static PlaceholderMessage makeSuccess(Message jdaMessage, String message) { return new PlaceholderMessage(jdaMessage.getChannel(), createEmbeddedBuilder().setColor(MessageType.SUCCESS.getColor()), message ).setGlobalPlaceholderType(PlaceholderType.ALL, jdaMessage); }
public static PlaceholderMessage makeWarning(Message jdaMessage, String message) { return new PlaceholderMessage(jdaMessage.getChannel(), createEmbeddedBuilder().setColor(MessageType.WARNING.getColor()), message ).setGlobalPlaceholderType(PlaceholderType.ALL, jdaMessage); }
public static PlaceholderMessage makeInfo(Message jdaMessage, String message) { return new PlaceholderMessage(jdaMessage.getChannel(), createEmbeddedBuilder().setColor(MessageType.INFO.getColor()), message ).setGlobalPlaceholderType(PlaceholderType.ALL, jdaMessage); }
public static void finishNow(UUID uuid, Guild guild) { VoteGroup group = groupMap.get(uuid + guild.getId()); String message = group.getVoteMessage().getId(); groupMap.remove(uuid + guild.getId()); runnableMap.get(uuid + guild.getId()).run(group.won()); runnableMap.remove(uuid + guild.getId()); Scheduler.cancelTask("Votes-" + message); group.getVoteMessage().getChannel().deleteMessageById(group.getVoteMessage().getId()).queue(); } }
@Override public boolean onCommand(CommandMessage context, String[] args) { long start = System.currentTimeMillis(); context.getMessage().getChannel().sendTyping().queue(v -> { long ping = System.currentTimeMillis() - start; context.makeInfo(context.i18n("message")) .set("heartbeat", context.getJDA().getPing()) .set("rating", ratePing(context, ping)) .set("ping", ping) .queue(); }); return true; }
@Override public boolean handle(@Nonnull Message message, @Nonnull MiddlewareStack stack, String... args) { if (avaire.getVoteManager().isEnabled() && isServerVIP(stack, message)) { return stack.next(); } if (avaire.getVoteManager().hasVoted(message.getAuthor())) { return stack.next(); } return runMessageCheck(message, () -> { avaire.getVoteManager().getMessenger().sendMustVoteMessage(message.getChannel()); return false; }); }
/** * Retrieves the message again before deleting it * Mostly for delayed deletion * * @param messageToDelete the message to delete */ public void saveDelete(Message messageToDelete) { if (messageToDelete != null && botInstance.getJda() == messageToDelete.getJDA()) { TextChannel channel = botInstance.getJda().getTextChannelById(messageToDelete.getChannel().getId()); if (channel != null && PermissionUtil.checkPermission(channel, channel.getGuild().getSelfMember(), Permission.MESSAGE_HISTORY)) { botInstance.queue.add(channel.deleteMessageById(messageToDelete.getId())); } } }