Skip to content

Commit

Permalink
Add interface type to channel types (#2567)
Browse files Browse the repository at this point in the history
  • Loading branch information
freya022 authored Oct 29, 2023
1 parent b6fedfc commit 217bea1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 16 deletions.
45 changes: 29 additions & 16 deletions src/main/java/net/dv8tion/jda/api/entities/channel/ChannelType.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,69 +28,82 @@ public enum ChannelType
/**
* A {@link TextChannel TextChannel}, Guild-Only.
*/
TEXT(0, 0, true),
TEXT(TextChannel.class, 0, 0, true),
/**
* A {@link PrivateChannel PrivateChannel}.
*/
PRIVATE(1, -1),
PRIVATE(PrivateChannel.class, 1, -1),
/**
* A {@link VoiceChannel VoiceChannel}, Guild-Only.
*/
VOICE(2, 1, true),
VOICE(VoiceChannel.class, 2, 1, true),
/**
* A Group. (unused)
*/
GROUP(3, -1),
GROUP(GroupChannel.class, 3, -1),
/**
* A {@link Category Category}, Guild-Only.
*/
CATEGORY(4, 2, true),
CATEGORY(Category.class, 4, 2, true),
/**
* A {@link NewsChannel NewsChannel}, Guild-Only.
*/
NEWS(5, 0, true),
NEWS(NewsChannel.class, 5, 0, true),
/**
* A {@link StageChannel StageChannel}, Guild-Only.
*/
STAGE(13, 1, true),
STAGE(StageChannel.class, 13, 1, true),

GUILD_NEWS_THREAD(10, -1, true),
GUILD_PUBLIC_THREAD(11, -1, true),
GUILD_PRIVATE_THREAD(12, -1, true),
GUILD_NEWS_THREAD(ThreadChannel.class, 10, -1, true),
GUILD_PUBLIC_THREAD(ThreadChannel.class, 11, -1, true),
GUILD_PRIVATE_THREAD(ThreadChannel.class, 12, -1, true),

/**
* A {@link net.dv8tion.jda.api.entities.channel.concrete.ForumChannel ForumChannel}, Guild-Only.
*/
FORUM(15, 0, true),
FORUM(ForumChannel.class, 15, 0, true),

/**
* A {@link MediaChannel}, Guild-Only.
*/
MEDIA(16, 0, true),
MEDIA(MediaChannel.class, 16, 0, true),

/**
* Unknown Discord channel type.
*
* <p>This might be used in the case when a channel is not available in cache, like when sending webhook messages.
*/
UNKNOWN(-1, -2);
UNKNOWN(Channel.class, -1, -2);

private final int sortBucket;
private final int id;
private final boolean isGuild;
private final Class<? extends Channel> clazz;

ChannelType(int id, int sortBucket)
ChannelType(Class<? extends Channel> clazz, int id, int sortBucket)
{
this(id, sortBucket, false);
this(clazz, id, sortBucket, false);
}

ChannelType(int id, int sortBucket, boolean isGuild)
ChannelType(Class<? extends Channel> clazz, int id, int sortBucket, boolean isGuild)
{
this.clazz = clazz;
this.id = id;
this.sortBucket = sortBucket;
this.isGuild = isGuild;
}

/**
* The interface this channel type corresponds to.
*
* @return This channel type's interface
*/
@Nonnull
public Class<? extends Channel> getInterface()
{
return this.clazz;
}

/**
* The sorting bucket for this channel type.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.concrete;

import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;

/**
* Represents a Group DM channel.
*
* <p><b>This is currently unused.</b>
*/
public interface GroupChannel extends MessageChannel
{
}

0 comments on commit 217bea1

Please sign in to comment.