Skip to content

Commit

Permalink
attempt to defer async to avoid interactions timing out
Browse files Browse the repository at this point in the history
  • Loading branch information
loukylor committed Nov 8, 2024
1 parent f1deb15 commit a1b65b6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions TrickfireCheckIn/Discord/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ public static Task CheckInOut(SlashCommandContext context)
return CheckInOutInternal(context.Interaction);
}

internal static Task CheckInOutInternal(DiscordInteraction interaction)
internal static async Task CheckInOutInternal(DiscordInteraction interaction)
{
await interaction.DeferAsync(true);

// Member is not since this command cannot be called outside of
// guilds
DiscordMember member = (interaction.User as DiscordMember)!;
Expand All @@ -103,7 +105,7 @@ internal static Task CheckInOutInternal(DiscordInteraction interaction)
}

// Send confirmation response
DiscordInteractionResponseBuilder builder = new() { IsEphemeral = true };
DiscordFollowupMessageBuilder builder = new() { IsEphemeral = true };
if (memberIndex == -1)
{
builder.WithContent("Checked in. " + GetCheckInMessage());
Expand All @@ -112,10 +114,7 @@ internal static Task CheckInOutInternal(DiscordInteraction interaction)
{
builder.WithContent($"Checked out. " + GetCheckOutMessage());
}
return interaction.CreateResponseAsync(
DiscordInteractionResponseType.ChannelMessageWithSource,
builder
);
await interaction.CreateFollowupMessageAsync(builder);
}

// Make a fake weighted random using range checking
Expand Down

0 comments on commit a1b65b6

Please sign in to comment.