本文整理汇总了Java中net.dv8tion.jda.core.requests.restaction.AuditableRestAction类的典型用法代码示例。如果您正苦于以下问题:Java AuditableRestAction类的具体用法?Java AuditableRestAction怎么用?Java AuditableRestAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuditableRestAction类属于net.dv8tion.jda.core.requests.restaction包,在下文中一共展示了AuditableRestAction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: delete
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
Route.CompiledRoute route = Route.Webhooks.DELETE_TOKEN_WEBHOOK.compile(getId(), token);
return new AuditableRestAction<Void>(getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:17,代码来源:WebhookImpl.java
示例2: delete
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
checkPermission(Permission.MANAGE_CHANNEL);
Route.CompiledRoute route = Route.Channels.DELETE_CHANNEL.compile(getId());
return new AuditableRestAction<Void>(getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:19,代码来源:AbstractChannelImpl.java
示例3: delete
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
if (!channel.getGuild().getSelfMember().hasPermission(channel, Permission.MANAGE_PERMISSIONS))
throw new InsufficientPermissionException(Permission.MANAGE_PERMISSIONS);
String targetId = isRoleOverride() ? getRole().getId() : getMember().getUser().getId();
Route.CompiledRoute route = Route.Channels.DELETE_PERM_OVERRIDE.compile(channel.getId(), targetId);
return new AuditableRestAction<Void>(getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:21,代码来源:PermissionOverrideImpl.java
示例4: deleteWebhookById
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> deleteWebhookById(String id)
{
Checks.notEmpty(id, "webhook id");
if (!guild.getSelfMember().hasPermission(this, Permission.MANAGE_WEBHOOKS))
throw new InsufficientPermissionException(Permission.MANAGE_WEBHOOKS);
Route.CompiledRoute route = Route.Webhooks.DELETE_WEBHOOK.compile(id);
return new AuditableRestAction<Void>(getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:22,代码来源:TextChannelImpl.java
示例5: delete
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
if (!getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES))
throw new InsufficientPermissionException(Permission.MANAGE_ROLES);
if(!PermissionUtil.canInteract(getGuild().getSelfMember(), this))
throw new HierarchyException("Can't delete role >= highest self-role");
if (managed)
throw new UnsupportedOperationException("Cannot delete a Role that is managed. ");
Route.CompiledRoute route = Route.Roles.DELETE_ROLE.compile(guild.getId(), getId());
return new AuditableRestAction<Void>(getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:24,代码来源:RoleImpl.java
示例6: delete
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
final Route.CompiledRoute route = Route.Invites.DELETE_INVITE.compile(this.code);
return new AuditableRestAction<Void>(this.api, route)
{
@Override
protected void handleResponse(final Response response, final Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:18,代码来源:InviteImpl.java
示例7: delete
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
if (isFake())
throw new IllegalStateException("The emote you are trying to delete is not an actual emote we have access to (it is fake)!");
if (managed)
throw new UnsupportedOperationException("You cannot delete a managed emote!");
if (!guild.getSelfMember().hasPermission(Permission.MANAGE_EMOTES))
throw new InsufficientPermissionException(Permission.MANAGE_EMOTES);
Route.CompiledRoute route = Route.Emotes.DELETE_EMOTE.compile(getGuild().getId(), getId());
return new AuditableRestAction<Void>(getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:24,代码来源:EmoteImpl.java
示例8: update
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
/**
* Creates a new {@link net.dv8tion.jda.core.requests.RestAction RestAction} instance
* that will apply <b>all</b> changes that have been made to this manager instance.
* <br>If no changes have been made this will simply return {@link net.dv8tion.jda.core.requests.RestAction.EmptyRestAction EmptyRestAction}.
*
* <p>Before applying new changes it is recommended to call {@link #reset()} to reset previous changes.
* <br>This is automatically called if this method returns successfully.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} for this
* update include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_EMOJI UNKNOWN_EMOJI}
* <br>If the target Emote was deleted before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>If the currently logged in account was removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>If the currently logged in account loses the {@link net.dv8tion.jda.core.Permission#MANAGE_EMOTES MANAGE_EMOTES Permission}
* before finishing the task</li>
* </ul>
*
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have the Permission {@link net.dv8tion.jda.core.Permission#MANAGE_EMOTES MANAGE_EMOTES}
* in the underlying {@link net.dv8tion.jda.core.entities.Guild Guild}.
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
* <br>Applies all changes that have been made in a single api-call.
*/
@CheckReturnValue
public AuditableRestAction<Void> update()
{
checkPermission(Permission.MANAGE_EMOTES);
if (!needsUpdate())
return new AuditableRestAction.EmptyRestAction<>(getJDA(), null);
JSONObject body = new JSONObject();
if (name.shouldUpdate())
body.put("name", name.getValue());
if (roles.shouldUpdate())
body.put("roles", roles.getValue().stream().map(ISnowflake::getId).collect(Collectors.toList()));
reset(); //reset because we built the JSONObject needed to update
Route.CompiledRoute route = Route.Emotes.MODIFY_EMOTE.compile(getGuild().getId(), emote.getId());
return new AuditableRestAction<Void>(getJDA(), route, body)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:59,代码来源:EmoteManagerUpdatable.java
示例9: update
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
/**
* Creates a new {@link net.dv8tion.jda.core.requests.RestAction RestAction} instance
* that will apply <b>all</b> changes that have been made to this manager instance.
* <br>If no changes have been made this will simply return {@link net.dv8tion.jda.core.requests.RestAction.EmptyRestAction EmptyRestAction}.
*
* <p>Before applying new changes it is recommended to call {@link #reset()} to reset previous changes.
* <br>This is automatically called if this method returns successfully.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} for this
* update include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_ROLE UNKNOWN_ROLE}
* <br>If the Role was deleted before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>If the currently logged in account was removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>If the currently logged in account loses the {@link net.dv8tion.jda.core.Permission#MANAGE_ROLES MANAGE_ROLES Permission} or lost
* positional power before finishing the task</li>
* </ul>
*
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have the Permission {@link net.dv8tion.jda.core.Permission#MANAGE_ROLES MANAGE_ROLES}
* @throws net.dv8tion.jda.core.exceptions.HierarchyException
* If the currently logged in account does not meet the required hierarchy position
* to {@link Role#canInteract(net.dv8tion.jda.core.entities.Role) interact} with this Role
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
* <br>Applies all changes that have been made in a single api-call.
*/
@CheckReturnValue
public AuditableRestAction<Void> update()
{
checkPermission(Permission.MANAGE_ROLES);
checkPosition();
if (!needsUpdate())
return new AuditableRestAction.EmptyRestAction<>(getJDA(), null);
//TODO: check if all of this is *actually* needed.
JSONObject body = new JSONObject().put("name", role.getName());
if(name.shouldUpdate())
body.put("name", name.getValue());
if(color.shouldUpdate())
body.put("color", color.getValue() == null ? 0 : color.getValue().getRGB() & 0xFFFFFF);
if(hoisted.shouldUpdate())
body.put("hoist", hoisted.getValue().booleanValue());
if(mentionable.shouldUpdate())
body.put("mentionable", mentionable.getValue().booleanValue());
if (permissions.shouldUpdate())
body.put("permissions", permissions.getValue());
reset();
Route.CompiledRoute route = Route.Roles.MODIFY_ROLE.compile(getGuild().getId(), role.getId());
return new AuditableRestAction<Void>(getJDA(), route, body)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:69,代码来源:RoleManagerUpdatable.java
示例10: update
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
/**
* Creates a new {@link net.dv8tion.jda.core.requests.RestAction RestAction} instance
* that will apply <b>all</b> changes that have been made to this manager instance.
* <br>If no changes have been made this will simply return {@link net.dv8tion.jda.core.requests.RestAction.EmptyRestAction EmptyRestAction}.
*
* <p>Before applying new changes it is recommended to call {@link #reset()} to reset previous changes.
* <br>This is automatically called if this method returns successfully.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} for this
* update include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>If the TextChannel was deleted before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>If the currently logged in account was removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>If the currently logged in account loses the {@link net.dv8tion.jda.core.Permission#MANAGE_WEBHOOKS MANAGE_WEBHOOKS Permission}</li>
* </ul>
*
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have the Permission {@link net.dv8tion.jda.core.Permission#MANAGE_WEBHOOKS MANAGE_WEBHOOKS}
* in either the current or selected new TextChannel.
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
* <br>Applies all changes that have been made in a single api-call.
*/
@CheckReturnValue
public AuditableRestAction<Void> update()
{
Member self = getGuild().getSelfMember();
if (!self.hasPermission(webhook.getChannel(), Permission.MANAGE_WEBHOOKS))
throw new InsufficientPermissionException(Permission.MANAGE_WEBHOOKS);
if (channel.isSet() && !self.hasPermission(channel.getValue(), Permission.MANAGE_WEBHOOKS))
throw new InsufficientPermissionException(Permission.MANAGE_WEBHOOKS, "Permission not available in selected new channel");
if (!shouldUpdate())
return new AuditableRestAction.EmptyRestAction<>(getJDA(), null);
JSONObject data = new JSONObject();
data.put("name", name.getOriginalValue());
if (channel.shouldUpdate())
data.put("channel_id", channel.getValue().getId());
if (name.shouldUpdate())
data.put("name", name.getValue());
if (avatar.shouldUpdate())
{
Icon value = avatar.getValue();
data.put("avatar", value != null ? value.getEncoding() : JSONObject.NULL);
}
Route.CompiledRoute route = Route.Webhooks.MODIFY_WEBHOOK.compile(webhook.getId());
return new AuditableRestAction<Void>(getJDA(), route, data)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:66,代码来源:WebhookManagerUpdatable.java
示例11: update
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
/**
* Creates a new {@link net.dv8tion.jda.core.requests.RestAction RestAction} instance
* that will apply <b>all</b> changes that have been made to this manager instance.
* <br>If no changes have been made this will simply return {@link net.dv8tion.jda.core.requests.RestAction.EmptyRestAction EmptyRestAction}.
*
* <p>Before applying new changes it is recommended to call {@link #reset()} to reset previous changes.
* <br>This is automatically called if this method returns successfully.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} for this
* update include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_OVERRIDE UNKNOWN_OVERRIDE}
* <br>If the PermissionOverride was deleted before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>If the currently logged in account was removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>If the currently logged in account loses the {@link net.dv8tion.jda.core.Permission#MANAGE_PERMISSIONS MANAGE_PERMISSIONS Permission}</li>
* </ul>
*
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have the Permission {@link net.dv8tion.jda.core.Permission#MANAGE_PERMISSIONS MANAGE_PERMISSIONS}
* in the {@link #getChannel() Channel}
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
* <br>Applies all changes that have been made in a single api-call.
*/
@CheckReturnValue
public AuditableRestAction<Void> update()
{
checkPermission(Permission.MANAGE_PERMISSIONS);
if (!shouldUpdate())
return new AuditableRestAction.EmptyRestAction<>(getJDA(), null);
String targetId = override.isRoleOverride() ? override.getRole().getId() : override.getMember().getUser().getId();
JSONObject body = new JSONObject()
.put("id", targetId)
.put("type", override.isRoleOverride() ? "role" : "member")
.put("allow", getAllowBits())
.put("deny", getDenyBits());
reset();
Route.CompiledRoute route = Route.Channels.MODIFY_PERM_OVERRIDE.compile(override.getChannel().getId(), targetId);
return new AuditableRestAction<Void>(getJDA(), route, body)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:58,代码来源:PermOverrideManagerUpdatable.java
示例12: update
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
/**
* Creates a new {@link net.dv8tion.jda.core.requests.RestAction RestAction} instance
* that will apply <b>all</b> changes that have been made to this manager instance.
* <br>If no changes have been made this will simply return {@link net.dv8tion.jda.core.requests.RestAction.EmptyRestAction EmptyRestAction}.
*
* <p>Before applying new changes it is recommended to call {@link #reset()} to reset previous changes.
* <br>This is automatically called if this method returns successfully.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} for this
* update include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL}
* <br>If the Channel was deleted before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>If the currently logged in account was removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>If the currently logged in account loses the {@link net.dv8tion.jda.core.Permission#MANAGE_CHANNEL MANAGE_CHANNEL Permission}
* before finishing the task</li>
* </ul>
*
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have the Permission {@link net.dv8tion.jda.core.Permission#MANAGE_CHANNEL MANAGE_CHANNEL}
* in the underlying {@link net.dv8tion.jda.core.entities.Channel Channel}.
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
* <br>Applies all changes that have been made in a single api-call.
*/
@CheckReturnValue
public AuditableRestAction<Void> update()
{
checkPermission(Permission.MANAGE_CHANNEL);
if (!needToUpdate())
return new AuditableRestAction.EmptyRestAction<>(getJDA(), null);
JSONObject frame = new JSONObject().put("name", channel.getName());
if (name.shouldUpdate())
frame.put("name", name.getValue());
if (position.shouldUpdate())
frame.put("position", position.getValue());
if (topic != null && topic.shouldUpdate())
frame.put("topic", topic.getValue() == null ? JSONObject.NULL : topic.getValue());
if (nsfw != null && nsfw.shouldUpdate())
frame.put("nsfw", nsfw.getValue());
if (userLimit != null && userLimit.shouldUpdate())
frame.put("user_limit", userLimit.getValue());
if (bitrate != null && bitrate.shouldUpdate())
frame.put("bitrate", bitrate.getValue());
if (parent != null && parent.shouldUpdate())
frame.put("parent_id", parent.getValue() == null ? JSONObject.NULL : parent.getValue().getIdLong());
reset(); //now that we've built our JSON object, reset the manager back to the non-modified state
Route.CompiledRoute route = Route.Channels.MODIFY_CHANNEL.compile(channel.getId());
return new AuditableRestAction<Void>(channel.getJDA(), route, frame)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:68,代码来源:ChannelManagerUpdatable.java
示例13: delete
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete()
{
if (!getJDA().getSelfUser().equals(getAuthor()))
{
if (isFromType(ChannelType.PRIVATE) || isFromType(ChannelType.GROUP))
throw new IllegalStateException("Cannot delete another User's messages in a Group or PrivateChannel.");
else if (!getGuild().getSelfMember()
.hasPermission((TextChannel) getChannel(), Permission.MESSAGE_MANAGE))
throw new InsufficientPermissionException(Permission.MESSAGE_MANAGE);
}
return channel.deleteMessageById(getIdLong());
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:14,代码来源:ReceivedMessage.java
示例14: deleteMessageById
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> deleteMessageById(String messageId)
{
Checks.notEmpty(messageId, "messageId");
checkPermission(Permission.MESSAGE_READ);
//Call MessageChannel's default method
return TextChannel.super.deleteMessageById(messageId);
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:10,代码来源:TextChannelImpl.java
示例15: delete
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete() {
return null;
}
开发者ID:Chikachi,项目名称:DiscordIntegrationCore,代码行数:5,代码来源:FakeRole.java
示例16: createEmote
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
private void createEmote(String iconName, CommandEvent commandEvent, Icon icon, Role... roles) {
JSONObject body = new JSONObject();
body.put("name", iconName);
body.put("image", icon.getEncoding());
if (roles.length > 0) // making sure none of the provided roles are null before mapping them to the snowflake id
{
body.put("roles",
Stream.of(roles).filter(Objects::nonNull).map(ISnowflake::getId).collect(Collectors.toSet()));
}
// todo: check bot permissions, must be able to handle emojis
GuildImpl guild = (GuildImpl) commandEvent.getGuild();
JDA jda = commandEvent.getJDA();
Route.CompiledRoute route = Route.Emotes.CREATE_EMOTE.compile(guild.getId());
AuditableRestAction<Emote> action = new AuditableRestAction<Emote>(jda, route, body)
{
@Override
protected void handleResponse(Response response, Request<Emote> request)
{
if (response.isOk()) {
JSONObject obj = response.getObject();
final long id = obj.getLong("id");
String name = obj.getString("name");
EmoteImpl emote = new EmoteImpl(id, guild).setName(name);
// managed is false by default, should always be false for emotes created by client accounts.
JSONArray rolesArr = obj.getJSONArray("roles");
Set<Role> roleSet = emote.getRoleSet();
for (int i = 0; i < rolesArr.length(); i++)
{
roleSet.add(guild.getRoleById(rolesArr.getString(i)));
}
// put emote into cache
guild.getEmoteMap().put(id, emote);
request.onSuccess(emote);
}
else {
request.onFailure(response);
throw new RuntimeException("Couldn't install emojis. " +
"Make sure that pokeraidbot has access to manage emojis.");
}
}
};
action.queue();
}
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:48,代码来源:InstallEmotesCommand.java
示例17: prune
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
/**
* This method will prune (kick) all members who were offline for at least <i>days</i> days.
* <br>The RestAction returned from this method will return the amount of Members that were pruned.
* <br>You can use {@link Guild#getPrunableMemberCount(int)} to determine how many Members would be pruned if you were to
* call this method.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The prune cannot finished due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>We were removed from the Guild before finishing the task</li>
* </ul>
*
* @param days
* Minimum number of days since a member has been offline to get affected.
*
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
* If the account doesn't have {@link net.dv8tion.jda.core.Permission#KICK_MEMBERS KICK_MEMBER} Permission.
* @throws net.dv8tion.jda.core.exceptions.GuildUnavailableException
* If the guild is temporarily not {@link net.dv8tion.jda.core.entities.Guild#isAvailable() available}
* @throws IllegalArgumentException
* If the provided days are less than {@code 1}
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction} - Type: Integer
* <br>The amount of Members that were pruned from the Guild.
*/
@CheckReturnValue
public AuditableRestAction<Integer> prune(int days)
{
checkAvailable();
checkPermission(Permission.KICK_MEMBERS);
Checks.check(days >= 1, "Days amount must be at minimum 1 day.");
Route.CompiledRoute route = Route.Guilds.PRUNE_MEMBERS.compile(guild.getId()).withQueryParams("days", Integer.toString(days));
return new AuditableRestAction<Integer>(guild.getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Integer> request)
{
if (response.isOk())
request.onSuccess(response.getObject().getInt("pruned"));
else
request .onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:51,代码来源:GuildController.java
示例18: unban
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
/**
* Unbans the a user specified by the userId from this Guild.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The target Member cannot be unbanned due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>We were removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_USER UNKNOWN_USER}
* <br>The specified User is invalid</li>
* </ul>
*
* @param userId
* The id of the {@link net.dv8tion.jda.core.entities.User User} to unban.
*
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
* If the logged in account does not have the {@link net.dv8tion.jda.core.Permission#BAN_MEMBERS} permission.
* @throws net.dv8tion.jda.core.exceptions.GuildUnavailableException
* If the guild is temporarily not {@link net.dv8tion.jda.core.entities.Guild#isAvailable() available}
* @throws IllegalArgumentException
* If the provided id is null or blank
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
*/
@CheckReturnValue
public AuditableRestAction<Void> unban(String userId)
{
checkAvailable();
Checks.notBlank(userId, "User ID");
checkPermission(Permission.BAN_MEMBERS);
Route.CompiledRoute route = Route.Guilds.UNBAN.compile(guild.getId(), userId);
return new AuditableRestAction<Void>(guild.getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else if (response.code == 404)
request.onFailure(new IllegalArgumentException("User with provided id \"" + userId + "\" does not exist! Cannot unban a non-existent user!"));
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:52,代码来源:GuildController.java
示例19: addSingleRoleToMember
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
/**
* Atomically assigns the provided {@link net.dv8tion.jda.core.entities.Role Role} to the specified {@link net.dv8tion.jda.core.entities.Member Member}.
* <br><b>This can be used together with other role modification methods as it does not require an updated cache!</b>
*
* <p>If multiple roles should be added/removed (efficiently) in one request
* you may use {@link #modifyMemberRoles(Member, Collection, Collection) modifyMemberRoles(Member, Collection, Collection)} or similar methods.
*
* <p>If the specified role is already present in the member's set of roles this does nothing.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The Members Roles could not be modified due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>We were removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
* <br>The target Member was removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_ROLE UNKNOWN_ROLE}
* <br>If the specified Role does not exist</li>
* </ul>
*
* @param member
* The target member who will receive the new role
* @param role
* The role which should be assigned atomically
*
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If the specified member/role are not from the current Guild</li>
* <li>Either member or role are {@code null}</li>
* </ul>
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermissionException
* If the currently logged in account does not have {@link net.dv8tion.jda.core.Permission#MANAGE_ROLES Permission.MANAGE_ROLES}
* @throws net.dv8tion.jda.core.exceptions.HierarchyException
* If the provided roles are higher in the Guild's hierarchy
* and thus cannot be modified by the currently logged in account
*
* @return {@link net.dv8tion.jda.core.requests.restaction.AuditableRestAction AuditableRestAction}
*/
@CheckReturnValue
public AuditableRestAction<Void> addSingleRoleToMember(Member member, Role role)
{
Checks.notNull(member, "Member");
Checks.notNull(role, "Role");
checkGuild(member.getGuild(), "Member");
checkGuild(role.getGuild(), "Role");
checkPermission(Permission.MANAGE_ROLES);
checkPosition(role);
Route.CompiledRoute route = Route.Guilds.ADD_MEMBER_ROLE.compile(guild.getId(), member.getUser().getId(), role.getId());
return new AuditableRestAction<Void>(getJDA(), route)
{
@Override
protected void handleResponse(Response response, Request<Void> request)
{
if (response.isOk())
request.onSuccess(null);
else
request.onFailure(response);
}
};
}
开发者ID:DV8FromTheWorld,项目名称:JDA,代码行数:67,代码来源:GuildController.java
示例20: removeSingleRoleFromMember
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
/**
* Atomically removes the provided {@link net.dv8tion.jda.core.entities.Role Role} from the specified {@link net.dv8tion.jda.core.entities.Member Member}.
* <br><b>This can be used together with other role modification methods as it does not require an updated cache!</b>
*
* <p>If multiple roles should be added/removed (efficiently) in one request
* you may use {@link #modifyMemberRoles(Member, Collection, Collection) modifyMemberRoles(Member, Collection, Collection)} or similar methods.
*
* <p>If the specified role is not present in the member's set of roles this does nothing.
*
* <p>Possible {@link net.dv8tion.jda.core.requests.ErrorResponse ErrorResponses} caused by
* the returned {@link net.dv8tion.jda.core.requests.RestAction RestAction} include the following:
* <ul>
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_PERMISSIONS MISSING_PERMISSIONS}
* <br>The Members Roles could not be modified due to a permission discrepancy</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS}
* <br>We were removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_MEMBER UNKNOWN_MEMBER}
* <br>The target Member was removed from the Guild before finishing the task</li>
*
* <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_ROLE UNKNOWN_ROLE}
* <br>If the specified Role does not exist</li>
* </ul>
*
* @param member
* The target member who will lose the specified role
* @param role
* The role which should be removed atomically
*
* @throws java.lang.IllegalArgumentException
* <ul>
* <li>If the specified member/role are not from the current Guild</li>
* <li>Either member or role are {@code null}</li>
* </ul>
* @throws net.dv8tion.jda.core.exceptions.InsufficientPermiss
|
请发表评论