Skip to content

Commit

Permalink
fix: pagination issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Sep 19, 2023
1 parent f60dc77 commit 97d6687
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public class PaginationButtons
this.SkipRight
};

public const string SKIP_LEFT_CUSTOM_ID = "pgb-skip-left";
public const string LEFT_CUSTOM_ID = "pgb-left";
public const string STOP_CUSTOM_ID = "pgb-stop";
public const string RIGHT_CUSTOM_ID = "pgb-right";
public const string SKIP_RIGHT_CUSTOM_ID = "pgb-skip-right";

/// <summary>
/// Initializes a new instance of the <see cref="PaginationButtons"/> class.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion DisCatSharp.Interactivity/Extensions/ChannelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static Task SendPaginatedMessageAsync(this DiscordChannel channel, Discor
/// <summary>
/// Retrieves an interactivity instance from a channel instance.
/// </summary>
private static InteractivityExtension GetInteractivity(DiscordChannel channel)
internal static InteractivityExtension GetInteractivity(DiscordChannel channel)
{
var client = (DiscordClient)channel.Discord;
var interactivity = client.GetInteractivity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static class InteractionExtensions
/// <param name="deletion">Deletion behaviour</param>
/// <param name="token">A custom cancellation token that can be cancelled at any point.</param>
public static Task SendPaginatedResponseAsync(this DiscordInteraction interaction, bool deferred, bool ephemeral, DiscordUser user, IEnumerable<Page> pages, PaginationButtons buttons = null, PaginationBehaviour? behaviour = default, ButtonPaginationBehavior? deletion = default, CancellationToken token = default)
=> MessageExtensions.GetInteractivity(interaction.Message).SendPaginatedResponseAsync(interaction, deferred, ephemeral, user, pages, buttons, behaviour, deletion, token);
=> (interaction.Discord as DiscordClient)?.GetInteractivity()?.SendPaginatedResponseAsync(interaction, deferred, ephemeral, user, pages, buttons, behaviour, deletion, token);

/// <summary>
/// Sends multiple modals to the user with a prompt to open the next one.
Expand Down
11 changes: 10 additions & 1 deletion DisCatSharp.Interactivity/InteractivityExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public async Task<InteractivityResult<ComponentInteractionCreateEventArgs>> Wait
/// <param name="timeoutOverride">Override the timeout period specified in <see cref="InteractivityConfiguration"/>.</param>
/// <returns>A <see cref="InteractivityResult{T}"/> with the result of the modal.</returns>
public Task<InteractivityResult<ComponentInteractionCreateEventArgs>> WaitForModalAsync(string customId, TimeSpan? timeoutOverride = null)
=> this.WaitForModalAsync(customId, this.GetCancellationToken(timeoutOverride));
=> this.WaitForModalAsync(customId, this.GetCancellationToken(timeoutOverride));

/// <summary>
/// Waits for a user modal submit.
Expand Down Expand Up @@ -785,6 +785,15 @@ public async Task SendPaginatedResponseAsync(DiscordInteraction interaction, boo
bts.Left.Disable();
}

if (pages.Count() == 1)
{
bts.SkipRight.Disable();
bts.Left.Disable();
bts.Stop.Disable();
bts.Right.Disable();
bts.SkipRight.Disable();
}

DiscordMessage message;

if (deferred)
Expand Down

0 comments on commit 97d6687

Please sign in to comment.