Checks.check(channels.stream().allMatch(c -> guild.equals(c.getGuild())), "One or more channels are not from the correct guild"); Checks.check(channels.stream().allMatch(c -> c.getType().equals(type)), "One or more channels did not match the expected type of " + type.name());
public void addReactionListener(long guildId, Message message, CommandReactionListener<?> handler) { if (handler == null) { return; } if (message.getChannelType().equals(ChannelType.TEXT)) { if (!PermissionUtil.checkPermission(message.getTextChannel(), message.getGuild().getSelfMember(), Permission.MESSAGE_ADD_REACTION)) { return; } } if (!reactions.containsKey(guildId)) { reactions.put(guildId, new ConcurrentHashMap<>()); } if (!reactions.get(guildId).containsKey(message.getIdLong())) { for (String emote : handler.getEmotes()) { message.addReaction(emote).complete(); } reactions.get(guildId).put(message.getIdLong(), handler); } }
public String formatGuild(MessageChannel channel, Object... vars) { if (channel.getType().equals(ChannelType.TEXT)) { return formatFull(((TextChannel) channel).getGuild().getIdLong(), false, vars); } return formatFull(0, false, vars); }
if (channel.getType().equals(ChannelType.TEXT) && !PermissionUtil.checkPermission((TextChannel) channel, ((TextChannel) channel).getGuild().getSelfMember(), Permission.MESSAGE_ATTACH_FILES)) { return Templates.permission_missing.formatGuild(channel, "MESSAGE_ATTACH_FILES");
@Override public boolean onCommand(CommandMessage context, String[] args) { if (args.length == 0) { return sendErrorMessage(context, context.i18n("missingArgument")); } Channel channel = MentionableUtil.getChannel(context.getMessage(), args); if (channel == null) { return handleSlowmode(context, context.getChannel(), args); } if (!channel.getType().equals(ChannelType.TEXT)) { return sendErrorMessage(context, "invalidTextChannel", channel.getName()); } return handleSlowmode(context, (TextChannel) channel, Arrays.copyOfRange(args, 1, args.length)); }
public void editBlocking(Message msg, String newContent) { if (!msg.getChannelType().equals(ChannelType.TEXT)) { return; } TextChannel channel = botInstance.getJda().getTextChannelById(msg.getTextChannel().getId()); if (channel == null) { return; } botInstance.queue.add(channel.editMessageById(msg.getId(), newContent)); }
return sb.toString(); case "debug": if (userRank.isAtLeast(SimpleRank.GUILD_ADMIN) && channel.getType().equals(ChannelType.TEXT)) { Guild guild = ((TextChannel) channel).getGuild(); if (args.length == 1) {
public final boolean executeReaction(User player, MessageChannel channel, MessageReaction reaction, String messageId) { if (!channel.getType().equals(ChannelType.TEXT) || !reactionMessages.containsKey(messageId)) { return false; } if (!isInAGame(player.getId())) { return false; } if (!getGame(player.getId()).isTurnOf(player)) { return false; } final String input = Misc.emoteToNumber(reaction.getReactionEmote().getName()); Message msg = channel.getMessageById(messageId).complete(); if (msg == null) { return false; } execute(player, (TextChannel) channel, input, msg); return true; }
if (object instanceof Message && ((Message) object).getChannelType().equals(ChannelType.TEXT)) { return parseChannel(((Message) object).getTextChannel(), message);
private void handleReaction(GenericMessageReactionEvent e, boolean adding) { if (e.getUser().isBot()) { if (!discordBot.security.isInteractionBot(e.getUser().getIdLong())) { return; } } if (!e.getChannel().getType().equals(ChannelType.TEXT)) { return; } TextChannel channel = (TextChannel) e.getChannel(); if (discordBot.commandReactionHandler.canHandle(channel.getGuild().getIdLong(), e.getMessageIdLong())) { discordBot.commandReactionHandler.handle(channel, e.getMessageIdLong(), e.getUser().getIdLong(), e.getReaction()); return; } if (!discordBot.gameHandler.executeReaction(e.getUser(), e.getChannel(), e.getReaction(), e.getMessageId())) { if (!discordBot.musicReactionHandler.handle(e.getMessageIdLong(), channel, e.getUser(), e.getReactionEmote(), adding)) { discordBot.roleReactionHandler.handle(e.getMessageId(), channel, e.getUser(), e.getReactionEmote(), adding); } } }