mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Bugfix to buttons not working when there's only one item, and buy db query
This commit is contained in:
20
src/NadekoBot/Common/Interaction/SimpleInteraction.cs
Normal file
20
src/NadekoBot/Common/Interaction/SimpleInteraction.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
namespace NadekoBot;
|
||||||
|
|
||||||
|
public class SimpleInteraction<T>
|
||||||
|
{
|
||||||
|
public ButtonBuilder Button { get; }
|
||||||
|
private readonly Func<SocketMessageComponent, T, Task> _onClick;
|
||||||
|
private readonly T? _state;
|
||||||
|
|
||||||
|
public SimpleInteraction(ButtonBuilder button, Func<SocketMessageComponent, T?, Task> onClick, T? state = default)
|
||||||
|
{
|
||||||
|
Button = button;
|
||||||
|
_onClick = onClick;
|
||||||
|
_state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task TriggerAsync(SocketMessageComponent smc)
|
||||||
|
{
|
||||||
|
await _onClick(smc, _state!);
|
||||||
|
}
|
||||||
|
}
|
@@ -473,22 +473,3 @@ public partial class Xp : NadekoModule<XpService>
|
|||||||
return GetText(strs.xpn_notif_disabled);
|
return GetText(strs.xpn_notif_disabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SimpleInteraction<T>
|
|
||||||
{
|
|
||||||
public ButtonBuilder Button { get; }
|
|
||||||
private readonly Func<SocketMessageComponent, T, Task> _onClick;
|
|
||||||
private readonly T? _state;
|
|
||||||
|
|
||||||
public SimpleInteraction(ButtonBuilder button, Func<SocketMessageComponent, T?, Task> onClick, T state = default)
|
|
||||||
{
|
|
||||||
Button = button;
|
|
||||||
_onClick = onClick;
|
|
||||||
_state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task TriggerAsync(SocketMessageComponent smc)
|
|
||||||
{
|
|
||||||
await _onClick(smc, _state);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1337,7 +1337,7 @@ public class XpService : INService, IReadyExecutor, IExecNoCommand
|
|||||||
// await using var tran = await ctx.Database.BeginTransactionAsync();
|
// await using var tran = await ctx.Database.BeginTransactionAsync();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (await ctx.GetTable<XpShopOwnedItem>().AnyAsyncLinqToDB(x => x.ItemKey == key && x.ItemType == type))
|
if (await ctx.GetTable<XpShopOwnedItem>().AnyAsyncLinqToDB(x => x.UserId == userId && x.ItemKey == key && x.ItemType == type))
|
||||||
return BuyResult.AlreadyOwned;
|
return BuyResult.AlreadyOwned;
|
||||||
|
|
||||||
var item = GetShopItem(type, key);
|
var item = GetShopItem(type, key);
|
||||||
|
@@ -314,7 +314,7 @@ public static class MessageChannelExtensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastPage == 0)
|
if (lastPage == 0 && interFactory is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var client = (DiscordSocketClient)ctx.Client;
|
var client = (DiscordSocketClient)ctx.Client;
|
||||||
|
Reference in New Issue
Block a user