discord-jda / JDA

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

FlatMapRestAction not checking the condition predicate when using RestAction#submit() #2635

Closed Whizyyy closed 5 months ago

Whizyyy commented 5 months ago

General Troubleshooting

Version of JDA

5.0.0-beta.21

Expected Behaviour

JDA should verify the predicate and perform the function only if the predicate is verified.

The issue seems to happens when you are using RestAction#submit() but is working fine with RestAction#queue()

Code Example for Reproduction Steps

// The message here will not get deleted as the predicate always return false - This is expected.
channel.sendMessage("Hello World Queue!").flatMap(m -> false, Message::delete).queue();

// The message here will get deleted even if the predicate always return false - This is unexpected.
channel.sendMessage("Hello World Submit!").flatMap(m -> false, Message::delete).submit();

Code for JDABuilder or DefaultShardManagerBuilder used

DefaultShardManagerBuilder...

        builder.enableIntents(GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_MESSAGE_REACTIONS, GatewayIntent.MESSAGE_CONTENT, GatewayIntent.GUILD_VOICE_STATES);

        builder.setBulkDeleteSplittingEnabled(false);
        builder.disableCache(EnumSet.allOf(CacheFlag.class));
        builder.enableCache(CacheFlag.VOICE_STATE);
        builder.setMemberCachePolicy(MemberCachePolicy.DEFAULT);
        builder.setChunkingFilter(ChunkingFilter.NONE);
        builder.setLargeThreshold(250);

        builder.setActivity(Activity.listening("/help to start!"));

Exception or Error

N/A
MinnDevelopment commented 5 months ago

Fixed in 5.0.0-beta.22