part 3 of the response rework

This commit is contained in:
Kwoth
2024-04-29 21:03:40 +00:00
parent d28c7b500d
commit daa2177559
65 changed files with 508 additions and 625 deletions

View File

@@ -13,7 +13,7 @@ public sealed class CurrencyRewardService : INService, IDisposable
private readonly ICurrencyService _cs;
private readonly IPatronageService _ps;
private readonly DbService _db;
private readonly IEmbedBuilderService _eb;
private readonly IMessageSenderService _sender;
private readonly GamblingConfigService _config;
private readonly DiscordSocketClient _client;
@@ -21,14 +21,14 @@ public sealed class CurrencyRewardService : INService, IDisposable
ICurrencyService cs,
IPatronageService ps,
DbService db,
IEmbedBuilderService eb,
IMessageSenderService sender,
GamblingConfigService config,
DiscordSocketClient client)
{
_cs = cs;
_ps = ps;
_db = db;
_eb = eb;
_sender = sender;
_config = config;
_client = client;
@@ -175,7 +175,7 @@ public sealed class CurrencyRewardService : INService, IDisposable
.WithOkColor()
.WithDescription(message);
await user.EmbedAsync(eb);
await _sender.Response(user).Embed(eb).SendAsync();
}
catch
{

View File

@@ -31,10 +31,12 @@ public partial class Patronage : NadekoModule
_ = ctx.Channel.TriggerTypingAsync();
var result = await _service.SendMessageToPatronsAsync(tierAndHigher, message);
await Response().Confirm(strs.patron_msg_sent(
Format.Code(tierAndHigher.ToString()),
Format.Bold(result.Success.ToString()),
Format.Bold(result.Failed.ToString()))).SendAsync();
await Response()
.Confirm(strs.patron_msg_sent(
Format.Code(tierAndHigher.ToString()),
Format.Bold(result.Success.ToString()),
Format.Bold(result.Failed.ToString())))
.SendAsync();
}
// [OwnerOnly]
@@ -69,9 +71,9 @@ public partial class Patronage : NadekoModule
var quotaStats = await _service.GetUserQuotaStatistic(user.Id);
var eb = new EmbedBuilder()
.WithAuthor(user)
.WithTitle(GetText(strs.patron_info))
.WithOkColor();
.WithAuthor(user)
.WithTitle(GetText(strs.patron_info))
.WithOkColor();
if (quotaStats.Commands.Count == 0
&& quotaStats.Groups.Count == 0
@@ -82,7 +84,7 @@ public partial class Patronage : NadekoModule
else
{
eb.AddField(GetText(strs.tier), Format.Bold(patron.Tier.ToFullName()), true)
.AddField(GetText(strs.pledge), $"**{patron.Amount / 100.0f:N1}$**", true);
.AddField(GetText(strs.pledge), $"**{patron.Amount / 100.0f:N1}$**", true);
if (patron.Tier != PatronTier.None)
eb.AddField(GetText(strs.expires), patron.ValidThru.AddDays(1).ToShortAndRelativeTimestampTag(), true);
@@ -114,7 +116,7 @@ public partial class Patronage : NadekoModule
try
{
await ctx.User.EmbedAsync(eb);
await Response().User(ctx.User).Embed(eb).SendAsync();
_ = ctx.OkAsync();
}
catch

View File

@@ -29,7 +29,6 @@ public sealed class PatronageService
private readonly DbService _db;
private readonly DiscordSocketClient _client;
private readonly ISubscriptionHandler _subsHandler;
private readonly IEmbedBuilderService _eb;
private static readonly TypedKey<long> _quotaKey
= new($"quota:last_hourly_reset");
@@ -43,7 +42,6 @@ public sealed class PatronageService
DbService db,
DiscordSocketClient client,
ISubscriptionHandler subsHandler,
IEmbedBuilderService eb,
IBotCache cache,
IBotCredsProvider creds,
IMessageSenderService sender)
@@ -52,10 +50,9 @@ public sealed class PatronageService
_db = db;
_client = client;
_subsHandler = subsHandler;
_eb = eb;
_sender = sender;
_cache = cache;
_creds = creds;
_sender = sender;
}
public Task OnReadyAsync()
@@ -310,12 +307,12 @@ public sealed class PatronageService
ins =>
{
var eb = new EmbedBuilder()
.WithPendingColor()
.WithTitle("Insufficient Patron Tier")
.AddField("For", $"{ins.FeatureType}: `{ins.Feature}`", true)
.AddField("Required Tier",
$"[{ins.RequiredTier.ToFullName()}](https://patreon.com/join/nadekobot)",
true);
.WithPendingColor()
.WithTitle("Insufficient Patron Tier")
.AddField("For", $"{ins.FeatureType}: `{ins.Feature}`", true)
.AddField("Required Tier",
$"[{ins.RequiredTier.ToFullName()}](https://patreon.com/join/nadekobot)",
true);
if (ctx.Guild is null || ctx.Guild?.OwnerId == ctx.User.Id)
eb.WithDescription("You don't have the sufficent Patron Tier to run this command.")
@@ -333,15 +330,15 @@ public sealed class PatronageService
.Embed(eb)
.SendAsync();
else
_ = ctx.User.EmbedAsync(eb);
_ = _sender.Response(ctx).User(ctx.User).Embed(eb).SendAsync();
return true;
},
quota =>
{
var eb = new EmbedBuilder()
.WithPendingColor()
.WithTitle("Quota Limit Reached");
.WithPendingColor()
.WithTitle("Quota Limit Reached");
if (quota.IsOwnQuota || ctx.User.Id == ownerId)
{
@@ -369,7 +366,7 @@ public sealed class PatronageService
.Embed(eb)
.SendAsync();
else
_ = ctx.User.EmbedAsync(eb);
_ = _sender.Response(ctx).User(ctx.User).Embed(eb).SendAsync();
return true;
});
@@ -782,30 +779,30 @@ public sealed class PatronageService
return;
var eb = new EmbedBuilder()
.WithOkColor()
.WithTitle("❤️ Thank you for supporting NadekoBot! ❤️")
.WithDescription(
"Your donation has been processed and you will receive the rewards shortly.\n"
+ "You can visit <https://www.patreon.com/join/nadekobot> to see rewards for your tier. 🎉")
.AddField("Tier", Format.Bold(patron.Tier.ToString()), true)
.AddField("Pledge", $"**{patron.Amount / 100.0f:N1}$**", true)
.AddField("Expires",
patron.ValidThru.AddDays(1).ToShortAndRelativeTimestampTag(),
true)
.AddField("Instructions",
"""
*- Within the next **1-2 minutes** you will have all of the benefits of the Tier you've subscribed to.*
*- You can check your benefits on <https://www.patreon.com/join/nadekobot>*
*- You can use the `.patron` command in this chat to check your current quota usage for the Patron-only commands*
*- **ALL** of the servers that you **own** will enjoy your Patron benefits.*
*- You can use any of the commands available in your tier on any server (assuming you have sufficient permissions to run those commands)*
*- Any user in any of your servers can use Patron-only commands, but they will spend **your quota**, which is why it's recommended to use Nadeko's command cooldown system (.h .cmdcd) or permission system to limit the command usage for your server members.*
*- Permission guide can be found here if you're not familiar with it: <https://nadekobot.readthedocs.io/en/latest/permissions-system/>*
""",
inline: false)
.WithFooter($"platform id: {patron.UniquePlatformUserId}");
.WithOkColor()
.WithTitle("❤️ Thank you for supporting NadekoBot! ❤️")
.WithDescription(
"Your donation has been processed and you will receive the rewards shortly.\n"
+ "You can visit <https://www.patreon.com/join/nadekobot> to see rewards for your tier. 🎉")
.AddField("Tier", Format.Bold(patron.Tier.ToString()), true)
.AddField("Pledge", $"**{patron.Amount / 100.0f:N1}$**", true)
.AddField("Expires",
patron.ValidThru.AddDays(1).ToShortAndRelativeTimestampTag(),
true)
.AddField("Instructions",
"""
*- Within the next **1-2 minutes** you will have all of the benefits of the Tier you've subscribed to.*
*- You can check your benefits on <https://www.patreon.com/join/nadekobot>*
*- You can use the `.patron` command in this chat to check your current quota usage for the Patron-only commands*
*- **ALL** of the servers that you **own** will enjoy your Patron benefits.*
*- You can use any of the commands available in your tier on any server (assuming you have sufficient permissions to run those commands)*
*- Any user in any of your servers can use Patron-only commands, but they will spend **your quota**, which is why it's recommended to use Nadeko's command cooldown system (.h .cmdcd) or permission system to limit the command usage for your server members.*
*- Permission guide can be found here if you're not familiar with it: <https://nadekobot.readthedocs.io/en/latest/permissions-system/>*
""",
inline: false)
.WithFooter($"platform id: {patron.UniquePlatformUserId}");
await user.EmbedAsync(eb);
await _sender.Response(user).Embed(eb).SendAsync();
}
catch
{
@@ -830,7 +827,7 @@ public sealed class PatronageService
try
{
var user = await _client.GetUserAsync(patron.UserId);
await user.SendAsync(text);
await _sender.Response(user).Text(text).SendAsync();
++succ;
}
catch