mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
fix: Fixed pagination, for real this time, closes #435,
dev: removed some old creds migration code, incremented creds version
This commit is contained in:
@@ -31,10 +31,10 @@ public sealed class Creds : IBotCredentials
|
||||
|
||||
[Comment("""
|
||||
Pledge 5$ or more on https://patreon.com/nadekobot and connect your discord account to Patreon.
|
||||
Go to https://dashy.nadeko.bot and login with your discord account
|
||||
Go to https://dashy.nadeko.bot/me and login with your discord account
|
||||
Go to the Keys page and click "Generate New Key" and copy it here
|
||||
You and anyone else with the permission to run `.prompt` command will be able to use natural language to run bot's commands.
|
||||
For example '@Bot how's the weather in Paris' will return the current weather in Paris as if you were to run `.weather Paris` command
|
||||
For example '@Bot how's the weather in Paris' will return the current weather in Paris as if you were to run `.weather Paris` command.
|
||||
""")]
|
||||
public string NadekoAiToken { get; set; }
|
||||
|
||||
@@ -156,7 +156,7 @@ public sealed class Creds : IBotCredentials
|
||||
|
||||
public Creds()
|
||||
{
|
||||
Version = 7;
|
||||
Version = 8;
|
||||
Token = string.Empty;
|
||||
UsePrivilegedIntents = true;
|
||||
OwnerIds = new List<ulong>();
|
||||
|
@@ -6,14 +6,16 @@ public interface INadekoInteractionService
|
||||
ulong userId,
|
||||
ButtonBuilder button,
|
||||
Func<SocketMessageComponent, Task> onTrigger,
|
||||
bool singleUse = true);
|
||||
bool singleUse = true,
|
||||
bool clearAfter = true);
|
||||
|
||||
public NadekoInteractionBase Create<T>(
|
||||
ulong userId,
|
||||
ButtonBuilder button,
|
||||
Func<SocketMessageComponent, T, Task> onTrigger,
|
||||
in T state,
|
||||
bool singleUse = true);
|
||||
bool singleUse = true,
|
||||
bool clearAfter = true);
|
||||
|
||||
NadekoInteractionBase Create(
|
||||
ulong userId,
|
||||
|
@@ -8,8 +8,9 @@ public sealed class NadekoButtonInteractionHandler : NadekoInteractionBase
|
||||
ButtonBuilder button,
|
||||
Func<SocketMessageComponent, Task> onAction,
|
||||
bool onlyAuthor,
|
||||
bool singleUse = true)
|
||||
: base(client, authorId, button.CustomId, onAction, onlyAuthor, singleUse)
|
||||
bool singleUse = true,
|
||||
bool clearAfter = true)
|
||||
: base(client, authorId, button.CustomId, onAction, onlyAuthor, singleUse, clearAfter)
|
||||
{
|
||||
Button = button;
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ public abstract class NadekoInteractionBase
|
||||
private IUserMessage message = null!;
|
||||
private readonly string _customId;
|
||||
private readonly bool _singleUse;
|
||||
private readonly bool _clearAfter;
|
||||
|
||||
public NadekoInteractionBase(
|
||||
DiscordSocketClient client,
|
||||
@@ -19,13 +20,16 @@ public abstract class NadekoInteractionBase
|
||||
string customId,
|
||||
Func<SocketMessageComponent, Task> onAction,
|
||||
bool onlyAuthor,
|
||||
bool singleUse = true)
|
||||
bool singleUse = true,
|
||||
bool clearAfter = true)
|
||||
{
|
||||
_authorId = authorId;
|
||||
_customId = customId;
|
||||
_onAction = onAction;
|
||||
_onlyAuthor = onlyAuthor;
|
||||
_singleUse = singleUse;
|
||||
_clearAfter = clearAfter;
|
||||
|
||||
_interactionCompletedSource = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
Client = client;
|
||||
@@ -36,13 +40,11 @@ public abstract class NadekoInteractionBase
|
||||
message = msg;
|
||||
|
||||
Client.InteractionCreated += OnInteraction;
|
||||
if (_singleUse)
|
||||
await Task.WhenAny(Task.Delay(30_000), _interactionCompletedSource.Task);
|
||||
else
|
||||
await Task.Delay(30_000);
|
||||
await Task.WhenAny(Task.Delay(30_000), _interactionCompletedSource.Task);
|
||||
Client.InteractionCreated -= OnInteraction;
|
||||
|
||||
await msg.ModifyAsync(m => m.Components = new ComponentBuilder().Build());
|
||||
if (_clearAfter)
|
||||
await msg.ModifyAsync(m => m.Components = new ComponentBuilder().Build());
|
||||
}
|
||||
|
||||
private Task OnInteraction(SocketInteraction arg)
|
||||
@@ -59,11 +61,15 @@ public abstract class NadekoInteractionBase
|
||||
if (smc.Data.CustomId != _customId)
|
||||
return Task.CompletedTask;
|
||||
|
||||
if (_interactionCompletedSource.Task.IsCompleted)
|
||||
return Task.CompletedTask;
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
_interactionCompletedSource.TrySetResult(true);
|
||||
if (_singleUse)
|
||||
_interactionCompletedSource.TrySetResult(true);
|
||||
await ExecuteOnActionAsync(smc);
|
||||
|
||||
if (!smc.HasResponded)
|
||||
|
@@ -13,25 +13,30 @@ public class NadekoInteractionService : INadekoInteractionService, INService
|
||||
ulong userId,
|
||||
ButtonBuilder button,
|
||||
Func<SocketMessageComponent, Task> onTrigger,
|
||||
bool singleUse = true)
|
||||
bool singleUse = true,
|
||||
bool clearAfter = true)
|
||||
=> new NadekoButtonInteractionHandler(_client,
|
||||
userId,
|
||||
button,
|
||||
onTrigger,
|
||||
onlyAuthor: true,
|
||||
singleUse: singleUse);
|
||||
singleUse: singleUse,
|
||||
clearAfter: clearAfter);
|
||||
|
||||
public NadekoInteractionBase Create<T>(
|
||||
ulong userId,
|
||||
ButtonBuilder button,
|
||||
Func<SocketMessageComponent, T, Task> onTrigger,
|
||||
in T state,
|
||||
bool singleUse = true)
|
||||
bool singleUse = true,
|
||||
bool clearAfter = true
|
||||
)
|
||||
=> Create(userId,
|
||||
button,
|
||||
((Func<T, Func<SocketMessageComponent, Task>>)((data)
|
||||
=> smc => onTrigger(smc, data)))(state),
|
||||
singleUse);
|
||||
singleUse,
|
||||
clearAfter);
|
||||
|
||||
public NadekoInteractionBase Create(
|
||||
ulong userId,
|
||||
|
@@ -1,45 +0,0 @@
|
||||
#nullable disable
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public class OldCreds
|
||||
{
|
||||
public string Token { get; set; } = string.Empty;
|
||||
public ulong[] OwnerIds { get; set; } = new ulong[1];
|
||||
public string LoLApiKey { get; set; } = string.Empty;
|
||||
public string GoogleApiKey { get; set; } = string.Empty;
|
||||
public string MashapeKey { get; set; } = string.Empty;
|
||||
public string OsuApiKey { get; set; } = string.Empty;
|
||||
public string CleverbotApiKey { get; set; } = string.Empty;
|
||||
public string CarbonKey { get; set; } = string.Empty;
|
||||
public int TotalShards { get; set; } = 1;
|
||||
public string PatreonAccessToken { get; set; } = string.Empty;
|
||||
public string PatreonCampaignId { get; set; } = "334038";
|
||||
public RestartConfig RestartCommand { get; set; }
|
||||
|
||||
public string ShardRunCommand { get; set; } = string.Empty;
|
||||
public string ShardRunArguments { get; set; } = string.Empty;
|
||||
public int? ShardRunPort { get; set; }
|
||||
public string MiningProxyUrl { get; set; } = string.Empty;
|
||||
public string MiningProxyCreds { get; set; } = string.Empty;
|
||||
|
||||
public string BotListToken { get; set; } = string.Empty;
|
||||
public string TwitchClientId { get; set; } = string.Empty;
|
||||
public string VotesToken { get; set; } = string.Empty;
|
||||
public string VotesUrl { get; set; } = string.Empty;
|
||||
public string RedisOptions { get; set; } = string.Empty;
|
||||
public string LocationIqApiKey { get; set; } = string.Empty;
|
||||
public string TimezoneDbApiKey { get; set; } = string.Empty;
|
||||
public string CoinmarketcapApiKey { get; set; } = string.Empty;
|
||||
|
||||
public class RestartConfig
|
||||
{
|
||||
public string Cmd { get; set; }
|
||||
public string Args { get; set; }
|
||||
|
||||
public RestartConfig(string cmd, string args)
|
||||
{
|
||||
Cmd = cmd;
|
||||
Args = args;
|
||||
}
|
||||
}
|
||||
}
|
@@ -71,7 +71,8 @@ public partial class ResponseBuilder
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
true,
|
||||
singleUse: false);
|
||||
singleUse: false,
|
||||
clearAfter: false);
|
||||
|
||||
if (_paginationBuilder.InteractionFunc is not null)
|
||||
{
|
||||
@@ -106,7 +107,8 @@ public partial class ResponseBuilder
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
true,
|
||||
singleUse: false);
|
||||
singleUse: false,
|
||||
clearAfter: false);
|
||||
|
||||
return (leftBtnInter, maybeInter, rightBtnInter);
|
||||
}
|
||||
|
Reference in New Issue
Block a user