- Reworked embed builder

- Use IEmbedBuilderService to create embed builders
- Wrapped embed builder and using IEmbedBuilder
This commit is contained in:
Kwoth
2021-07-09 22:23:19 +02:00
parent 5b4daa9dd3
commit 5e4754fa40
103 changed files with 730 additions and 540 deletions

View File

@@ -135,7 +135,7 @@ namespace NadekoBot.Modules.Xp
await ctx.SendPaginatedConfirmAsync(0, (page) =>
{
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithOkColor()
.WithTitle($"{club.ToString()}")
.WithDescription(GetText("level_x", lvl.Level) + $" ({club.Xp} xp)")
@@ -187,7 +187,7 @@ namespace NadekoBot.Modules.Xp
.Take(10)
.Select(x => x.ToString()));
return new EmbedBuilder()
return _eb.Create()
.WithTitle(GetText("club_bans_for", club.ToString()))
.WithDescription(toShow)
.WithOkColor();
@@ -218,7 +218,7 @@ namespace NadekoBot.Modules.Xp
.Take(10)
.Select(x => x.ToString()));
return new EmbedBuilder()
return _eb.Create()
.WithTitle(GetText("club_apps_for", club.ToString()))
.WithDescription(toShow)
.WithOkColor();
@@ -373,7 +373,7 @@ namespace NadekoBot.Modules.Xp
var clubs = _service.GetClubLeaderboardPage(page);
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithTitle(GetText("club_leaderboard", page + 1))
.WithOkColor();

View File

@@ -22,7 +22,7 @@ namespace NadekoBot.Modules.Xp
[UserPerm(GuildPerm.Administrator)]
public async Task XpReset(ulong userId)
{
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithTitle(GetText("reset"))
.WithDescription(GetText("reset_user_confirm"));
@@ -39,7 +39,7 @@ namespace NadekoBot.Modules.Xp
[UserPerm(GuildPerm.Administrator)]
public async Task XpReset()
{
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithTitle(GetText("reset"))
.WithDescription(GetText("reset_server_confirm"));

View File

@@ -49,6 +49,7 @@ namespace NadekoBot.Modules.Xp.Services
private readonly IHttpClientFactory _httpFactory;
private readonly XpConfigService _xpConfig;
private readonly IPubSub _pubSub;
private readonly IEmbedBuilderService _eb;
public const int XP_REQUIRED_LVL_1 = 36;
@@ -77,7 +78,8 @@ namespace NadekoBot.Modules.Xp.Services
ICurrencyService cs,
IHttpClientFactory http,
XpConfigService xpConfig,
IPubSub pubSub)
IPubSub pubSub,
IEmbedBuilderService eb)
{
_db = db;
_cmd = cmd;
@@ -90,6 +92,7 @@ namespace NadekoBot.Modules.Xp.Services
_httpFactory = http;
_xpConfig = xpConfig;
_pubSub = pubSub;
_eb = eb;
_excludedServers = new ConcurrentHashSet<ulong>();
_excludedChannels = new ConcurrentDictionary<ulong, ConcurrentHashSet<ulong>>();
_client = client;
@@ -261,14 +264,14 @@ namespace NadekoBot.Modules.Xp.Services
{
var chan = await x.User.GetOrCreateDMChannelAsync();
if (chan != null)
await chan.SendConfirmAsync(_strings.GetText("level_up_dm",
await chan.SendConfirmAsync(_eb, _strings.GetText("level_up_dm",
x.Guild.Id,
x.User.Mention, Format.Bold(x.Level.ToString()),
Format.Bold(x.Guild.ToString() ?? "-")));
}
else if (x.MessageChannel != null) // channel
{
await x.MessageChannel.SendConfirmAsync(_strings.GetText("level_up_channel",
await x.MessageChannel.SendConfirmAsync(_eb, _strings.GetText("level_up_channel",
x.Guild.Id,
x.User.Mention, Format.Bold(x.Level.ToString())));
}
@@ -285,7 +288,7 @@ namespace NadekoBot.Modules.Xp.Services
chan = x.MessageChannel;
}
await chan.SendConfirmAsync(_strings.GetText("level_up_global",
await chan.SendConfirmAsync(_eb, _strings.GetText("level_up_global",
x.Guild.Id,
x.User.Mention, Format.Bold(x.Level.ToString())));
}

View File

@@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Xp
[NadekoCommand, Aliases]
public async Task XpRewsReset()
{
var reply = await PromptUserConfirmAsync(new EmbedBuilder()
var reply = await PromptUserConfirmAsync(_eb.Create()
.WithPendingColor()
.WithDescription(GetText("xprewsreset_confirm")));
@@ -91,7 +91,7 @@ namespace NadekoBot.Modules.Xp
return Context.SendPaginatedConfirmAsync(page, cur =>
{
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithTitle(GetText("level_up_rewards"))
.WithOkColor();
@@ -200,7 +200,7 @@ namespace NadekoBot.Modules.Xp
var globalSetting = _service.GetNotificationType(ctx.User);
var serverSetting = _service.GetNotificationType(ctx.User.Id, ctx.Guild.Id);
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithOkColor()
.AddField(GetText("xpn_setting_global"), GetNotifLocationString(globalSetting))
.AddField(GetText("xpn_setting_server"), GetNotifLocationString(serverSetting));
@@ -288,7 +288,7 @@ namespace NadekoBot.Modules.Xp
var lines = desc.Split('\n');
await ctx.SendPaginatedConfirmAsync(0, curpage =>
{
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithTitle(GetText("exclusion_list"))
.WithDescription(string.Join('\n', lines.Skip(15 * curpage).Take(15)))
.WithOkColor();
@@ -331,7 +331,7 @@ namespace NadekoBot.Modules.Xp
await ctx.SendPaginatedConfirmAsync(page, (curPage) =>
{
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithTitle(GetText("server_leaderboard"))
.WithOkColor();
@@ -379,7 +379,7 @@ namespace NadekoBot.Modules.Xp
return;
var users = _service.GetUserXps(page);
var embed = new EmbedBuilder()
var embed = _eb.Create()
.WithTitle(GetText("global_leaderboard"))
.WithOkColor();