/
EmoteManager.java
118 lines (107 loc) · 3.74 KB
/
EmoteManager.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
/*
* Copyright 2015-2016 Austin Keener & Michael Ritter
*
* 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.client.managers;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.Emote;
import net.dv8tion.jda.core.entities.Guild;
import net.dv8tion.jda.core.entities.Role;
import net.dv8tion.jda.core.entities.impl.EmoteImpl;
import net.dv8tion.jda.core.exceptions.AccountTypeException;
import net.dv8tion.jda.core.exceptions.PermissionException;
import net.dv8tion.jda.core.requests.RestAction;
import java.util.Set;
/**
* Used to modify or delete an Emote.<p>
* <b>This is a <u>client only</u> function!</b>
*/
public class EmoteManager
{
protected final EmoteManagerUpdatable updatable;
public EmoteManager(EmoteImpl emote)
{
this.updatable = new EmoteManagerUpdatable(emote);
}
/**
* The {@link net.dv8tion.jda.core.JDA JDA} instance of this Emote
*
* @return
* The JDA instance of this Emote
*/
public JDA getJDA()
{
return updatable.getJDA();
}
/**
* The {@link net.dv8tion.jda.core.entities.Guild Guild} this emote is in
*
* @return
* The Guild of the respected Emote
*/
public Guild getGuild()
{
return updatable.getGuild();
}
/**
* The {@link net.dv8tion.jda.core.entities.Emote Emote} represented by this Manager.
*
* @return
* The Emote
*/
public Emote getEmote()
{
return updatable.getEmote();
}
/**
* Sets the name of this Emote.<p>
* <b>This is a <u>client only</u> function!</b>
*
* @param name
* The name to set for this Emote (null to keep current name)
* @return
* {@link net.dv8tion.jda.core.requests.RestAction RestAction} - <br>
* <b>Type</b>: {@link java.lang.Void}<br>
* <b>Value</b>: None
* @throws AccountTypeException
* if the current AccountType is not Client
* @throws PermissionException
* if either the Emote trying to update is fake or we do not have the required Permissions to update this emote
* @throws IllegalArgumentException
* if the specified name has less than 2 chars or more than 32 chars.
*/
public RestAction<Void> setName(String name)
{
return updatable.getNameField().setValue(name).update();
}
/**
* Set roles this emote is active for.<p>
* <b>This is a <u>client only</u> function!</b>
*
* @param roles
* A set of roles (all within the same guild the emote is in) / null to keep current roles
* @return
* {@link net.dv8tion.jda.core.requests.RestAction RestAction} - <br>
* <b>Type</b>: {@link java.lang.Void}<br>
* <b>Value</b>: None
* @throws AccountTypeException
* if the current AccountType is not Client
* @throws PermissionException
* if either the Emote trying to update is fake or we do not have the required Permissions to update this emote
*/
public RestAction<Void> setRoles(Set<Role> roles)
{
return updatable.getRolesField().setValue(roles).update();
}
}