我正在开发一个不和谐机器人,但是我遇到了一些我从未遇到过的问题。我的discord机器人无法发送消息。bot不包含任何不推荐使用的方法。代码如下:
主要内容:
private Main() throws LoginException {
final JDA jda = JDABuilder.createDefault("My.Token.Here", GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_EMOJIS, GatewayIntent.GUILD_VOICE_STATES).build();
CommandClientBuilder builder = new CommandClientBuilder();
builder.setOwnerId("778564522046128148");
builder.setActivity(Activity.watching("es bueda fixe!"));
CommandClient client = builder.build();
jda.addEventListener(client);
jda.addEventListener(new JoinLeave());
jda.addEventListener(new TestCommand());
}
public static void main(String[] args) throws LoginException{
long enable = System.currentTimeMillis();
new Main();
System.out.println("Bot enabled in: " + (System.currentTimeMillis() - enable) + "ms!");
}
testcommand(测试bot是否工作):
public class TestCommand extends ListenerAdapter {
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent e){
System.out.println("hefdfs");
if(e.getMessage().getContentRaw().equalsIgnoreCase("!test")){
e.getChannel().sendMessage("test").queue();
}
}
}
谢谢。
1条答案
按热度按时间xzlaal3s1#
您禁用了
GUILD_MESSAGES
意图。打电话的时候把它加到你的意图清单上createDefault
:读取网关意图和成员缓存