Fix ST command to defer, as it can be quite slow
This commit is contained in:
21
src/main.rs
21
src/main.rs
@@ -179,7 +179,11 @@ async fn dawn(ctx: Context<'_>) -> Result<()> {
|
||||
}
|
||||
|
||||
#[poise::command(slash_command, ephemeral)]
|
||||
async fn join(ctx: Context<'_>, to: serenity::UserId, user: Option<serenity::UserId>) -> Result<()> {
|
||||
async fn join(
|
||||
ctx: Context<'_>,
|
||||
to: serenity::UserId,
|
||||
user: Option<serenity::UserId>,
|
||||
) -> Result<()> {
|
||||
let guild = ctx
|
||||
.guild_id()
|
||||
.ok_or_eyre("This bot only works in servers")?;
|
||||
@@ -195,7 +199,9 @@ async fn join(ctx: Context<'_>, to: serenity::UserId, user: Option<serenity::Use
|
||||
|
||||
match channel {
|
||||
Some(channel) => {
|
||||
guild.move_member(ctx, user.unwrap_or(ctx.author().id), channel).await?;
|
||||
guild
|
||||
.move_member(ctx, user.unwrap_or(ctx.author().id), channel)
|
||||
.await?;
|
||||
ctx.reply("Joined player").await?;
|
||||
}
|
||||
None => {
|
||||
@@ -213,6 +219,8 @@ async fn st(ctx: Context<'_>, mut spectators: Vec<serenity::UserId>) -> Result<(
|
||||
let GuildData { st, .. } = ctx.data().get(guild).await?;
|
||||
spectators.push(ctx.author().id);
|
||||
|
||||
ctx.defer_ephemeral().await?;
|
||||
|
||||
guild
|
||||
.members_iter(&ctx)
|
||||
.try_for_each(|member| {
|
||||
@@ -313,7 +321,14 @@ async fn main() -> Result<()> {
|
||||
|
||||
let framework = poise::Framework::builder()
|
||||
.options(poise::FrameworkOptions {
|
||||
commands: vec![dusk(), dawn(), st(), currently_playing(), join(), configure()],
|
||||
commands: vec![
|
||||
dusk(),
|
||||
dawn(),
|
||||
st(),
|
||||
currently_playing(),
|
||||
join(),
|
||||
configure(),
|
||||
],
|
||||
event_handler: |ctx, ev, ctxf, data| on_event(ctx, ev, ctxf, data).boxed(),
|
||||
..Default::default()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user