Reputation: 33
i have problem because i made smth in ButtonClickEvent and it works well but when someone click button under this button i have error "This interaction failed", i have to finish in code action with button or what can i do with this ?
Declaring button:
channel.sendFile(file,"paint.png").setEmbeds(embed.build()).setActionRow(Button.success("veryfication","VERYFI!")).queue();
And ButtonClickEvent:
public void onButtonClick(ButtonClickEvent e){
if(e.getButton() != null) {
if (e.getButton().getId().equalsIgnoreCase("veryfication")) {
final Member member = e.getMember();
if (member != null && member.getRoles() != null) {
if (!member.getRoles().contains(e.getGuild().getRoleById("920701070831939669"))) {
e.getGuild().addRoleToMember(member, e.getGuild().getRoleById("920701070831939669")).queue();
}
}
}
}
}
Image:
Upvotes: 3
Views: 2087
Reputation: 6131
Discord requires that you acknowledge the button interaction. This can be done with one of the following:
If you only want to acknowledge the button was clicked, without responding with a message or editing the message, you can simply use event.deferEdit().queue();
.
Upvotes: 3