mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-11-04 08:34:27 -05:00
add: Added dropdown menu for .cmds help and group help (part of cmds). Group help will no longer be on .h
fix: paginated response replies will no longer ping the author
This commit is contained in:
@@ -6,10 +6,10 @@ public sealed class NadekoButtonInteraction : NadekoInteraction
|
||||
DiscordSocketClient client,
|
||||
ulong authorId,
|
||||
ButtonBuilder button,
|
||||
Func<SocketMessageComponent, Task> onClick,
|
||||
Func<SocketMessageComponent, Task> onAction,
|
||||
bool onlyAuthor,
|
||||
bool singleUse = true)
|
||||
: base(client, authorId, button.CustomId, onClick, onlyAuthor, singleUse)
|
||||
: base(client, authorId, button.CustomId, onAction, onlyAuthor, singleUse)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ public sealed class NadekoSelectInteraction : NadekoInteraction
|
||||
DiscordSocketClient client,
|
||||
ulong authorId,
|
||||
SelectMenuBuilder menu,
|
||||
Func<SocketMessageComponent, Task> onClick,
|
||||
Func<SocketMessageComponent, Task> onAction,
|
||||
bool onlyAuthor,
|
||||
bool singleUse = true)
|
||||
: base(client, authorId, menu.CustomId, onClick, onlyAuthor, singleUse)
|
||||
: base(client, authorId, menu.CustomId, onAction, onlyAuthor, singleUse)
|
||||
{
|
||||
Menu = menu;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
public abstract class NadekoInteraction
|
||||
{
|
||||
private readonly ulong _authorId;
|
||||
private readonly Func<SocketMessageComponent, Task> _onClick;
|
||||
private readonly Func<SocketMessageComponent, Task> _onAction;
|
||||
private readonly bool _onlyAuthor;
|
||||
public DiscordSocketClient Client { get; }
|
||||
|
||||
@@ -17,13 +17,13 @@ public abstract class NadekoInteraction
|
||||
DiscordSocketClient client,
|
||||
ulong authorId,
|
||||
string customId,
|
||||
Func<SocketMessageComponent, Task> onClick,
|
||||
Func<SocketMessageComponent, Task> onAction,
|
||||
bool onlyAuthor,
|
||||
bool singleUse = true)
|
||||
{
|
||||
_authorId = authorId;
|
||||
_customId = customId;
|
||||
_onClick = onClick;
|
||||
_onAction = onAction;
|
||||
_onlyAuthor = onlyAuthor;
|
||||
_singleUse = singleUse;
|
||||
_interactionCompletedSource = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
@@ -61,12 +61,19 @@ public abstract class NadekoInteraction
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
_interactionCompletedSource.TrySetResult(true);
|
||||
await ExecuteOnActionAsync(smc);
|
||||
|
||||
if (!smc.HasResponded)
|
||||
try
|
||||
{
|
||||
await smc.DeferAsync();
|
||||
_interactionCompletedSource.TrySetResult(true);
|
||||
await ExecuteOnActionAsync(smc);
|
||||
|
||||
if (!smc.HasResponded)
|
||||
{
|
||||
await smc.DeferAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex, "An exception occured while handling an interaction: {Message}", ex.Message);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -77,5 +84,5 @@ public abstract class NadekoInteraction
|
||||
public abstract void AddTo(ComponentBuilder cb);
|
||||
|
||||
public Task ExecuteOnActionAsync(SocketMessageComponent smc)
|
||||
=> _onClick(smc);
|
||||
=> _onAction(smc);
|
||||
}
|
||||
@@ -44,9 +44,8 @@ public partial class ResponseBuilder
|
||||
var leftButton = new ButtonBuilder()
|
||||
.WithStyle(ButtonStyle.Primary)
|
||||
.WithCustomId(BUTTON_LEFT)
|
||||
.WithDisabled(lastPage == 0)
|
||||
.WithEmote(InteractionHelpers.ArrowLeft)
|
||||
.WithDisabled(currentPage <= 0);
|
||||
.WithDisabled(lastPage == 0 || currentPage <= 0);
|
||||
|
||||
var leftBtnInter = new NadekoButtonInteraction(_client,
|
||||
model.User?.Id ?? 0,
|
||||
@@ -78,9 +77,8 @@ public partial class ResponseBuilder
|
||||
var rightButton = new ButtonBuilder()
|
||||
.WithStyle(ButtonStyle.Primary)
|
||||
.WithCustomId(BUTTON_RIGHT)
|
||||
.WithDisabled(lastPage == 0)
|
||||
.WithEmote(InteractionHelpers.ArrowRight)
|
||||
.WithDisabled(lastPage == 0 || currentPage > lastPage);
|
||||
.WithDisabled(lastPage == 0 || currentPage >= lastPage);
|
||||
|
||||
var rightBtnInter = new NadekoButtonInteraction(_client,
|
||||
model.User?.Id ?? 0,
|
||||
@@ -141,6 +139,7 @@ public partial class ResponseBuilder
|
||||
.SendMessageAsync(model.Text,
|
||||
embed: embed.Build(),
|
||||
components: cb.Build(),
|
||||
allowedMentions: model.SanitizeMentions,
|
||||
messageReference: model.MessageReference);
|
||||
|
||||
if (lastPage == 0 && _paginationBuilder.InteractionFunc is null)
|
||||
|
||||
Reference in New Issue
Block a user