mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-20 17:28:54 +00:00
Remove limits for mods on voting and community buckets
This commit is contained in:
parent
9e83501259
commit
5a702b16cb
2 changed files with 19 additions and 3 deletions
|
@ -18,6 +18,7 @@ use youmubot_prelude::{Duration as ParseDuration, *};
|
|||
#[bucket = "voting"]
|
||||
#[only_in(guilds)]
|
||||
#[min_args(2)]
|
||||
#[owner_privilege]
|
||||
pub fn vote(ctx: &mut Context, msg: &Message, mut args: Args) -> CommandResult {
|
||||
// Parse stuff first
|
||||
let args = args.quoted();
|
||||
|
|
|
@ -3,8 +3,10 @@ use dotenv::var;
|
|||
use serenity::{
|
||||
framework::standard::{DispatchError, StandardFramework},
|
||||
model::{
|
||||
channel::{Message, Reaction},
|
||||
channel::{Channel, Message, Reaction},
|
||||
gateway,
|
||||
id::{ChannelId, GuildId, UserId},
|
||||
permissions::Permissions,
|
||||
},
|
||||
};
|
||||
use youmubot_prelude::*;
|
||||
|
@ -41,6 +43,19 @@ impl EventHandler for Handler {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns whether the user has "MANAGE_MESSAGES" permission in the channel.
|
||||
fn is_channel_mod(ctx: &mut Context, _: Option<GuildId>, ch: ChannelId, u: UserId) -> bool {
|
||||
match ch.to_channel(&ctx) {
|
||||
Ok(Channel::Guild(gc)) => {
|
||||
let gc = gc.read();
|
||||
gc.permissions_for_user(&ctx, u)
|
||||
.map(|perms| perms.contains(Permissions::MANAGE_MESSAGES))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Setup dotenv
|
||||
if let Ok(path) = dotenv::dotenv() {
|
||||
|
@ -167,11 +182,11 @@ fn setup_framework(client: &Client) -> StandardFramework {
|
|||
// println!("Message is not a command '{}'", message.content);
|
||||
})
|
||||
.bucket("voting", |c| {
|
||||
c.delay(120 /* 2 minutes */).time_span(120).limit(1)
|
||||
c.check(|ctx, g, ch, u| !is_channel_mod(ctx, g, ch, u)).delay(120 /* 2 minutes */).time_span(120).limit(1)
|
||||
})
|
||||
.bucket("images", |c| c.time_span(60).limit(2))
|
||||
.bucket("community", |c| {
|
||||
c.delay(30).time_span(30).limit(1)
|
||||
c.check(|ctx, g, ch, u| !is_channel_mod(ctx, g, ch, u)).delay(30).time_span(30).limit(1)
|
||||
})
|
||||
.group(&prelude_commands::PRELUDE_GROUP);
|
||||
// groups here
|
||||
|
|
Loading…
Add table
Reference in a new issue