From 2316f058a5606e403d6f25cd78339b70f20cf944 Mon Sep 17 00:00:00 2001 From: Austin Keener Date: Sat, 14 May 2022 14:21:44 -0400 Subject: [PATCH 01/17] First pass on new union types --- .../jda/api/entities/ChannelField.java | 6 +- .../net/dv8tion/jda/api/entities/Guild.java | 9 +- .../jda/api/entities/GuildMessageChannel.java | 5 +- ...ageChannel.java => IWebhookContainer.java} | 67 +++++--------- .../net/dv8tion/jda/api/entities/Member.java | 7 +- .../net/dv8tion/jda/api/entities/Message.java | 6 +- .../jda/api/entities/MessageHistory.java | 5 +- .../jda/api/entities/MessageReaction.java | 13 +-- .../jda/api/entities/MessageReference.java | 5 +- .../dv8tion/jda/api/entities/NewsChannel.java | 4 +- .../jda/api/entities/StageChannel.java | 2 +- .../api/entities/StandardGuildChannel.java | 52 +++++++++++ .../entities/StandardGuildMessageChannel.java | 69 ++++++++++++++ .../dv8tion/jda/api/entities/TextChannel.java | 6 +- .../jda/api/entities/ThreadChannel.java | 8 +- .../jda/api/entities/VoiceChannel.java | 2 +- .../net/dv8tion/jda/api/entities/Webhook.java | 12 ++- .../unions/DefaultGuildChannelUnion.java | 38 ++++++++ .../unions/GuildMessageChannelUnion.java | 44 +++++++++ .../channel/unions/IThreadContainerUnion.java | 41 +++++++++ .../unions/IWebhookContainerUnion.java | 41 +++++++++ .../channel/unions/MessageChannelUnion.java | 40 +++++++++ .../unions/StandardGuildChannelUnion.java | 38 ++++++++ .../MessageContextInteractionEvent.java | 6 +- .../command/SlashCommandInteractionEvent.java | 5 +- ...enericComponentInteractionCreateEvent.java | 8 +- .../events/message/GenericMessageEvent.java | 10 ++- .../message/MessageBulkDeleteEvent.java | 5 +- .../jda/api/events/user/UserTypingEvent.java | 5 +- .../jda/api/interactions/Interaction.java | 5 +- .../interactions/commands/OptionMapping.java | 5 +- .../commands/SlashCommandInteraction.java | 10 +-- .../context/MessageContextInteraction.java | 10 +-- .../components/ComponentInteraction.java | 3 +- .../jda/api/managers/WebhookManager.java | 12 ++- .../channel/concrete/NewsChannelManager.java | 4 +- .../channel/concrete/StageChannelManager.java | 6 +- .../channel/concrete/TextChannelManager.java | 4 +- .../channel/concrete/VoiceChannelManager.java | 6 +- .../StandardGuildChannelManager.java | 44 +++++++++ ...> StandardGuildMessageChannelManager.java} | 32 +++---- .../requests/restaction/MessageAction.java | 3 +- .../requests/restaction/WebhookAction.java | 6 +- .../pagination/MessagePaginationAction.java | 3 +- .../ThreadChannelPaginationAction.java | 3 +- .../entities/AbstractChannelImpl.java | 67 ++++++++++++++ .../internal/entities/AbstractMessage.java | 6 +- .../AbstractStandardGuildChannelImpl.java | 73 +++++++++++++++ ...stractStandardGuildMessageChannelImpl.java | 77 ++++++++++++++++ .../jda/internal/entities/EntityBuilder.java | 7 +- .../jda/internal/entities/GuildImpl.java | 5 +- .../jda/internal/entities/MemberImpl.java | 5 +- .../internal/entities/NewsChannelImpl.java | 89 ++---------------- .../internal/entities/ReceivedMessage.java | 10 ++- .../internal/entities/StageChannelImpl.java | 53 ++--------- .../internal/entities/TextChannelImpl.java | 90 ++----------------- .../internal/entities/ThreadChannelImpl.java | 5 +- .../internal/entities/VoiceChannelImpl.java | 50 ++--------- .../jda/internal/entities/WebhookImpl.java | 18 ++-- .../attribute/IThreadContainerMixin.java | 6 +- .../IWebhookContainerMixin.java} | 34 ++----- .../middleman/GuildMessageChannelMixin.java | 7 +- .../middleman/MessageChannelMixin.java | 55 ++++++------ .../middleman/StandardGuildChannelMixin.java | 34 +++++++ .../StandardGuildMessageChannelMixin.java | 48 ++++++++++ .../CommandInteractionPayloadImpl.java | 6 +- .../MessageContextInteractionImpl.java | 6 +- .../command/SlashCommandInteractionImpl.java | 6 +- .../component/ComponentInteractionImpl.java | 6 +- .../internal/managers/WebhookManagerImpl.java | 10 +-- .../restaction/MessageActionImpl.java | 5 +- .../restaction/WebhookActionImpl.java | 11 +-- .../MessagePaginationActionImpl.java | 5 +- .../ThreadChannelPaginationActionImpl.java | 5 +- 74 files changed, 998 insertions(+), 516 deletions(-) rename src/main/java/net/dv8tion/jda/api/entities/{BaseGuildMessageChannel.java => IWebhookContainer.java} (73%) create mode 100644 src/main/java/net/dv8tion/jda/api/entities/StandardGuildChannel.java create mode 100644 src/main/java/net/dv8tion/jda/api/entities/StandardGuildMessageChannel.java create mode 100644 src/main/java/net/dv8tion/jda/api/entities/channel/unions/DefaultGuildChannelUnion.java create mode 100644 src/main/java/net/dv8tion/jda/api/entities/channel/unions/GuildMessageChannelUnion.java create mode 100644 src/main/java/net/dv8tion/jda/api/entities/channel/unions/IThreadContainerUnion.java create mode 100644 src/main/java/net/dv8tion/jda/api/entities/channel/unions/IWebhookContainerUnion.java create mode 100644 src/main/java/net/dv8tion/jda/api/entities/channel/unions/MessageChannelUnion.java create mode 100644 src/main/java/net/dv8tion/jda/api/entities/channel/unions/StandardGuildChannelUnion.java create mode 100644 src/main/java/net/dv8tion/jda/api/managers/channel/middleman/StandardGuildChannelManager.java rename src/main/java/net/dv8tion/jda/api/managers/channel/middleman/{BaseGuildMessageChannelManager.java => StandardGuildMessageChannelManager.java} (53%) create mode 100644 src/main/java/net/dv8tion/jda/internal/entities/AbstractStandardGuildChannelImpl.java create mode 100644 src/main/java/net/dv8tion/jda/internal/entities/AbstractStandardGuildMessageChannelImpl.java rename src/main/java/net/dv8tion/jda/internal/entities/mixin/channel/{middleman/BaseGuildMessageChannelMixin.java => attribute/IWebhookContainerMixin.java} (76%) create mode 100644 src/main/java/net/dv8tion/jda/internal/entities/mixin/channel/middleman/StandardGuildChannelMixin.java create mode 100644 src/main/java/net/dv8tion/jda/internal/entities/mixin/channel/middleman/StandardGuildMessageChannelMixin.java diff --git a/src/main/java/net/dv8tion/jda/api/entities/ChannelField.java b/src/main/java/net/dv8tion/jda/api/entities/ChannelField.java index efc50428ff..85168f7046 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/ChannelField.java +++ b/src/main/java/net/dv8tion/jda/api/entities/ChannelField.java @@ -78,16 +78,16 @@ public enum ChannelField * * Limited to {@link NewsChannel NewsChannels} and {@link TextChannel TextChannels}. * - * @see BaseGuildMessageChannel#getTopic() + * @see StandardGuildMessageChannel#getTopic() */ TOPIC("topic", AuditLogKey.CHANNEL_TOPIC), /** * The NSFW state of the channel. * - * Limited to {@link BaseGuildMessageChannel Base Guild Channels} (and implementations). + * Limited to {@link StandardGuildMessageChannel StandardGuildMessageChannels} (and implementations). * - * @see BaseGuildMessageChannel#isNSFW() + * @see StandardGuildMessageChannel#isNSFW() */ NSFW("nsfw", AuditLogKey.CHANNEL_NSFW), diff --git a/src/main/java/net/dv8tion/jda/api/entities/Guild.java b/src/main/java/net/dv8tion/jda/api/entities/Guild.java index fbddaa75fa..22d1f87bd1 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/Guild.java +++ b/src/main/java/net/dv8tion/jda/api/entities/Guild.java @@ -19,6 +19,7 @@ import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.Region; import net.dv8tion.jda.api.entities.channel.IGuildChannelContainer; +import net.dv8tion.jda.api.entities.channel.unions.DefaultGuildChannelUnion; import net.dv8tion.jda.api.entities.templates.Template; import net.dv8tion.jda.api.exceptions.InsufficientPermissionException; import net.dv8tion.jda.api.interactions.commands.Command; @@ -1943,17 +1944,17 @@ default RestAction retrieveEmote(@Nonnull Emote emote) Role getPublicRole(); /** - * The default {@link net.dv8tion.jda.api.entities.BaseGuildMessageChannel BaseGuildMessageChannel} for a {@link net.dv8tion.jda.api.entities.Guild Guild}. + * The default {@link net.dv8tion.jda.api.entities.StandardGuildChannel} for a {@link net.dv8tion.jda.api.entities.Guild Guild}. *
This is the channel that the Discord client will default to opening when a Guild is opened for the first time when accepting an invite - * that is not directed at a specific {@link net.dv8tion.jda.api.entities.BaseGuildMessageChannel BaseGuildMessageChannel}. + * that is not directed at a specific {@link IInviteContainer channel}. * *

