Skip to content

Commit

Permalink
Move channels to separate package and cleanup code (#2180)
Browse files Browse the repository at this point in the history
* Cleanup handling of casts in a lot of places
* Move channels to separate package
* Move impl classes and mixins to new package
  • Loading branch information
MinnDevelopment authored Sep 13, 2022
1 parent 574bd8f commit 11c5bf0
Show file tree
Hide file tree
Showing 280 changed files with 1,540 additions and 1,055 deletions.
3 changes: 3 additions & 0 deletions src/examples/java/AudioEchoExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import net.dv8tion.jda.api.audio.AudioSendHandler;
import net.dv8tion.jda.api.audio.CombinedAudio;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.managers.AudioManager;
Expand Down
2 changes: 1 addition & 1 deletion src/examples/java/MessageLoggerExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
import net.dv8tion.jda.api.entities.emoji.Emoji;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
Expand Down
2 changes: 1 addition & 1 deletion src/examples/java/SlashBotExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/net/dv8tion/jda/api/EmbedBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class EmbedBuilder

/**
* Constructs a new EmbedBuilder instance, which can be used to create {@link net.dv8tion.jda.api.entities.MessageEmbed MessageEmbeds}.
* These can then be sent to a channel using {@link net.dv8tion.jda.api.entities.MessageChannel#sendMessageEmbeds(MessageEmbed, MessageEmbed...)}.
* These can then be sent to a channel using {@link net.dv8tion.jda.api.entities.channel.middleman.MessageChannel#sendMessageEmbeds(MessageEmbed, MessageEmbed...)}.
* <br>Every part of an embed can be removed or cleared by providing {@code null} to the setter method.
*/
public EmbedBuilder() { }
Expand Down Expand Up @@ -432,7 +432,7 @@ public EmbedBuilder setColor(int color)
*
* <p><b>Uploading images with Embeds</b>
* <br>When uploading an <u>image</u>
* (using {@link net.dv8tion.jda.api.entities.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)})
* (using {@link net.dv8tion.jda.api.entities.channel.middleman.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)})
* you can reference said image using the specified filename as URI {@code attachment://filename.ext}.
*
* <p><u>Example</u>
Expand Down Expand Up @@ -479,7 +479,7 @@ public EmbedBuilder setThumbnail(@Nullable String url)
*
* <p><b>Uploading images with Embeds</b>
* <br>When uploading an <u>image</u>
* (using {@link net.dv8tion.jda.api.entities.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)})
* (using {@link net.dv8tion.jda.api.entities.channel.middleman.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)})
* you can reference said image using the specified filename as URI {@code attachment://filename.ext}.
*
* <p><u>Example</u>
Expand All @@ -504,7 +504,7 @@ public EmbedBuilder setThumbnail(@Nullable String url)
*
* @return the builder after the image has been set
*
* @see net.dv8tion.jda.api.entities.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)
* @see net.dv8tion.jda.api.entities.channel.middleman.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)
*/
@Nonnull
public EmbedBuilder setImage(@Nullable String url)
Expand Down Expand Up @@ -580,7 +580,7 @@ public EmbedBuilder setAuthor(@Nullable String name, @Nullable String url)
*
* <p><b>Uploading images with Embeds</b>
* <br>When uploading an <u>image</u>
* (using {@link net.dv8tion.jda.api.entities.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)})
* (using {@link net.dv8tion.jda.api.entities.channel.middleman.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)})
* you can reference said image using the specified filename as URI {@code attachment://filename.ext}.
*
* <p><u>Example</u>
Expand Down Expand Up @@ -660,7 +660,7 @@ public EmbedBuilder setFooter(@Nullable String text)
*
* <p><b>Uploading images with Embeds</b>
* <br>When uploading an <u>image</u>
* (using {@link net.dv8tion.jda.api.entities.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)})
* (using {@link net.dv8tion.jda.api.entities.channel.middleman.MessageChannel#sendFiles(net.dv8tion.jda.api.utils.FileUpload...) MessageChannel.sendFiles(...)})
* you can reference said image using the specified filename as URI {@code attachment://filename.ext}.
*
* <p><u>Example</u>
Expand Down
30 changes: 17 additions & 13 deletions src/main/java/net/dv8tion/jda/api/JDA.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
package net.dv8tion.jda.api;

import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.IGuildChannelContainer;
import net.dv8tion.jda.api.entities.channel.Channel;
import net.dv8tion.jda.api.entities.channel.attribute.IGuildChannelContainer;
import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji;
import net.dv8tion.jda.api.entities.sticker.*;
import net.dv8tion.jda.api.hooks.IEventManager;
Expand Down Expand Up @@ -1244,22 +1248,22 @@ default <T extends Channel> T getChannelById(@Nonnull Class<T> type, long id)

/**
* {@link net.dv8tion.jda.api.utils.cache.SnowflakeCacheView SnowflakeCacheView} of
* all cached {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannels} visible to this JDA session.
* all cached {@link PrivateChannel PrivateChannels} visible to this JDA session.
*
* @return {@link net.dv8tion.jda.api.utils.cache.SnowflakeCacheView SnowflakeCacheView}
*/
@Nonnull
SnowflakeCacheView<PrivateChannel> getPrivateChannelCache();

/**
* An unmodifiable list of all known {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannels}.
* An unmodifiable list of all known {@link PrivateChannel PrivateChannels}.
*
* <p>This copies the backing store into a list. This means every call
* creates a new list with O(n) complexity. It is recommended to store this into
* a local variable or use {@link #getPrivateChannelCache()} and use its more efficient
* versions of handling these values.
*
* @return Possibly-empty list of all {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannels}.
* @return Possibly-empty list of all {@link PrivateChannel PrivateChannels}.
*/
@Nonnull
default List<PrivateChannel> getPrivateChannels()
Expand All @@ -1268,16 +1272,16 @@ default List<PrivateChannel> getPrivateChannels()
}

/**
* This returns the {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel} which has the same id as the one provided.
* <br>If there is no known {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel} with an id that matches the provided
* This returns the {@link PrivateChannel PrivateChannel} which has the same id as the one provided.
* <br>If there is no known {@link PrivateChannel PrivateChannel} with an id that matches the provided
* one, then this returns {@code null}.
*
* @param id
* The id of the {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel}.
* The id of the {@link PrivateChannel PrivateChannel}.
* @throws java.lang.NumberFormatException
* If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)}
*
* @return Possibly-null {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel} with matching id.
* @return Possibly-null {@link PrivateChannel PrivateChannel} with matching id.
*/
@Nullable
default PrivateChannel getPrivateChannelById(@Nonnull String id)
Expand All @@ -1286,14 +1290,14 @@ default PrivateChannel getPrivateChannelById(@Nonnull String id)
}

/**
* This returns the {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel} which has the same id as the one provided.
* <br>If there is no known {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel} with an id that matches the provided
* This returns the {@link PrivateChannel PrivateChannel} which has the same id as the one provided.
* <br>If there is no known {@link PrivateChannel PrivateChannel} with an id that matches the provided
* one, then this returns {@code null}.
*
* @param id
* The id of the {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel}.
* The id of the {@link PrivateChannel PrivateChannel}.
*
* @return Possibly-null {@link net.dv8tion.jda.api.entities.PrivateChannel PrivateChannel} with matching id.
* @return Possibly-null {@link PrivateChannel PrivateChannel} with matching id.
*/
@Nullable
default PrivateChannel getPrivateChannelById(long id)
Expand Down Expand Up @@ -1382,7 +1386,7 @@ default RestAction<PrivateChannel> openPrivateChannelById(@Nonnull String userId
*
* <p><b>Hint</b>: To check whether you can use an {@link RichCustomEmoji} in a specific
* context you can use {@link RichCustomEmoji#canInteract(net.dv8tion.jda.api.entities.Member)} or {@link
* RichCustomEmoji#canInteract(net.dv8tion.jda.api.entities.User, net.dv8tion.jda.api.entities.MessageChannel)}
* RichCustomEmoji#canInteract(net.dv8tion.jda.api.entities.User, MessageChannel)}
*
* <p><b>Unicode emojis are not included as {@link RichCustomEmoji Custom Emoji}!</b>
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/dv8tion/jda/api/JDABuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.dv8tion.jda.api.audio.factory.IAudioSendFactory;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.events.Event;
import net.dv8tion.jda.api.exceptions.InvalidTokenException;
import net.dv8tion.jda.api.hooks.IEventManager;
import net.dv8tion.jda.api.hooks.VoiceDispatchInterceptor;
import net.dv8tion.jda.api.requests.GatewayIntent;
Expand All @@ -29,7 +30,6 @@
import net.dv8tion.jda.internal.managers.PresenceImpl;
import net.dv8tion.jda.internal.utils.Checks;
import net.dv8tion.jda.internal.utils.IOUtil;
import net.dv8tion.jda.api.exceptions.InvalidTokenException;
import net.dv8tion.jda.internal.utils.config.AuthorizationConfig;
import net.dv8tion.jda.internal.utils.config.MetaConfig;
import net.dv8tion.jda.internal.utils.config.SessionConfig;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/dv8tion/jda/api/Permission.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public boolean isChannel()
}

/**
* Whether this permission is specifically for {@link net.dv8tion.jda.api.entities.TextChannel TextChannels}
* Whether this permission is specifically for {@link net.dv8tion.jda.api.entities.channel.concrete.TextChannel TextChannels}
*
* @return True, if and only if this permission can only be applied to text channels
*/
Expand All @@ -207,7 +207,7 @@ public boolean isText()
}

/**
* Whether this permission is specifically for {@link net.dv8tion.jda.api.entities.VoiceChannel VoiceChannels}
* Whether this permission is specifically for {@link net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel VoiceChannels}
*
* @return True, if and only if this permission can only be applied to voice channels
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/dv8tion/jda/api/Region.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

/**
* Represents the Regions used for Audio connections.
* <br>This is used by {@link net.dv8tion.jda.api.entities.AudioChannel AudioChannels} to define where the audio server that hosts the
* {@link net.dv8tion.jda.api.entities.AudioChannel} is located.
* <br>This is used by {@link net.dv8tion.jda.api.entities.channel.middleman.AudioChannel AudioChannels} to define where the audio server that hosts the
* {@link net.dv8tion.jda.api.entities.channel.middleman.AudioChannel} is located.
*/
public enum Region
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package net.dv8tion.jda.api.audio.factory;

import net.dv8tion.jda.api.audio.hooks.ConnectionStatus;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -49,7 +49,7 @@ public interface IPacketProvider
/**
* Provides the current channel that this connection is transmitting to.
*
* @return The {@link net.dv8tion.jda.api.entities.AudioChannel AudioChannel} that this connection is sending to.
* @return The {@link net.dv8tion.jda.api.entities.channel.middleman.AudioChannel AudioChannel} that this connection is sending to.
*/
@Nonnull
AudioChannel getConnectedChannel();
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/net/dv8tion/jda/api/audit/ActionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package net.dv8tion.jda.api.audit;

import net.dv8tion.jda.api.entities.GuildChannel;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji;

/**
Expand Down Expand Up @@ -447,7 +447,7 @@ public enum ActionType
INTEGRATION_DELETE(82, TargetType.INTEGRATION),

/**
* A {@link net.dv8tion.jda.api.entities.StageInstance StageInstance} was started by a {@link net.dv8tion.jda.api.entities.StageChannel#isModerator(Member) Stage Moderator}.
* A {@link net.dv8tion.jda.api.entities.StageInstance StageInstance} was started by a {@link net.dv8tion.jda.api.entities.channel.concrete.StageChannel#isModerator(Member) Stage Moderator}.
*
* <p><b>Possible Options</b><br>
* <ul>
Expand All @@ -463,7 +463,7 @@ public enum ActionType
STAGE_INSTANCE_CREATE(83, TargetType.STAGE_INSTANCE),

/**
* A {@link net.dv8tion.jda.api.entities.StageInstance StageInstance} was updated by a {@link net.dv8tion.jda.api.entities.StageChannel#isModerator(Member) Stage Moderator}.
* A {@link net.dv8tion.jda.api.entities.StageInstance StageInstance} was updated by a {@link net.dv8tion.jda.api.entities.channel.concrete.StageChannel#isModerator(Member) Stage Moderator}.
*
* <p><b>Possible Options</b><br>
* <ul>
Expand All @@ -479,7 +479,7 @@ public enum ActionType
STAGE_INSTANCE_UPDATE(84, TargetType.STAGE_INSTANCE),

/**
* A {@link net.dv8tion.jda.api.entities.StageInstance StageInstance} was deleted by a {@link net.dv8tion.jda.api.entities.StageChannel#isModerator(Member) Stage Moderator}.
* A {@link net.dv8tion.jda.api.entities.StageInstance StageInstance} was deleted by a {@link net.dv8tion.jda.api.entities.channel.concrete.StageChannel#isModerator(Member) Stage Moderator}.
*
* <p><b>Possible Options</b><br>
* <ul>
Expand Down Expand Up @@ -529,7 +529,7 @@ public enum ActionType
STICKER_DELETE(92, TargetType.STICKER),

/**
* A user created a {@link net.dv8tion.jda.api.entities.ThreadChannel ThreadChannel}
* A user created a {@link net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel ThreadChannel}
*
* <p><b>Possible Keys</b><br>
* <ul>
Expand All @@ -545,7 +545,7 @@ public enum ActionType
THREAD_CREATE(110, TargetType.THREAD),

/**
* A user updated a {@link net.dv8tion.jda.api.entities.ThreadChannel ThreadChannel}
* A user updated a {@link net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel ThreadChannel}
*
* <p><b>Possible Keys</b><br>
* <ul>
Expand All @@ -561,7 +561,7 @@ public enum ActionType
THREAD_UPDATE(111, TargetType.THREAD),

/**
* A user deleted a {@link net.dv8tion.jda.api.entities.ThreadChannel ThreadChannel}
* A user deleted a {@link net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel ThreadChannel}
*/
THREAD_DELETE(112, TargetType.THREAD),

Expand Down
33 changes: 18 additions & 15 deletions src/main/java/net/dv8tion/jda/api/audit/AuditLogKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
package net.dv8tion.jda.api.audit;

import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.GuildChannel;
import net.dv8tion.jda.api.entities.ICategorizableChannel;
import net.dv8tion.jda.api.entities.ThreadChannel;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.attribute.ICategorizableChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.concrete.ThreadChannel;
import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji;
import net.dv8tion.jda.api.entities.sticker.GuildSticker;

Expand Down Expand Up @@ -213,32 +216,32 @@ public enum AuditLogKey
CHANNEL_PARENT("parent_id"),

/**
* Change of the {@link net.dv8tion.jda.api.entities.TextChannel#getTopic() TextChannel.getTopic()} value.
* <br>Only for {@link net.dv8tion.jda.api.entities.ChannelType#TEXT ChannelType.TEXT}
* Change of the {@link TextChannel#getTopic() TextChannel.getTopic()} value.
* <br>Only for {@link ChannelType#TEXT ChannelType.TEXT}
*
* <p>Expected type: <b>String</b>
*/
CHANNEL_TOPIC("topic"),

/**
* Change of the {@link net.dv8tion.jda.api.entities.TextChannel#getSlowmode() TextChannel.getSlowmode()} value.
* <br>Only for {@link net.dv8tion.jda.api.entities.ChannelType#TEXT ChannelType.TEXT}
* Change of the {@link TextChannel#getSlowmode() TextChannel.getSlowmode()} value.
* <br>Only for {@link ChannelType#TEXT ChannelType.TEXT}
*
* <p>Expected type: <b>Integer</b>
*/
CHANNEL_SLOWMODE("rate_limit_per_user"),

/**
* Change of the {@link net.dv8tion.jda.api.entities.VoiceChannel#getBitrate() VoiceChannel.getBitrate()} value.
* <br>Only for {@link net.dv8tion.jda.api.entities.ChannelType#VOICE ChannelType.VOICE}
* Change of the {@link VoiceChannel#getBitrate() VoiceChannel.getBitrate()} value.
* <br>Only for {@link ChannelType#VOICE ChannelType.VOICE}
*
* <p>Expected type: <b>Integer</b>
*/
CHANNEL_BITRATE("bitrate"),

/**
* Change of the {@link net.dv8tion.jda.api.entities.VoiceChannel#getUserLimit() VoiceChannel.getUserLimit()} value.
* <br>Only for {@link net.dv8tion.jda.api.entities.ChannelType#VOICE ChannelType.VOICE}
* Change of the {@link VoiceChannel#getUserLimit() VoiceChannel.getUserLimit()} value.
* <br>Only for {@link ChannelType#VOICE ChannelType.VOICE}
*
* <p>Expected type: <b>Integer</b>
*/
Expand All @@ -253,15 +256,15 @@ public enum AuditLogKey

/**
* Change of the {@link net.dv8tion.jda.api.Region Region} value.
* <br>Only for {@link net.dv8tion.jda.api.entities.ChannelType#VOICE ChannelType.VOICE} and {@link net.dv8tion.jda.api.entities.ChannelType#STAGE ChannelType.STAGE}
* <br>Only for {@link ChannelType#VOICE ChannelType.VOICE} and {@link ChannelType#STAGE ChannelType.STAGE}
*
* <p>Expected type: <b>String</b></p>
*/
CHANNEL_REGION("rtc_region"),

/**
* The integer type of this channel.
* <br>Use with {@link net.dv8tion.jda.api.entities.ChannelType#fromId(int) ChannelType.fromId(int)}.
* <br>Use with {@link ChannelType#fromId(int) ChannelType.fromId(int)}.
*
* <p>Expected type: <b>int</b>
*/
Expand All @@ -277,14 +280,14 @@ public enum AuditLogKey
// THREADS

/**
* Change of the {@link net.dv8tion.jda.api.entities.ThreadChannel#getName() ThreadChannel.getName()} value.
* Change of the {@link ThreadChannel#getName() ThreadChannel.getName()} value.
*
* <p>Expected type: <b>String</b>
*/
THREAD_NAME("name"),

/**
* Change of the {@link net.dv8tion.jda.api.entities.ThreadChannel#getSlowmode() ThreadChannel.getSlowmode()} value.
* Change of the {@link ThreadChannel#getSlowmode() ThreadChannel.getSlowmode()} value.
*
* <p>Expected type: <b>Integer</b>
*/
Expand Down
Loading

0 comments on commit 11c5bf0

Please sign in to comment.