Fix /st?
At this point, IDFK. I changed nothing and the permissions are correct now.
This commit is contained in:
4
.envrc
4
.envrc
@@ -1,4 +1,4 @@
|
|||||||
use flake
|
use flake
|
||||||
|
|
||||||
export DISCORD_TOKEN_FILE=./token
|
export DISCORD_TOKEN_FILE=./token-prod
|
||||||
export DB_FILE=db.sqlite
|
export DB_FILE=db-prod.sqlite
|
||||||
|
|||||||
35
src/main.rs
35
src/main.rs
@@ -1,4 +1,4 @@
|
|||||||
use std::{future::Future, io, path::Path};
|
use std::{io, path::Path};
|
||||||
|
|
||||||
use ::serenity::all::{ChannelId, GuildId, Mentionable, UserId};
|
use ::serenity::all::{ChannelId, GuildId, Mentionable, UserId};
|
||||||
use eyre::{Context as _, Error, OptionExt, Result};
|
use eyre::{Context as _, Error, OptionExt, Result};
|
||||||
@@ -107,19 +107,21 @@ async fn channel_children(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
fn move_users<'a>(
|
async fn move_users<'a>(
|
||||||
ctx: Context<'a>,
|
ctx: Context<'a>,
|
||||||
guild: GuildId,
|
guild: GuildId,
|
||||||
users: Vec<(ChannelId, UserId)>,
|
users: Vec<(ChannelId, UserId)>,
|
||||||
) -> impl Future<Output = Result<()>> + Send + 'a {
|
) -> Result<()> {
|
||||||
futures::stream::iter(users.into_iter().map(move |(channel, user)| async move {
|
futures::stream::iter(users.into_iter())
|
||||||
tracing::info!(?channel, ?user, "Moving user");
|
.map(Ok::<_, eyre::Error>)
|
||||||
guild.move_member(ctx, user, channel).await?;
|
.try_for_each_concurrent(10, move |(channel, user)| async move {
|
||||||
tracing::info!(?channel, ?user, "Moved user");
|
tracing::info!(?channel, ?user, "Moving user");
|
||||||
Ok(())
|
guild.move_member(ctx, user, channel).await?;
|
||||||
}))
|
tracing::info!(?channel, ?user, "Moved user");
|
||||||
.buffer_unordered(10)
|
Ok(())
|
||||||
.try_collect::<()>()
|
})
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument]
|
#[tracing::instrument]
|
||||||
@@ -321,7 +323,9 @@ async fn currently_playing(ctx: Context<'_>, player: Option<serenity::UserId>) -
|
|||||||
let guild = ctx
|
let guild = ctx
|
||||||
.guild_id()
|
.guild_id()
|
||||||
.ok_or_eyre("This bot only works in servers")?;
|
.ok_or_eyre("This bot only works in servers")?;
|
||||||
let GuildData { currently_playing, .. } = ctx.data().get(guild).await?;
|
let GuildData {
|
||||||
|
currently_playing, ..
|
||||||
|
} = ctx.data().get(guild).await?;
|
||||||
|
|
||||||
let member = guild
|
let member = guild
|
||||||
.member(&ctx, player.unwrap_or(ctx.author().id))
|
.member(&ctx, player.unwrap_or(ctx.author().id))
|
||||||
@@ -336,7 +340,12 @@ async fn currently_playing(ctx: Context<'_>, player: Option<serenity::UserId>) -
|
|||||||
};
|
};
|
||||||
|
|
||||||
ctx.reply(if player.is_some() {
|
ctx.reply(if player.is_some() {
|
||||||
format!("{} is {} {}", member.mention(), msg, currently_playing.mention())
|
format!(
|
||||||
|
"{} is {} {}",
|
||||||
|
member.mention(),
|
||||||
|
msg,
|
||||||
|
currently_playing.mention()
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
format!("You are {} {}", msg, currently_playing.mention())
|
format!("You are {} {}", msg, currently_playing.mention())
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user