Module rewrites, optimizations, bugfixes, & more
This is a very large release with a number of rewritten components. The cache
has been rewritten to make use of memory more efficiently, the models directory
has been re-organized, structures are now deserialized via serde and
serde_derive - instead of the custom decoding build script we had - with a
number of bugfixes and other various changes and additions.
Thanks to the following for their contributions this release:
- @acdenisSK
- @Flat
- @fwrs
- @hsiW
- @Roughsketch
- @sschroe
Upgrade Path
Replace uses of ext::cache::ChannelRef with model::Channel.
The following ext::cache::Cache method signatures are now encased in
Arc<RwLock>s and should be handled appropriately:
callchannelguildguild_channelgroupmemberroleuser
Additionally, GuildId::find and UserId::find now return
Option<Arc<RwLock>>s.
Member::display_name now returns a Cow<String> instead of a &str.
client::Context has had most of its methods removed. The methods were mostly
a copy of those on ChannelId. Upgrade by instead calling methods on
ChannelId:
command!(foo(ctx) {
let _ = ctx.say("hello");
});
// is now written as:
command!(bar(_ctx, msg) {
let _ = msg.channel_id.say("hello");
});CreateMessage::nonce has been removed. Instead, simply do not provide a nonce.
ChannelId::edit_message now has an argument signature of:
&self, message_id: M, f: F
where F: FnOnce(CreateMessage) -> CreateMessage, M: Into<MessageId>instead of
&self, message_id: M, text: &str, f: F
where F: FnOnce(CreateEmbed) -> CreateEmbed, M: Into<MessageId>To account for this change, modify code like so:
channel_id.edit_message(message_id, "new content", |e| e);
// now:
channel_id.edit_message(message_id, |m| m.content("new content"));Message::edit has also had an argument signature updated to:
&mut self, f: F where F: FnOnce(CreateMessage) -> CreateMessagefrom:
&mut self, new_content: &str, embed: F where F: FnOnce(CreateEmbed) -> CreateEmbedTo account for this change, modify code like so:
message.edit("new content", |e| e.description("test"));
// now:
message.edit(|m| m.content("new content").embed(|e| e.description("test")));client::rest::accept_invite, Invite::accept, and RichInvite::accept have
been removed. Instead, do not attempt this, as they were userbot functions.
Selfbot support has been completely removed. Review the
commit message for the long list of details.
Group calls and guild sync have also been removed. Read the commit
message for all the details.
Instead of defining multiple separate error messages for command framework
message dispatches, match the dispatch error in a single method:
// old code:
client.with_framework(|f| f
.configure(|c| c
.command_disabled_message("The command `%command%` was disabled")
.blocked_guild_message("The owner of this guild has been blocked")
.invalid_permission_message("You don't have permission to use this command")));
// new code:
client.with_framework(|f| f.on_dispatch_error(|_, msg, err| {
match err {
DispatchError::CommandDisabled(command_name) => {
let _ = msg.channel_id.say(&format!("The command `{}` was disabled", command_name));
},
DispatchError::BlockedGuild => {
// this change also allows for more intelligent error messages:
if let Some(guild) = msg.guild() {
let owner_id = guild.read().unwrap().owner_id;
if let Some(user) = CACHE.read().unwrap().user(owner_id) {
let c = format!("The owner - {} - has been blocked", user.name);
let _ = msg.channel_id.say(&c);
return;
}
}
let _ = msg.channel_id.say("The owner of this guild has been blocked");
},
DispatchError::LackOfPermissions(_) => {
let _ = msg.channel_id.say("You don't have permission to use this command");
},
}
}));All functions prefixed with get_ have had the prefix removed. For example,
Guild::get_webhooks() is now Guild::webhooks().
Instead of using model::permissions::general(), model::permissions::text(),
and model::permissions::voice(), use
model::permissions::{PRESET_GENERAL, PRESET_TEXT, PRESET_VOICE}.
Added
- Add
saymethod toGroup,GuildChannel,PrivateChannelc:a0bb306 - Add missing
send_file/send_messageimpls c:bad9ac3 - Add
Message::guildc:9ef5522 - Add Shard Id helpers c:1561f9e
- Implement
From<&str> for ReactionTypec:e7110ad - Check for embed lengths on message sends c:e1079e9
- Add
is_nsfwcheck to channels c:9268f9c - Add missing
Member::kickhelper c:83b1d96 - Derive
Eq,Hash,PartialEqonReactionTypec:86a4e00 (@acdenisSK)
Fixed
- Handle unsuccessful responses before decoding c:7e254c5
- Uniquely ratelimit message deletions c:01f6872
- Fix Member methods due to variant
joined_atvalues c:cd914f5 - Fix deadlock on channel create event for DMs c:6b0b9b2 (@sschroe)
- Default to using
[0, 1]shards c:f0d1157 - Fix ratelimiting for
Route::Noneroutes c:5bf6c2d - Fix guild leaving result c:ae352ea
- Fix permissions when sending to DMs or groups c:404a089 (@acdenisSK)
- Check if message starts with
dynamic_prefixresult c:9ec05e7 (@Roughsketch) - Trim content before parsing framework args c:e6712c9 (@Roughsketch)
Changed
- Optimize caching c:0c9ec37
- Remove most
Contextmethods c:585af23 - Remove sending message nonces c:9c04a19
- Standardize message editing methods c:3c7c575
- Remove invite accepting c:e4b484f
- Remove selfbot support c:d9118c0 c:c74cc15
- Switch to using serde for deserialization c:f6b27eb
- Update the ways errors are handled in dispatch c:31aae7d (@fwrs)
- Deprecate methods prefixed with
get_c:3f03f9a - Framework help commands now accept a slice of args c:ff4437a
- Make
User.discriminatorau16c:0f41ffc - Use constants for preset permissions c:70d4e75