Skip to content

v0.6.0-rc.0

Compare
Choose a tag to compare
@arqunis arqunis released this 06 May 17:28
· 148 commits to v0.6.x since this release

Thanks to the following for their contributions:

Release candidate

This is a testing release for receiving feedback regarding the new big changes introduced, whether they’re satisfactory, or horrid and should be revised, before we officially stabilise them.

Please inform us of any suggestions, or bugs you might have!

Major breaking changes

Serenity has migrated to the 2018 Rust edition, whose lints and idioms are enforced in its codebase.

The cache and http are no longer globally accessible. The Context now carries instances to them, and as such, all functions that had used the cache and http before, now accept the context as their first parameter in order to operate. Passing the fields present on the context is acceptable too.

The framework had been swayed off of builders, and proselytised to procedural, macro-based attributes.
Giving options to your commands might have looked like this:

command!(foo(ctx, msg, args) {
    ...
});

framework.command("foo", |c| 
   c.description("I am foobar")
       .min_args(1)
       .max_args(2)
       .usage("#foo bar baz")
       .cmd(foo));

But now, it will be:

#[command] // Marks this function as a command.
#[description = "I am foobar"] // These are the "parameter" attributes, for providing the options to the attribute macro.
#[min_args(1)]
#[max_args(2)]
#[usage("#foo bar baz")]
fn foo(ctx: &mut Context, msg: &Message, args: Args) -> CommandResult {
    ...

    Ok(())
}

The same happened to creating groups, but with macro! style flavour, which have become a compulsory step in registering your commands:

group!({
    name: "fizzbuzz",
    options: {
        prefix: "fezz",
        ...
    },
    commands: [foo],
});

All .commands and .ons are thus replaced with simple calls to .group:

framework.group(&FIZZBUZZ_GROUP); // !

! - procedural macros are functions that accept Rust code, return Rust code. The Rust code that the #[command] (and similarly, group!) macro generates is the function you supplied it with, and a static instance of options that you've configured the command with. The static is assigned a suffixed, all uppercase version of the function’s name (or in the case of group!, of the name field). Hence this weird identifier from nowhere.

Book

To help new (and existing) users familiarise themselves with the library better, we have decided to write a book similar to one of Rust's official learning material to the language, The Book.

It's no ready yet, but we hope that on its release that it will clear misunderstandings (if any), explain the why and how of the library and put you in the right direction of Discord bot making!

Added

Changed

Fixed

Removed