discord-jda / JDA

Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Apache License 2.0
4.29k stars 738 forks source link

Boost Event #2570

Closed GitMilchi closed 11 months ago

GitMilchi commented 11 months ago

General Troubleshooting

Version of JDA

JDA-5.0.0-beta.13_79b1b56-withDependencies

Expected Behaviour

I used the public void onGuildMemberUpdateBoostTime(GuildMemberUpdateBoostTimeEvent event) and I thought the event is triggering at every boost but its not triggering at a 2nd boost.

Which event do I have to use for get every boost and work with the member who boosted?

Code Example for Reproduction Steps

@Override
    public void onGuildMemberUpdateBoostTime(GuildMemberUpdateBoostTimeEvent event) {
        Member member = event.getMember();
        System.out.println("Oldtime: "+event.getOldTimeBoosted());
        System.out.println("NewTime: "+event.getNewTimeBoosted());
        if(event.getOldTimeBoosted() == null) {
            EmbedBuilder embedBuilder = new EmbedBuilder();
            embedBuilder.setTitle("<a:boost:1156895777277353986> Server Boost");
            embedBuilder.setDescription(member.getAsMention() + " hat unseren Server geboost! Dankeschön. Insgesamt haben wir nun **"+event.getGuild().getBoostCount() +"** Server Boosts! <:logo_transparent:1156145056009429092>");
            embedBuilder.setFooter("Mirage Roleplay", event.getGuild().getIconUrl());
            embedBuilder.setImage("https://i.imgur.com/c3TSEtC.png");
            embedBuilder.setColor(Mirage.color);
            event.getGuild().getTextChannelById(Config.getInstance().boostchannel).sendMessageEmbeds(embedBuilder.build()).queue();
        }
    }

Code for JDABuilder or DefaultShardManagerBuilder used

public static JDA jda;

    public static Color color = new Color(55, 167, 230);

    public static void main(String[] args) throws LoginException, ClassNotFoundException, SQLException {
        //Config.getInstance().toFile("config.json");
        Config.load("config.json");
        RestAction.setDefaultTimeout(60, TimeUnit.SECONDS);
        JDABuilder jdaBuilder = JDABuilder.createDefault(Config.getInstance().bottoken);
        jdaBuilder.enableIntents(GatewayIntent.GUILD_MEMBERS, GatewayIntent.GUILD_MESSAGE_REACTIONS, GatewayIntent.DIRECT_MESSAGE_REACTIONS, GatewayIntent.DIRECT_MESSAGES, GatewayIntent.MESSAGE_CONTENT);
        jdaBuilder.setChunkingFilter(ChunkingFilter.ALL);
        jdaBuilder.setMemberCachePolicy(MemberCachePolicy.ALL);
        jdaBuilder.setStatus(OnlineStatus.ONLINE);
        jda = jdaBuilder.build();

        MySQL.connect();
        registerListener(jda);
        registerSlashCommands(jda);
        updateBotStatus(jda);
        checkMySQLConnection();
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
        System.out.println(format.format(date));

    }

Exception or Error

No response

RedDaedalus commented 11 months ago

As per the docs, this event only fires when a user starts or stops boosting -- subsequent boosts do not trigger it. The only other way to detect boosting is to listen for the message event and check if the [message type](https://docs.jda.wiki/net/dv8tion/jda/api/entities/Message.html#getType()) is GUILD_MEMBER_BOOST.