/** * The {@link net.dv8tion.jda.core.entities.Guild Guild} * <br>Shortcut for {@code getChannel().getGuild()} * * @return The Guild */ public Guild getGuild() { return channel.getGuild(); } }
public GenericGuildMessageEvent(JDA api, long responseNumber, long messageId, TextChannel channel) { super(api, responseNumber, channel.getGuild()); this.messageId = messageId; this.channel = channel; }
@Override public Guild getGuild() { return channel.getGuild(); }
/** * The {@link net.dv8tion.jda.core.entities.Guild Guild} where the messages were deleted. * * @return The Guild */ public Guild getGuild() { return channel.getGuild(); }
/** * The {@link net.dv8tion.jda.core.entities.Guild Guild} this Reaction was used in, * this might return {@code null} when this Reaction was not used in a MessageChannel * from the ChannelType {@link net.dv8tion.jda.core.entities.ChannelType#TEXT TEXT}! * * @return {@link net.dv8tion.jda.core.entities.Guild Guild} this Reaction was used in, or {@code null} */ public Guild getGuild() { TextChannel channel = getTextChannel(); return channel != null ? channel.getGuild() : null; }
@Override public Guild getGuild() { return isFromType(ChannelType.TEXT) ? getTextChannel().getGuild() : null; }
/** * {@link net.dv8tion.jda.core.entities.Guild Guild} in which this users started typing, * or {@code null} if this was not in a Guild. * * @return Possibly-null {@link net.dv8tion.jda.core.entities.Guild Guild} */ public Guild getGuild() { return isFromType(ChannelType.TEXT) ? getTextChannel().getGuild() : null; }
/** * The {@link net.dv8tion.jda.core.entities.Guild Guild} the Message was received in. * <br>If this Message was not received in a {@link net.dv8tion.jda.core.entities.TextChannel TextChannel}, * this will return {@code null}. * * @return The Guild the Message was received in or null if not from a TextChannel * * @see net.dv8tion.jda.core.events.message.GenericMessageEvent#isFromType(ChannelType) */ public Guild getGuild() { return isFromType(ChannelType.TEXT) ? getTextChannel().getGuild() : null; }
/** * Sets the system {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} of this {@link net.dv8tion.jda.core.entities.Guild Guild}. * * @param systemChannel * The new system channel for this {@link net.dv8tion.jda.core.entities.Guild Guild} * or {@code null} to reset * * @throws IllegalArgumentException * If the provided channel is not from this guild * * @return GuildManager for chaining convenience */ @CheckReturnValue public GuildManager setSystemChannel(TextChannel systemChannel) { Checks.check(systemChannel == null || systemChannel.getGuild().equals(getGuild()), "Channel must be from the same guild"); this.systemChannel = systemChannel == null ? null : systemChannel.getId(); set |= SYSTEM_CHANNEL; return this; }
protected boolean hasPermission(Permission perm) { if (channel.getType() != ChannelType.TEXT) return true; TextChannel text = (TextChannel) channel; Member self = text.getGuild().getSelfMember(); return self.hasPermission(text, perm); }
/** * Creates a new MessageHistory object. * * @param channel * The {@link net.dv8tion.jda.core.entities.MessageChannel MessageChannel} to retrieval history from. */ public MessageHistory(MessageChannel channel) { this.channel = channel; if (channel instanceof TextChannel) { TextChannel tc = (TextChannel) channel; if (!tc.getGuild().getSelfMember().hasPermission(tc, Permission.MESSAGE_HISTORY)) throw new InsufficientPermissionException(Permission.MESSAGE_HISTORY); } }
/** * Sets the {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} of the selected {@link net.dv8tion.jda.core.entities.Webhook Webhook}. * * <p>A webhook channel <b>must not</b> be {@code null} and <b>must</b> be in the same {@link net.dv8tion.jda.core.entities.Guild Guild}! * * @param channel * The new {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} * for the selected {@link net.dv8tion.jda.core.entities.Webhook Webhook} * * @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException * If the currently logged in account does not have the Permission {@link net.dv8tion.jda.core.Permission#MANAGE_WEBHOOKS MANAGE_WEBHOOKS} * in the specified TextChannel * @throws IllegalArgumentException * If the provided channel is {@code null} or from a different Guild * * @return WebhookManager for chaining convenience */ @CheckReturnValue public WebhookManager setChannel(TextChannel channel) { Checks.notNull(channel, "Channel"); Checks.check(channel.getGuild().equals(getGuild()), "Channel is not from the same guild"); this.channel = channel.getId(); set |= CHANNEL; return this; }
.setOwner(owner == null ? null : channel.getGuild().getMember(owner)) .setUser(defaultUser);
@Override public int compareTo(TextChannel chan) { Checks.notNull(chan, "Other TextChannel"); if (this == chan) return 0; Checks.check(getGuild().equals(chan.getGuild()), "Cannot compare TextChannels that aren't from the same guild!"); if (this.getPositionRaw() == chan.getPositionRaw()) return Long.compare(id, chan.getIdLong()); return Integer.compare(rawPosition, chan.getPositionRaw()); }
private static void checkArguments(MessageChannel channel, String messageId) { Checks.isSnowflake(messageId, "Message ID"); Checks.notNull(channel, "Channel"); if (channel.getType() == ChannelType.TEXT) { TextChannel t = (TextChannel) channel; if (!t.getGuild().getSelfMember().hasPermission(t, Permission.MESSAGE_HISTORY)) throw new InsufficientPermissionException(Permission.MESSAGE_HISTORY); } }
public MessagePaginationAction(MessageChannel channel) { super(channel.getJDA(), Route.Messages.GET_MESSAGE_HISTORY.compile(channel.getId()), 1, 100, 100); if (channel.getType() == ChannelType.TEXT) { TextChannel textChannel = (TextChannel) channel; if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_HISTORY)) throw new InsufficientPermissionException(Permission.MESSAGE_HISTORY); } this.channel = channel; }
final Member self = text.getGuild().getSelfMember(); if (!self.hasPermission(text, Permission.MESSAGE_READ)) throw new InsufficientPermissionException(Permission.MESSAGE_READ);