在JDA 4中使用member.ban()时遇到麻烦;当我调用cmd时,它不会向控制台发送任何错误,
成功禁止了MB:[昵称此处](U:[用户名此处[usersidhere])/ G:[GuildNameHere] [GuildIDHere))
这是运行此代码的代码
public void onGuildMessageReceived(GuildMessageReceivedEvent event){
String[] args = event.getMessage().getContentRaw().split("\\s+");
if(args[0].equalsIgnoreCase(cogBotMain.prefix + "Ban") && event.getMember().hasPermission(Permission.BAN_MEMBERS)){
Member member = event.getGuild().getMemberById(args[1].replace("<@!", "").replace(">", ""));
if(args.length < 3){
//ERROR
EmbedBuilder errorban = new EmbedBuilder();
errorban.setTitle("Cog Bot - Syntax Error");
errorban.setDescription("Please use the proper syntax: " + cogBotMain.prefix + "ban <mentionTheUser> <NumberMessagesToDelete> <Reason>");
errorban.setColor(0xf56e6e);
errorban.setFooter("Created by A Yoshi#1662");
event.getChannel().sendMessage(errorban.build()).complete();
errorban.clear();
}else{
String Banres = args[3];
int BanTime = Integer.parseInt(args[2]);
if (member != null) {
member.ban(BanTime,Banres);
event.getChannel().sendMessage("Successfully banned " + member).complete();
}
}
}
}
答案 0 :(得分:0)
嘿,您忘记了queue()
后面的member.ban(BanTime,Banres);