我不认为我做错了什么,但很明显我有,错误类型>测试,什么也不会发生。 我一直在关注 this guide 并在 2018 年上传时更改内容
Main.java:
package diaduck.Playground;
import javax.security.auth.login.LoginException;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
public class Main {
public static JDA jda;
public static String prefix = ">";
public static void main(String[] args) throws LoginException {
String token = "ODU4NzA1MTA0NTY4MTg4OTQ4.YNiBcg.0000000000000000000"
JDABuilder jda = JDABuilder.createDefault(token);
jda.setStatus(OnlineStatus.DO_NOT_DISTURB);
jda.setActivity(Activity.listening("the kids scream"));
jda.addEventListeners(new Commands());
jda.build();
}
}
Commands.java
package diaduck.Playground;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
public class Commands extends ListenerAdapter {
public void onGuildMessageRecived(GuildMessageReceivedEvent event) {
String[] args = event.getMessage().getContentRaw().split("\\s+");
if (args[0].equalsIgnoreCase(Main.prefix + "test")) {
event.getChannel().sendTyping().queue();
event.getChannel().sendMessage("Ok").queue();
}
}
}
答案 0 :(得分:0)