/
ForumChannel.java
145 lines (129 loc) · 4.45 KB
/
ForumChannel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
* 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.Guild;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.entities.channel.attribute.IAgeRestrictedChannel;
import net.dv8tion.jda.api.entities.channel.attribute.IPostContainer;
import net.dv8tion.jda.api.entities.channel.attribute.ISlowmodeChannel;
import net.dv8tion.jda.api.entities.channel.attribute.IWebhookContainer;
import net.dv8tion.jda.api.entities.channel.middleman.StandardGuildChannel;
import net.dv8tion.jda.api.managers.channel.concrete.ForumChannelManager;
import net.dv8tion.jda.api.requests.restaction.ChannelAction;
import net.dv8tion.jda.api.requests.restaction.ForumPostAction;
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
import javax.annotation.Nonnull;
import java.util.Collection;
/**
* A Forum Channel which contains {@link #createForumPost(String, MessageCreateData) Forum Posts}.
* <br>Forum posts are simply {@link ThreadChannel ThreadChannels} of type {@link ChannelType#GUILD_PUBLIC_THREAD}.
*
* <p>The {@code CREATE POSTS} permission that is shown in the official Discord Client, is an alias for {@link net.dv8tion.jda.api.Permission#MESSAGE_SEND Permission.MESSAGE_SEND}.
* {@link net.dv8tion.jda.api.Permission#CREATE_PUBLIC_THREADS Permission.CREATE_PUBLIC_THREADS} is ignored for creating forum posts.
*
* @see Guild#createForumChannel(String, Category)
* @see #createForumPost(String, MessageCreateData)
*/
public interface ForumChannel extends StandardGuildChannel, IPostContainer, IWebhookContainer, IAgeRestrictedChannel, ISlowmodeChannel
{
/**
* The maximum length of a forum topic ({@value #MAX_FORUM_TOPIC_LENGTH})
*/
int MAX_FORUM_TOPIC_LENGTH = IPostContainer.MAX_POST_CONTAINER_TOPIC_LENGTH;
/**
* The maximum number of {@link ForumPostAction#setTags(Collection) tags} that can be applied to a forum post. ({@value #MAX_POST_TAGS})
*/
int MAX_POST_TAGS = IPostContainer.MAX_POST_TAGS;
@Nonnull
@Override
default ChannelType getType()
{
return ChannelType.FORUM;
}
@Nonnull
@Override
ForumChannelManager getManager();
@Nonnull
@Override
ChannelAction<ForumChannel> createCopy(@Nonnull Guild guild);
@Nonnull
@Override
default ChannelAction<ForumChannel> createCopy()
{
return createCopy(getGuild());
}
/**
* The default layout used to show threads.
*
* @return The default layout used to show threads.
*/
@Nonnull
Layout getDefaultLayout();
/**
* The layout used to sort forum posts.
*/
enum Layout
{
/**
* Displayed as default (not set).
*/
DEFAULT_VIEW(0),
/**
* Displayed as a chronological list.
*/
LIST_VIEW(1),
/**
* Displayed as a collection of tiles.
*/
GALLERY_VIEW(2),
/**
* Placeholder for future layout types.
*/
UNKNOWN(-1);
private final int key;
Layout(int key)
{
this.key = key;
}
/**
* The underlying value as used by Discord.
*
* @return The raw order key
*/
public int getKey()
{
return key;
}
/**
* The {@link Layout} for the provided key.
*
* @param key
* The key to get the {@link Layout} for
*
* @return The {@link Layout} for the provided key, or {@link #UNKNOWN} if the key is not known
*/
@Nonnull
public static Layout fromKey(int key)
{
for (Layout layout : values())
{
if (layout.key == key)
return layout;
}
return UNKNOWN;
}
}
}