Skip to content

v5.0.0-alpha.6 | Attachment Options & Breaking Cleanup

Compare
Choose a tag to compare
@DV8FromTheWorld DV8FromTheWorld released this 20 Feb 21:41
· 441 commits to master since this release
094f41a

Changelog

This release includes a variety of breaking changes that were needed to either correctly model how Discord models things in their API or to better set us up for future development.

In this version, we added a new pattern for options on commands. You can now use getOption(name[, fallback], resolver) to easily get any optional arguments for your commands:

public void onSlashCommandInteraction(SlashCommandInteractionEvent event)
{
    //                              name      fallback          resolver
    
    // null if user is not a member of the guild (fallback not used, since option is mapped to a User instance)
    Member member = event.getOption("target", event::getMember, OptionMapping::getAsMember);
    // null if fallback is used (getAsUser cannot be null)
    User user =     event.getOption("target", null            , OptionMapping::getAsUser);
    // null fallback implied
    User nullable = event.getOption("target",                   OptionMapping::getAsUser); // <- implicit fallback null

    // real use-cases:
    int days = event.getOption("days", 7, OptionMapping::getAsInt); // optional ban days
    String reason = event.getOption("reason", "banned by mod", OptionMapping::getAsString); // optional ban reason
}

You can also now flip the iteration direction for MessageChannel.getIterableHistory. A common request as of late, was to get the first messages of a channel, which can now be accomplished by doing channel.getIterableHistory().reverse().takeAsync(1000).

New Features

Changes

  • [Breaking] Change PrivateChannel#getUser to handle API nullability by @oliver276 in #2012
  • [Breaking] Make getDefaultChannel return BaseGuildMessageChannel by @MinnDevelopment in #2016
  • [Semi-Breaking] Dont override latest message id on deletion event by @ishwi in #2013
  • [Breaking] Change some voice Regions and remove VOICE_CHANNEL_REGIONS set by @caneleex in #1962
  • Fix OptionData#setAutoComplete logic. by @portlek in #2003
  • Fix max file size limit in MessageAction by @Xirado in #2017
  • Fix javadoc warnings by @Chew in #1976
  • Fix misspelled ErrorResponse enum value by @Xirado in #2031
  • Fix missing cache cleanup for news/stage/thread channels by @Mitmocc in #2029

Removed

Full Changelog: v5.0.0-alpha.5...v5.0.0-alpha.6

Installation

Gradle

repositories {
    mavenCentral()
}
dependencies {
    implementation("net.dv8tion:JDA:5.0.0-alpha.6")
}

Maven

<dependency>
    <groupId>net.dv8tion</groupId>
    <artifactId>JDA</artifactId>
    <version>5.0.0-alpha.6</version> 
</dependency>