moved the member-getter to as late as possible

This commit is contained in:
jude 2020-10-26 12:33:38 +00:00
parent 3e490bb5c4
commit 84e4952752
3 changed files with 5 additions and 4 deletions

2
Cargo.lock generated
View File

@ -1175,7 +1175,7 @@ dependencies = [
[[package]] [[package]]
name = "reminder_rs" name = "reminder_rs"
version = "1.0.2" version = "1.1.0"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"async-trait", "async-trait",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "reminder_rs" name = "reminder_rs"
version = "1.0.2" version = "1.1.0"
authors = ["jellywx <judesouthworth@pm.me>"] authors = ["jellywx <judesouthworth@pm.me>"]
edition = "2018" edition = "2018"

View File

@ -349,8 +349,6 @@ impl Framework for RegexFramework {
else if let (Some(guild), Some(Channel::Guild(channel))) = else if let (Some(guild), Some(Channel::Guild(channel))) =
(msg.guild(&ctx).await, msg.channel(&ctx).await) (msg.guild(&ctx).await, msg.channel(&ctx).await)
{ {
let member = guild.member(&ctx, &msg.author).await.unwrap();
if let Some(full_match) = self.command_matcher.captures(&msg.content) { if let Some(full_match) = self.command_matcher.captures(&msg.content) {
if check_prefix(&ctx, &guild, full_match.name("prefix")).await { if check_prefix(&ctx, &guild, full_match.name("prefix")).await {
let pool = ctx let pool = ctx
@ -370,6 +368,7 @@ impl Framework for RegexFramework {
.commands .commands
.get(&full_match.name("cmd").unwrap().as_str().to_lowercase()) .get(&full_match.name("cmd").unwrap().as_str().to_lowercase())
.unwrap(); .unwrap();
let channel_data = ChannelData::from_channel( let channel_data = ChannelData::from_channel(
msg.channel(&ctx).await.unwrap(), msg.channel(&ctx).await.unwrap(),
&pool, &pool,
@ -385,6 +384,8 @@ impl Framework for RegexFramework {
.unwrap_or("") .unwrap_or("")
.to_string(); .to_string();
let member = guild.member(&ctx, &msg.author).await.unwrap();
if command.check_permissions(&ctx, &guild, &member).await { if command.check_permissions(&ctx, &guild, &member).await {
(command.func)(&ctx, &msg, args).await; (command.func)(&ctx, &msg, args).await;
} else if command.required_perms == PermissionLevel::Restricted } else if command.required_perms == PermissionLevel::Restricted