mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-18 16:28:55 +00:00
Fix intents and so core/choose and core/role
This commit is contained in:
parent
2ce83a86dd
commit
e830eab3f2
3 changed files with 10 additions and 17 deletions
|
@ -67,25 +67,16 @@ pub async fn choose(ctx: &Context, m: &Message, mut args: Args) -> CommandResult
|
|||
.collect::<stream::FuturesUnordered<_>>()
|
||||
.filter_map(|member| async move {
|
||||
// Filter by role if provided
|
||||
if let Some(role) = role {
|
||||
if member
|
||||
.roles(&ctx)
|
||||
.await
|
||||
.map(|roles| roles.into_iter().any(|r| role == r.id))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
Some(member)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
Some(member)
|
||||
match role {
|
||||
Some(role) if member.roles.iter().any(|r| role == *r) => Some(member),
|
||||
None => Some(member),
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
.await)
|
||||
} else {
|
||||
panic!()
|
||||
unreachable!()
|
||||
}
|
||||
};
|
||||
let users = users?;
|
||||
|
|
|
@ -118,8 +118,8 @@ async fn list(ctx: &Context, m: &Message, _: Args) -> CommandResult {
|
|||
async fn toggle(ctx: &Context, m: &Message, mut args: Args) -> CommandResult {
|
||||
let role = args.single_quoted::<String>()?;
|
||||
let guild_id = m.guild_id.unwrap();
|
||||
let roles = guild_id.to_partial_guild(&ctx).await?.roles;
|
||||
let role = role_from_string(&role, &roles);
|
||||
let guild = guild_id.to_partial_guild(&ctx).await?;
|
||||
let role = role_from_string(&role, &guild.roles);
|
||||
match role {
|
||||
None => {
|
||||
m.reply(&ctx, "No such role exists").await?;
|
||||
|
@ -134,7 +134,7 @@ async fn toggle(ctx: &Context, m: &Message, mut args: Args) -> CommandResult {
|
|||
m.reply(&ctx, "This role is not self-assignable. Check the `listroles` command to see which role can be assigned.").await?;
|
||||
}
|
||||
Some(role) => {
|
||||
let mut member = m.member(&ctx).await.unwrap();
|
||||
let mut member = guild.member(&ctx, m.author.id).await.unwrap();
|
||||
if member.roles.contains(&role.id) {
|
||||
member.remove_role(&ctx, &role).await?;
|
||||
m.reply(&ctx, format!("Role `{}` has been removed.", role.name))
|
||||
|
|
|
@ -94,6 +94,8 @@ async fn main() {
|
|||
| GatewayIntents::GUILD_BANS
|
||||
| GatewayIntents::GUILD_MESSAGES
|
||||
| GatewayIntents::GUILD_MESSAGE_REACTIONS
|
||||
| GatewayIntents::GUILD_PRESENCES
|
||||
| GatewayIntents::GUILD_MEMBERS
|
||||
| GatewayIntents::DIRECT_MESSAGES
|
||||
| GatewayIntents::DIRECT_MESSAGE_REACTIONS,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue