mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 16:58: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<_>>()
|
.collect::<stream::FuturesUnordered<_>>()
|
||||||
.filter_map(|member| async move {
|
.filter_map(|member| async move {
|
||||||
// Filter by role if provided
|
// Filter by role if provided
|
||||||
if let Some(role) = role {
|
match role {
|
||||||
if member
|
Some(role) if member.roles.iter().any(|r| role == *r) => Some(member),
|
||||||
.roles(&ctx)
|
None => Some(member),
|
||||||
.await
|
_ => None,
|
||||||
.map(|roles| roles.into_iter().any(|r| role == r.id))
|
|
||||||
.unwrap_or(false)
|
|
||||||
{
|
|
||||||
Some(member)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Some(member)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
.await)
|
.await)
|
||||||
} else {
|
} else {
|
||||||
panic!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let users = users?;
|
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 {
|
async fn toggle(ctx: &Context, m: &Message, mut args: Args) -> CommandResult {
|
||||||
let role = args.single_quoted::<String>()?;
|
let role = args.single_quoted::<String>()?;
|
||||||
let guild_id = m.guild_id.unwrap();
|
let guild_id = m.guild_id.unwrap();
|
||||||
let roles = guild_id.to_partial_guild(&ctx).await?.roles;
|
let guild = guild_id.to_partial_guild(&ctx).await?;
|
||||||
let role = role_from_string(&role, &roles);
|
let role = role_from_string(&role, &guild.roles);
|
||||||
match role {
|
match role {
|
||||||
None => {
|
None => {
|
||||||
m.reply(&ctx, "No such role exists").await?;
|
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?;
|
m.reply(&ctx, "This role is not self-assignable. Check the `listroles` command to see which role can be assigned.").await?;
|
||||||
}
|
}
|
||||||
Some(role) => {
|
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) {
|
if member.roles.contains(&role.id) {
|
||||||
member.remove_role(&ctx, &role).await?;
|
member.remove_role(&ctx, &role).await?;
|
||||||
m.reply(&ctx, format!("Role `{}` has been removed.", role.name))
|
m.reply(&ctx, format!("Role `{}` has been removed.", role.name))
|
||||||
|
|
|
@ -94,6 +94,8 @@ async fn main() {
|
||||||
| GatewayIntents::GUILD_BANS
|
| GatewayIntents::GUILD_BANS
|
||||||
| GatewayIntents::GUILD_MESSAGES
|
| GatewayIntents::GUILD_MESSAGES
|
||||||
| GatewayIntents::GUILD_MESSAGE_REACTIONS
|
| GatewayIntents::GUILD_MESSAGE_REACTIONS
|
||||||
|
| GatewayIntents::GUILD_PRESENCES
|
||||||
|
| GatewayIntents::GUILD_MEMBERS
|
||||||
| GatewayIntents::DIRECT_MESSAGES
|
| GatewayIntents::DIRECT_MESSAGES
|
||||||
| GatewayIntents::DIRECT_MESSAGE_REACTIONS,
|
| GatewayIntents::DIRECT_MESSAGE_REACTIONS,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue