有没有一种方法,只需拥有他的ID和他的TextChannel
ID?
我发现了这个:
Message message = TextChannel.getHistory().getMessageById(String id);
但是它只是抛出一个错误:net.dv8tion.jda.api.exceptions.ErrorResponseException: 10008: Unknown Message
答案 0 :(得分:3)
您可以使用MessageChannel#retrieveMessageById(id)
:
channel.retrieveMessageById(id).queue((message) -> {
// use the message here, its an async callback
message.addReaction(reaction).queue();
message.editMessage("bleh").queue();
System.out.println("Message Content: " + message.getContentDisplay());
}, (failure) -> {
// if the retrieve request failed this will be called (also async)
if (failure instanceof ErrorResponseException) {
ErrorResponseException ex = (ErrorResponseException) failure;
if (ex.getErrorResponse() == ErrorResponse.UNKNOWN_MESSAGE) {
// this means the message doesn't exist
channel.sendMessage("That message doesn't exist !").queue();
}
}
failure.printStackTrace();
});
也值得一看: