-
-
Notifications
You must be signed in to change notification settings - Fork 737
/
TemplateGuild.java
247 lines (227 loc) · 7.83 KB
/
TemplateGuild.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/*
* 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.templates;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Guild.ExplicitContentLevel;
import net.dv8tion.jda.api.entities.Guild.NotificationLevel;
import net.dv8tion.jda.api.entities.Guild.Timeout;
import net.dv8tion.jda.api.entities.Guild.VerificationLevel;
import net.dv8tion.jda.api.entities.ISnowflake;
import net.dv8tion.jda.api.interactions.DiscordLocale;
import net.dv8tion.jda.api.utils.ImageProxy;
import org.jetbrains.annotations.Unmodifiable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
/**
* POJO for the guild information provided by a template.
*
* @see Template#getGuild()
*/
public class TemplateGuild implements ISnowflake
{
private final long id;
private final String name, description, iconId;
private final VerificationLevel verificationLevel;
private final NotificationLevel notificationLevel;
private final ExplicitContentLevel explicitContentLevel;
private final DiscordLocale locale;
private final Timeout afkTimeout;
private final TemplateChannel afkChannel;
private final TemplateChannel systemChannel;
private final List<TemplateRole> roles;
private final List<TemplateChannel> channels;
public TemplateGuild(final long id, final String name, final String description, final String iconId, final VerificationLevel verificationLevel,
final NotificationLevel notificationLevel, final ExplicitContentLevel explicitContentLevel, final DiscordLocale locale, final Timeout afkTimeout,
final TemplateChannel afkChannel, final TemplateChannel systemChannel, final List<TemplateRole> roles, final List<TemplateChannel> channels)
{
this.id = id;
this.name = name;
this.description = description;
this.iconId = iconId;
this.verificationLevel = verificationLevel;
this.notificationLevel = notificationLevel;
this.explicitContentLevel = explicitContentLevel;
this.locale = locale;
this.afkTimeout = afkTimeout;
this.afkChannel = afkChannel;
this.systemChannel = systemChannel;
this.roles = Collections.unmodifiableList(roles);
this.channels = Collections.unmodifiableList(channels);
}
@Override
public long getIdLong()
{
return this.id;
}
/**
* The name of this guild.
*
* @return The guild's name
*/
@Nonnull
public String getName()
{
return this.name;
}
/**
* The description for this guild.
* <br>This is displayed in the server browser below the guild name for verified guilds.
*
* @return The description
*/
@Nullable
public String getDescription()
{
return this.description;
}
/**
* The icon id of this guild.
*
* @return The guild's icon id
*
* @see #getIconUrl()
*/
@Nullable
public String getIconId()
{
return this.iconId;
}
/**
* The icon url of this guild.
*
* @return The guild's icon url
*
* @see #getIconId()
*/
@Nullable
public String getIconUrl()
{
return this.iconId == null ? null
: String.format(Guild.ICON_URL, this.id, this.iconId, iconId.startsWith("a_") ? "gif" : "png");
}
/**
* Returns an {@link ImageProxy} for this template guild's icon.
*
* @return Possibly-null {@link ImageProxy} of this template guild's icon
*
* @see #getIconUrl()
*/
@Nullable
public ImageProxy getIcon()
{
final String iconUrl = getIconUrl();
return iconUrl == null ? null : new ImageProxy(iconUrl);
}
/**
* Returns the {@link net.dv8tion.jda.api.entities.Guild.VerificationLevel VerificationLevel} of this guild.
*
* @return the verification level of the guild
*/
@Nonnull
public VerificationLevel getVerificationLevel()
{
return this.verificationLevel;
}
/**
* Returns the {@link net.dv8tion.jda.api.entities.Guild.NotificationLevel NotificationLevel} of this guild.
*
* @return the notification level of the guild
*/
@Nonnull
public NotificationLevel getDefaultNotificationLevel()
{
return this.notificationLevel;
}
/**
* Returns the {@link net.dv8tion.jda.api.entities.Guild.ExplicitContentLevel ExplicitContentLevel} of this guild.
*
* @return the explicit content level of the guild
*/
@Nonnull
public ExplicitContentLevel getExplicitContentLevel()
{
return this.explicitContentLevel;
}
/**
* The preferred locale for this guild.
*
* @return The preferred {@link DiscordLocale} for this guild
*/
@Nonnull
public DiscordLocale getLocale()
{
return this.locale;
}
/**
* Returns the {@link net.dv8tion.jda.api.entities.Guild.Timeout AFK Timeout} for this guild.
*
* @return the afk timeout for this guild
*/
@Nonnull
public Timeout getAfkTimeout()
{
return this.afkTimeout;
}
/**
* Provides the {@link net.dv8tion.jda.api.entities.templates.TemplateChannel TemplateChannel} that has been set as the channel
* which {@link net.dv8tion.jda.api.entities.Member Members} will be moved to after they have been inactive in a
* {@link net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel VoiceChannel} for longer than {@link #getAfkTimeout()}.
* <br>If no channel has been set as the AFK channel, this returns {@code null}.
*
* @return Possibly-null {@link net.dv8tion.jda.api.entities.templates.TemplateChannel TemplateChannel} that is the AFK Channel.
*/
@Nullable
public TemplateChannel getAfkChannel()
{
return this.afkChannel;
}
/**
* Provides the {@link net.dv8tion.jda.api.entities.templates.TemplateChannel TemplateChannel} that has been set as the channel
* which newly joined {@link net.dv8tion.jda.api.entities.Member Members} will be announced in.
* <br>If no channel has been set as the system channel, this returns {@code null}.
*
* @return Possibly-null {@link net.dv8tion.jda.api.entities.templates.TemplateChannel TemplateChannel} that is the system Channel.
*/
@Nullable
public TemplateChannel getSystemChannel()
{
return this.systemChannel;
}
/**
* Gets all {@link net.dv8tion.jda.api.entities.templates.TemplateRole Roles} in this {@link net.dv8tion.jda.api.entities.templates.TemplateGuild Guild}.
*
* @return An immutable List of {@link net.dv8tion.jda.api.entities.templates.TemplateRole Roles}.
*/
@Nonnull
@Unmodifiable
public List<TemplateRole> getRoles()
{
return this.roles;
}
/**
* Gets all {@link net.dv8tion.jda.api.entities.templates.TemplateChannel Channels} in this {@link net.dv8tion.jda.api.entities.templates.TemplateGuild Guild}.
*
* @return An immutable List of {@link net.dv8tion.jda.api.entities.templates.TemplateChannel Channels}.
*/
@Nonnull
@Unmodifiable
public List<TemplateChannel> getChannels()
{
return this.channels;
}
}