All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.dv8tion.jda.api.entities.channel.unions.DefaultGuildChannelUnion Maven / Gradle / Ivy

Go to download

Java wrapper for the popular chat & VOIP service: Discord https://discord.com

There is a newer version: 5.1.0
Show newest version
/*
 * 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.channel.unions;

import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer;
import net.dv8tion.jda.api.entities.channel.concrete.NewsChannel;
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildChannel;
import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildMessageChannel;

import javax.annotation.Nonnull;

/**
 * A specialized union representing all channel types that can be used for the "default" channel for
 * {@link Guild#getDefaultChannel()} or {@link Member#getDefaultChannel()}.
 * 
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.channel.attribute.IInviteContainer channel}. * *
This class extends {@link StandardGuildChannel} and primarily acts as a discovery tool for * developers to understand which channels might be returned as default channels. * *

Not all {@link StandardGuildChannel} channels can be used as a default channel! * *

This interface represents the follow concrete channel types: *

    *
  • {@link TextChannel}
  • *
  • {@link NewsChannel}
  • *
*/ public interface DefaultGuildChannelUnion extends StandardGuildChannel { /** * Casts this union to a {@link TextChannel}. * This method exists for developer discoverability. * *

Note: This is effectively equivalent to using the cast operator: *


     * //These are the same!
     * TextChannel channel = union.asTextChannel();
     * TextChannel channel2 = (TextChannel) union;
     * 
* * You can use {@link #getType()} to see if the channel is of type {@link ChannelType#TEXT} to validate * whether you can call this method in addition to normal instanceof checks: channel instanceof TextChannel * * @throws IllegalStateException * If the channel represented by this union is not actually a {@link TextChannel}. * * @return The channel as a {@link TextChannel} */ @Nonnull TextChannel asTextChannel(); /** * Casts this union to a {@link NewsChannel}. * This method exists for developer discoverability. * *

Note: This is effectively equivalent to using the cast operator: *


     * //These are the same!
     * NewsChannel channel = union.asNewsChannel();
     * NewsChannel channel2 = (NewsChannel) union;
     * 
* * You can use {@link #getType()} to see if the channel is of type {@link ChannelType#NEWS} to validate * whether you can call this method in addition to normal instanceof checks: channel instanceof NewsChannel * * @throws IllegalStateException * If the channel represented by this union is not actually a {@link NewsChannel}. * * @return The channel as a {@link NewsChannel} */ @Nonnull NewsChannel asNewsChannel(); //TODO: add asForumChannel() (I think ForumChannels can be the default?) /** * Casts this union to a {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer}. * This method exists for developer discoverability. * *

Note: This is effectively equivalent to using the cast operator: *


     * //These are the same!
     * IThreadContainer channel = union.asThreadContainer();
     * IThreadContainer channel2 = (IThreadContainer) union;
     * 
* * You can use channel instanceof IThreadContainer to validate whether you can call this method. * * @throws IllegalStateException * If the channel represented by this union is not actually a {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer}. * * @return The channel as a {@link net.dv8tion.jda.api.entities.channel.attribute.IThreadContainer} */ @Nonnull IThreadContainer asThreadContainer(); /** * Casts this union to a {@link StandardGuildMessageChannel}. * This method exists for developer discoverability. * *

Note: This is effectively equivalent to using the cast operator: *


     * //These are the same!
     * StandardGuildMessageChannel channel = union.asStandardGuildMessageChannel();
     * StandardGuildMessageChannel channel2 = (StandardGuildMessageChannel) union;
     * 
* * @throws IllegalStateException * If the channel represented by this union is not actually a {@link StandardGuildMessageChannel}. * * @return The channel as a {@link StandardGuildMessageChannel} */ @Nonnull StandardGuildMessageChannel asStandardGuildMessageChannel(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy