发送消息时不调用接收到的jda消息

nx7onnlm  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(192)

我开始对jda有一个问题,它在发送消息时不响应公会中的消息。bot有权接收通道消息,但它不通过运行函数进行响应。下面是我的类和所有运行的事件:(我有两个,一个用于bot启动时,另一个用于获取消息并将它们记录到控制台。)
下面是包含bot事件的类:

import net.dv8tion.jda.api.events.ReadyEvent;
            import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
            import net.dv8tion.jda.api.hooks.ListenerAdapter;
            import org.jetbrains.annotations.NotNull;

            public class BotEventsTwo extends ListenerAdapter {
                @Override
                public void onReady(@NotNull ReadyEvent event) {
                    System.out.println("Total guild count: " + event.getGuildTotalCount());
                    super.onReady(event);
                }

                @Override
                public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
                    System.out.println("Event: " + event.getMessage().getContentDisplay());
                }
            }

对不起,我把所有东西都贴得太远了,因为某些原因,当我不贴的时候,它就坏了
这里是主类(bot和stuff的开始发生在这里):

import net.dv8tion.jda.api.JDA;
        import net.dv8tion.jda.api.JDABuilder;
        import net.dv8tion.jda.api.requests.GatewayIntent;
        import net.dv8tion.jda.api.utils.cache.CacheFlag;
        import storage.Instances;
        import storage.StorageManager;

        import java.util.EnumSet;

        public class Starter {

            public static void main(String[] args) throws Exception {
                try {
                    JDA jda = JDABuilder.createDefault("token here", GatewayIntent.GUILD_VOICE_STATES)
                            .enableCache(EnumSet.of(
                                    CacheFlag.VOICE_STATE
                            ))
                            .addEventListeners(
                                    new BotEvents(),
                                    new BotEventsTwo()
                            )
                            .build();
                    jda.awaitReady();
                    new StorageManager();
                    Instances.bot = jda;
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题