Note: This channel is the first channel in the guild (ordered by position) that the {@link #getPublicRole()} * has the {@link net.dv8tion.jda.api.Permission#VIEW_CHANNEL Permission.VIEW_CHANNEL} in. * - * @return The {@link net.dv8tion.jda.api.entities.BaseGuildMessageChannel BaseGuildMessageChannel} representing the default channel for this guild + * @return The {@link net.dv8tion.jda.api.entities.StandardGuildChannel channel} representing the default channel for this guild */ @Nullable - BaseGuildMessageChannel getDefaultChannel(); + DefaultGuildChannelUnion getDefaultChannel(); /** * Returns the {@link GuildManager GuildManager} for this Guild, used to modify diff --git a/src/main/java/net/dv8tion/jda/api/entities/GuildMessageChannel.java b/src/main/java/net/dv8tion/jda/api/entities/GuildMessageChannel.java index ec1d9a578e..9c49822020 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/GuildMessageChannel.java +++ b/src/main/java/net/dv8tion/jda/api/entities/GuildMessageChannel.java @@ -15,10 +15,9 @@ /** * Represents all message channels present in guilds. * - * This includes channels that are not included in {@link BaseGuildMessageChannel BaseGuildMessageChannel}, such as {@link ThreadChannel}. - * - * @see BaseGuildMessageChannel + * This includes channels that are not included in {@link StandardGuildMessageChannel}, such as {@link ThreadChannel}. * + * @see StandardGuildMessageChannel */ public interface GuildMessageChannel extends GuildChannel, MessageChannel { diff --git a/src/main/java/net/dv8tion/jda/api/entities/BaseGuildMessageChannel.java b/src/main/java/net/dv8tion/jda/api/entities/IWebhookContainer.java similarity index 73% rename from src/main/java/net/dv8tion/jda/api/entities/BaseGuildMessageChannel.java rename to src/main/java/net/dv8tion/jda/api/entities/IWebhookContainer.java index da4e8a38b5..b19f30037a 100644 --- a/src/main/java/net/dv8tion/jda/api/entities/BaseGuildMessageChannel.java +++ b/src/main/java/net/dv8tion/jda/api/entities/IWebhookContainer.java @@ -1,51 +1,38 @@ +/* + * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package net.dv8tion.jda.api.entities; -import net.dv8tion.jda.api.managers.channel.middleman.BaseGuildMessageChannelManager; import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.api.requests.restaction.AuditableRestAction; -import net.dv8tion.jda.api.requests.restaction.ChannelAction; import net.dv8tion.jda.api.requests.restaction.WebhookAction; import javax.annotation.CheckReturnValue; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.List; - /** - * Represents a standard {@link Guild Guild} {@link MessageChannel MessageChannel}. - *
These are the "normal" message channels that are present in the channel sidebar. - * These are not {@link ThreadChannel ThreadChannels}. + * Represents a {@link GuildChannel} that is capable of utilizing webhooks. * - * @see net.dv8tion.jda.api.entities.GuildMessageChannel - * @see TextChannel - * @see NewsChannel + * Webhooks can be used to integrate third-party systems into Discord by way of sending information via messages. */ -public interface BaseGuildMessageChannel extends GuildMessageChannel, IThreadContainer, GuildChannel, ICategorizableChannel, ICopyableChannel, IPermissionContainer, IMemberContainer, IInviteContainer, IPositionableChannel +public interface IWebhookContainer extends GuildChannel { - //TODO-v5: Docs - @Override - @Nonnull - BaseGuildMessageChannelManager getManager(); - - /** - * The topic set for this TextChannel. - *
If no topic has been set, this returns null. - * - * @return Possibly-null String containing the topic of this TextChannel. - */ - @Nullable - String getTopic(); - - /** - * Whether or not this channel is considered as "NSFW" (Not-Safe-For-Work) - * - * @return True, If this TextChannel is considered NSFW by the official Discord Client - */ - boolean isNSFW(); - - /** - * Retrieves the {@link net.dv8tion.jda.api.entities.Webhook Webhooks} attached to this TextChannel. + /** + * Retrieves the {@link net.dv8tion.jda.api.entities.Webhook Webhooks} attached to this channel. * *

Possible ErrorResponses include: *