本文整理汇总了Java中net.dv8tion.jda.core.requests.restaction.AuditableRestAction类的典型用法代码示例。如果您正苦于以下问题:Java AuditableRestAction类的具体用法?Java AuditableRestAction怎么用?Java AuditableRestAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuditableRestAction类属于net.dv8tion.jda.core.requests.restaction包,在下文中一共展示了AuditableRestAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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);
}
};
}
示例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());
}
示例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);
}
示例15: delete
import net.dv8tion.jda.core.requests.restaction.AuditableRestAction; //导入依赖的package包/类
@Override
public AuditableRestAction<Void> delete() {
return null;
}