else if (channelType.isGuild())
@Override public boolean isGuildMessage() { return message.getChannelType().isGuild(); }
@Override public boolean handle(@Nonnull Message message, @Nonnull MiddlewareStack stack, String... args) { return !message.getChannelType().isGuild() && stack.next(); } }
if (type.isGuild())
if (type.isGuild())
/** * Fetches the guild transformer from the cache, if it doesn't exist in the * cache it will be loaded into the cache and then returned afterwords. * * @param avaire The avaire instance, used to talking to the database. * @param message The JDA message instance for the current message. * @return Possibly null, the guild transformer instance for the current guild, or null. */ @CheckReturnValue public static GuildTransformer fetchGuild(AvaIre avaire, Message message) { if (!message.getChannelType().isGuild()) { return null; } return fetchGuild(avaire, message.getGuild()); }
/** * Fetches a collection of reaction roles/messages for the server the message was * sent in, if the server doesn't have any reaction roles an empty collection * will be returned instead, if the message was not sent in a server then * {@code NULL} will be returned. * * @param avaire The avaire instance, used to talking to the database. * @param message The JDA message instance for the current message. * @return Possibly null, the reaction collections for the current guild, or null. */ @CheckReturnValue public static Collection fetchReactions(AvaIre avaire, Message message) { if (!message.getChannelType().isGuild()) { return null; } return fetchReactions(avaire, message.getGuild()); }
static String toGuild(Message message, String string) { if (!message.getChannelType().isGuild() || string == null) return string; return parseGuild(message.getGuild(), string); }
/** * Converts the message object to a guild object and parses the guild * and string to the {@link #parseGuild(Guild, String)} method. * * @param message The message that the guild should be retrieved from. * @param string The original string that should be parsed. * @return The parsed string if the given message contains a valid guild instance, * otherwise it will just return the original unchanged string. */ private static String toGuild(Message message, String string) { if (!message.getChannelType().isGuild()) { return string; } return parseGuild(message.getGuild(), string); }
private String generateServer(Message message) { if (!message.getChannelType().isGuild()) { return "PRIVATE"; } return String.format(propertyOutput, message.getGuild().getName(), message.getGuild().getId() ); }
private CharSequence generateChannel(Message message) { if (!message.getChannelType().isGuild()) { return "PRIVATE"; } return String.format(propertyOutput, message.getChannel().getName(), message.getChannel().getId() ); }
private String generateServer(Message message) { if (!message.getChannelType().isGuild()) { return ConsoleColor.GREEN + "PRIVATE"; } return String.format(propertyOutput, message.getGuild().getName(), message.getGuild().getId() ); }
private CharSequence generateChannel(Message message) { if (!message.getChannelType().isGuild()) { return ConsoleColor.GREEN + "PRIVATE"; } return String.format(propertyOutput, message.getChannel().getName(), message.getChannel().getId() ); }
/** * Checks if the author of the message, of the message was * sent in a guild, that the guild is on the blacklist. * * @param message The message that should be checked. * @return <code>True</code> if either the user, or the entire * server is blacklisted, <code>False</code> otherwise. */ public boolean isBlacklisted(@Nonnull Message message) { return isBlacklisted(message.getAuthor()) || (message.getChannelType().isGuild() && isBlacklisted(message.getGuild())); }
private boolean isServerVIP(MiddlewareStack stack, Message message) { if (!message.getChannelType().isGuild()) { return false; } GuildTransformer transformer = stack.getDatabaseEventHolder().getGuild(); return transformer != null && !transformer.getType().isDefault(); } }
private boolean canExecuteCommand(MessageReceivedEvent event, CommandContainer container) { if (!container.getCommand().isAllowedInDM() && !event.getChannelType().isGuild()) { MessageFactory.makeWarning(event.getMessage(), ":warning: You can not use this command in direct messages!").queue(); return false; } return true; }
private CompletableFuture<DatabaseEventHolder> loadDatabasePropertiesIntoMemory(final MessageReceivedEvent event) { return CompletableFuture.supplyAsync(() -> { if (!event.getChannelType().isGuild()) { return new DatabaseEventHolder(null, null); } GuildTransformer guild = GuildController.fetchGuild(avaire, event.getMessage()); if (guild == null || !guild.isLevels() || event.getAuthor().isBot()) { return new DatabaseEventHolder(guild, null); } return new DatabaseEventHolder(guild, PlayerController.fetchPlayer(avaire, event.getMessage())); }); }
@CheckReturnValue public static Collection fetchPlaylists(AvaIre avaire, Message message) { if (!message.getChannelType().isGuild()) { return null; } return (Collection) CacheUtil.getUncheckedUnwrapped(cache, message.getGuild().getIdLong(), () -> { try { return avaire.getDatabase().newQueryBuilder(Constants.MUSIC_PLAYLIST_TABLE_NAME) .selectAll().where("guild_id", message.getGuild().getId()) .get(); } catch (Exception e) { AvaIre.getLogger().error("Failed to fetch playlists for server " + message.getGuild().getId(), e); return null; } }); }
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 void onIntent(CommandMessage context, AIResponse response) { String nickname = context.getAuthor().getName(); if (context.getMessage().getChannelType().isGuild()) { nickname = context.getMember().getEffectiveName(); } context.makeInfo(StringReplacementUtil.replaceAll( response.getResult().getFulfillment().getSpeech(), "%nick%", nickname )).queue(); } }