mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-13 02:38:27 -04:00
- Reworked embed builder
- Use IEmbedBuilderService to create embed builders - Wrapped embed builder and using IEmbedBuilder
This commit is contained in:
@@ -21,9 +21,9 @@ namespace NadekoBot.Modules.Utility
|
||||
expr.EvaluateParameter += Expr_EvaluateParameter;
|
||||
var result = expr.Evaluate();
|
||||
if (!expr.HasErrors())
|
||||
await ctx.Channel.SendConfirmAsync("⚙ " + GetText("result"), result.ToString()).ConfigureAwait(false);
|
||||
await SendConfirmAsync("⚙ " + GetText("result"), result.ToString()).ConfigureAwait(false);
|
||||
else
|
||||
await ctx.Channel.SendErrorAsync("⚙ " + GetText("error"), expr.Error).ConfigureAwait(false);
|
||||
await SendErrorAsync("⚙ " + GetText("error"), expr.Error).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private static void Expr_EvaluateParameter(string name, NCalc.ParameterArgs args)
|
||||
@@ -55,7 +55,7 @@ namespace NadekoBot.Modules.Utility
|
||||
"GetHashCode",
|
||||
"GetType"
|
||||
});
|
||||
await ctx.Channel.SendConfirmAsync(GetText("calcops", Prefix), string.Join(", ", selection)).ConfigureAwait(false);
|
||||
await SendConfirmAsync(GetText("calcops", Prefix), string.Join(", ", selection)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -137,7 +137,7 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
await ctx.SendPaginatedConfirmAsync(page, (curPage) =>
|
||||
{
|
||||
return new EmbedBuilder().WithOkColor()
|
||||
return _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("alias_list"))
|
||||
.WithDescription(string.Join("\n",
|
||||
arr.Skip(curPage * 10).Take(10).Select(x => $"`{x.Key}` => `{x.Value}`")));
|
||||
|
@@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (setting is null)
|
||||
{
|
||||
var configNames = _settingServices.Select(x => x.Name);
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithErrorColor()
|
||||
.WithDescription(GetText("config_not_found", Format.Code(name)))
|
||||
.AddField(GetText("config_list"), string.Join("\n", configNames));
|
||||
@@ -73,7 +73,7 @@ namespace NadekoBot.Modules.Utility
|
||||
name = name?.ToLowerInvariant();
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("config_list"))
|
||||
.WithDescription(string.Join("\n", configNames));
|
||||
@@ -88,7 +88,7 @@ namespace NadekoBot.Modules.Utility
|
||||
// if config name is not found, print error and the list of configs
|
||||
if (setting is null)
|
||||
{
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithErrorColor()
|
||||
.WithDescription(GetText("config_not_found", Format.Code(name)))
|
||||
.AddField(GetText("config_list"), string.Join("\n", configNames));
|
||||
@@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (string.IsNullOrWhiteSpace(prop))
|
||||
{
|
||||
var propStrings = GetPropsAndValuesString(setting, propNames);
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle($"⚙️ {setting.Name}")
|
||||
.WithDescription(propStrings);
|
||||
@@ -121,7 +121,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (!exists)
|
||||
{
|
||||
var propStrings = GetPropsAndValuesString(setting, propNames);
|
||||
var propErrorEmbed = new EmbedBuilder()
|
||||
var propErrorEmbed = _eb.Create()
|
||||
.WithErrorColor()
|
||||
.WithDescription(GetText("config_prop_not_found", Format.Code(prop), Format.Code(name)))
|
||||
.AddField($"⚙️ {setting.Name}", propStrings);
|
||||
@@ -144,7 +144,7 @@ namespace NadekoBot.Modules.Utility
|
||||
value = Format.Code(Format.Sanitize(value?.TrimTo(1000)), "json");
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.AddField("Config", Format.Code(setting.Name), true)
|
||||
.AddField("Prop", Format.Code(prop), true)
|
||||
|
@@ -46,7 +46,7 @@ namespace NadekoBot.Modules.Utility
|
||||
var features = string.Join("\n", guild.Features);
|
||||
if (string.IsNullOrWhiteSpace(features))
|
||||
features = "-";
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithAuthor(GetText("server_info"))
|
||||
.WithTitle(guild.Name)
|
||||
.AddField(GetText("id"), guild.Id.ToString(), true)
|
||||
@@ -58,7 +58,7 @@ namespace NadekoBot.Modules.Utility
|
||||
.AddField(GetText("region"), guild.VoiceRegionId.ToString(), true)
|
||||
.AddField(GetText("roles"), (guild.Roles.Count - 1).ToString(), true)
|
||||
.AddField(GetText("features"), features, true)
|
||||
.WithColor(Bot.OkColor);
|
||||
.WithOkColor();
|
||||
if (Uri.IsWellFormedUriString(guild.IconUrl, UriKind.Absolute))
|
||||
embed.WithThumbnailUrl(guild.IconUrl);
|
||||
if (guild.Emotes.Any())
|
||||
@@ -82,13 +82,13 @@ namespace NadekoBot.Modules.Utility
|
||||
return;
|
||||
var createdAt = new DateTime(2015, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(ch.Id >> 22);
|
||||
var usercount = (await ch.GetUsersAsync().FlattenAsync().ConfigureAwait(false)).Count();
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithTitle(ch.Name)
|
||||
.WithDescription(ch.Topic?.SanitizeMentions(true))
|
||||
.AddField(GetText("id"), ch.Id.ToString(), true)
|
||||
.AddField(GetText("created_at"), $"{createdAt:dd.MM.yyyy HH:mm}", true)
|
||||
.AddField(GetText("users"), usercount.ToString(), true)
|
||||
.WithColor(Bot.OkColor);
|
||||
.WithOkColor();
|
||||
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (user is null)
|
||||
return;
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.AddField(GetText("name"), $"**{user.Username}**#{user.Discriminator}", true);
|
||||
if (!string.IsNullOrWhiteSpace(user.Nickname))
|
||||
{
|
||||
@@ -111,7 +111,7 @@ namespace NadekoBot.Modules.Utility
|
||||
.AddField(GetText("joined_server"), $"{user.JoinedAt?.ToString("dd.MM.yyyy HH:mm") ?? "?"}", true)
|
||||
.AddField(GetText("joined_discord"), $"{user.CreatedAt:dd.MM.yyyy HH:mm}", true)
|
||||
.AddField(GetText("roles"), $"**({user.RoleIds.Count - 1})** - {string.Join("\n", user.GetRoles().Take(10).Where(r => r.Id != r.Guild.EveryoneRole.Id).Select(r => r.Name)).SanitizeMentions(true)}", true)
|
||||
.WithColor(Bot.OkColor);
|
||||
.WithOkColor();
|
||||
|
||||
var av = user.RealAvatarUrl();
|
||||
if (av != null && av.IsAbsoluteUri)
|
||||
@@ -141,7 +141,7 @@ namespace NadekoBot.Modules.Utility
|
||||
kvp.Value / _stats.GetUptime().TotalSeconds, kvp.Value));
|
||||
}
|
||||
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create()
|
||||
.WithTitle(GetText("activity_page", page + 1))
|
||||
.WithOkColor()
|
||||
.WithFooter(GetText("activity_users_total", CmdHandler.UserMessagesSent.Count))
|
||||
|
@@ -29,7 +29,7 @@ namespace NadekoBot.Modules.Utility
|
||||
var ch = (ITextChannel)ctx.Channel;
|
||||
var invite = await ch.CreateInviteAsync(opts.Expire, opts.MaxUses, isTemporary: opts.Temporary, isUnique: opts.Unique).ConfigureAwait(false);
|
||||
|
||||
await ctx.Channel.SendConfirmAsync($"{ctx.User.Mention} https://discord.gg/{invite.Code}").ConfigureAwait(false);
|
||||
await SendConfirmAsync($"{ctx.User.Mention} https://discord.gg/{invite.Code}").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -54,12 +54,12 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
if (!invs.Any())
|
||||
{
|
||||
return new EmbedBuilder()
|
||||
return _eb.Create()
|
||||
.WithErrorColor()
|
||||
.WithDescription(GetText("no_invites"));
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithOkColor();
|
||||
var embed = _eb.Create().WithOkColor();
|
||||
foreach (var inv in invites)
|
||||
{
|
||||
var expiryString = (inv.MaxAge is null || inv.MaxAge == 0 || inv.CreatedAt is null)
|
||||
|
@@ -36,7 +36,7 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
var rem = (_service.Interval - (DateTime.UtcNow - _service.LastUpdate));
|
||||
var helpcmd = Format.Code(Prefix + "donate");
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
|
||||
.WithDescription(GetText("clpa_obsolete"))
|
||||
.AddField(GetText("clpa_fail_already_title"), GetText("clpa_fail_already"))
|
||||
.AddField(GetText("clpa_fail_wait_title"), GetText("clpa_fail_wait"))
|
||||
|
@@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Utility
|
||||
}
|
||||
|
||||
if (quotes.Any())
|
||||
await ctx.Channel.SendConfirmAsync(GetText("quotes_page", page + 1),
|
||||
await SendConfirmAsync(GetText("quotes_page", page + 1),
|
||||
string.Join("\n", quotes.Select(q => $"`#{q.Id}` {Format.Bold(q.Keyword.SanitizeAllMentions()),-20} by {q.AuthorName.SanitizeAllMentions()}")))
|
||||
.ConfigureAwait(false);
|
||||
else
|
||||
@@ -85,7 +85,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (CREmbed.TryParse(quote.Text, out var crembed))
|
||||
{
|
||||
rep.Replace(crembed);
|
||||
await ctx.Channel.EmbedAsync(crembed.ToEmbed(), $"`#{quote.Id}` 📣 " + crembed.PlainText?.SanitizeAllMentions() ?? "")
|
||||
await ctx.Channel.EmbedAsync(crembed.ToEmbed(_eb), $"`#{quote.Id}` 📣 " + crembed.PlainText?.SanitizeAllMentions() ?? "")
|
||||
.ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
private async Task ShowQuoteData(Quote data)
|
||||
{
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create(ctx)
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("quote_id", $"#{data.Id}"))
|
||||
.AddField(GetText("trigger"), data.Keyword)
|
||||
@@ -168,7 +168,7 @@ namespace NadekoBot.Modules.Utility
|
||||
|
||||
if (quote is null || quote.GuildId != ctx.Guild.Id)
|
||||
{
|
||||
await ctx.Channel.SendErrorAsync(GetText("quotes_notfound")).ConfigureAwait(false);
|
||||
await SendErrorAsync(GetText("quotes_notfound")).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
rep.Replace(crembed);
|
||||
|
||||
await ctx.Channel.EmbedAsync(crembed.ToEmbed(), infoText + crembed.PlainText?.SanitizeAllMentions())
|
||||
await ctx.Channel.EmbedAsync(crembed.ToEmbed(_eb), infoText + crembed.PlainText?.SanitizeAllMentions())
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
@@ -238,9 +238,9 @@ namespace NadekoBot.Modules.Utility
|
||||
}
|
||||
}
|
||||
if (success)
|
||||
await ctx.Channel.SendConfirmAsync(response).ConfigureAwait(false);
|
||||
await SendConfirmAsync(response).ConfigureAwait(false);
|
||||
else
|
||||
await ctx.Channel.SendErrorAsync(response).ConfigureAwait(false);
|
||||
await SendErrorAsync(response).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
|
@@ -8,10 +8,8 @@ using NadekoBot.Common.Attributes;
|
||||
using NadekoBot.Services;
|
||||
using NadekoBot.Services.Database.Models;
|
||||
using NadekoBot.Db;
|
||||
using NadekoBot.Db.Models;
|
||||
using NadekoBot.Extensions;
|
||||
using NadekoBot.Modules.Administration.Services;
|
||||
using NadekoBot.Modules.Utility.Common;
|
||||
using NadekoBot.Modules.Utility.Services;
|
||||
|
||||
namespace NadekoBot.Modules.Utility
|
||||
@@ -88,7 +86,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (--page < 0)
|
||||
return;
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("reminder_list"));
|
||||
|
||||
@@ -128,7 +126,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (--index < 0)
|
||||
return;
|
||||
|
||||
var embed = new EmbedBuilder();
|
||||
var embed = _eb.Create();
|
||||
|
||||
Reminder rem = null;
|
||||
using (var uow = _db.GetDbContext())
|
||||
@@ -191,7 +189,7 @@ namespace NadekoBot.Modules.Utility
|
||||
: TimeZoneInfo.ConvertTime(time, _tz.GetTimeZoneOrUtc(ctx.Guild.Id));
|
||||
try
|
||||
{
|
||||
await ctx.Channel.SendConfirmAsync(
|
||||
await SendConfirmAsync(
|
||||
"⏰ " + GetText("remind",
|
||||
Format.Bold(!isPrivate ? $"<#{targetId}>" : ctx.User.Username),
|
||||
Format.Bold(message),
|
||||
|
@@ -48,7 +48,7 @@ namespace NadekoBot.Modules.Utility
|
||||
}
|
||||
|
||||
var description = GetRepeaterInfoString(removed);
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("repeater_removed", index + 1))
|
||||
.WithDescription(description));
|
||||
@@ -144,7 +144,7 @@ namespace NadekoBot.Modules.Utility
|
||||
}
|
||||
|
||||
var description = GetRepeaterInfoString(runner);
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("repeater_created"))
|
||||
.WithDescription(description));
|
||||
@@ -162,7 +162,7 @@ namespace NadekoBot.Modules.Utility
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithTitle(GetText("list_of_repeaters"))
|
||||
.WithOkColor();
|
||||
|
||||
|
@@ -18,15 +18,17 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
{
|
||||
public class CommandMapService : IInputTransformer, INService
|
||||
{
|
||||
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
|
||||
public ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>> AliasMaps { get; } = new ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>>();
|
||||
|
||||
private readonly DbService _db;
|
||||
|
||||
//commandmap
|
||||
public CommandMapService(DiscordSocketClient client, DbService db)
|
||||
public CommandMapService(DiscordSocketClient client, DbService db, IEmbedBuilderService eb)
|
||||
{
|
||||
|
||||
_eb = eb;
|
||||
|
||||
using (var uow = db.GetDbContext())
|
||||
{
|
||||
var guildIds = client.Guilds.Select(x => x.Id).ToList();
|
||||
@@ -87,7 +89,7 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
|
||||
try
|
||||
{
|
||||
var toDelete = await channel.SendConfirmAsync($"{input} => {newInput}").ConfigureAwait(false);
|
||||
var toDelete = await channel.SendConfirmAsync(_eb, $"{input} => {newInput}").ConfigureAwait(false);
|
||||
var _ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(1500).ConfigureAwait(false);
|
||||
|
@@ -31,12 +31,13 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
private readonly ICurrencyService _currency;
|
||||
private readonly GamblingConfigService _gamblingConfigService;
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly DiscordSocketClient _client;
|
||||
|
||||
public DateTime LastUpdate { get; private set; } = DateTime.UtcNow;
|
||||
|
||||
public PatreonRewardsService(IBotCredentials creds, DbService db,
|
||||
ICurrencyService currency, IHttpClientFactory factory,
|
||||
ICurrencyService currency, IHttpClientFactory factory, IEmbedBuilderService eb,
|
||||
DiscordSocketClient client, GamblingConfigService gamblingConfigService)
|
||||
{
|
||||
_creds = creds;
|
||||
@@ -44,6 +45,7 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
_currency = currency;
|
||||
_gamblingConfigService = gamblingConfigService;
|
||||
_httpFactory = factory;
|
||||
_eb = eb;
|
||||
_client = client;
|
||||
|
||||
if (client.ShardId == 0)
|
||||
@@ -211,7 +213,7 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
return;
|
||||
|
||||
var channel = await user.GetOrCreateDMChannelAsync();
|
||||
await channel.SendConfirmAsync(message);
|
||||
await channel.SendConfirmAsync(_eb, message);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@@ -21,12 +21,14 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly DbService _db;
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
|
||||
public RemindService(DiscordSocketClient client, DbService db, IBotCredentials creds)
|
||||
public RemindService(DiscordSocketClient client, DbService db, IBotCredentials creds, IEmbedBuilderService eb)
|
||||
{
|
||||
_client = client;
|
||||
_db = db;
|
||||
_creds = creds;
|
||||
_eb = eb;
|
||||
_ = StartReminderLoop();
|
||||
}
|
||||
|
||||
@@ -167,7 +169,7 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
if (ch is null)
|
||||
return;
|
||||
|
||||
await ch.EmbedAsync(new EmbedBuilder()
|
||||
await ch.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("Reminder")
|
||||
.AddField("Created At", r.DateAdded.HasValue ? r.DateAdded.Value.ToLongDateString() : "?")
|
||||
|
@@ -26,16 +26,18 @@ namespace NadekoBot.Modules.Utility.Services
|
||||
|
||||
private readonly DbService _db;
|
||||
private readonly IBotCredentials _creds;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private LinkedList<RunningRepeater> _repeaterQueue;
|
||||
private ConcurrentHashSet<int> _noRedundant;
|
||||
|
||||
private readonly object _queueLocker = new object();
|
||||
|
||||
public RepeaterService(DiscordSocketClient client, DbService db, IBotCredentials creds)
|
||||
public RepeaterService(DiscordSocketClient client, DbService db, IBotCredentials creds, IEmbedBuilderService eb)
|
||||
{
|
||||
_db = db;
|
||||
_creds = creds;
|
||||
_eb = eb;
|
||||
_client = client;
|
||||
|
||||
var uow = _db.GetDbContext();
|
||||
@@ -261,7 +263,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
if (CREmbed.TryParse(repeater.Message, out var crEmbed))
|
||||
{
|
||||
rep.Replace(crEmbed);
|
||||
newMsg = await channel.EmbedAsync(crEmbed);
|
||||
newMsg = await channel.EmbedAsync(crEmbed, _eb);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -20,7 +20,7 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
var units = _service.Units;
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithTitle(GetText("convertlist"))
|
||||
.WithOkColor();
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace NadekoBot.Modules.Utility
|
||||
}
|
||||
res = Math.Round(res, 4);
|
||||
|
||||
await ctx.Channel.SendConfirmAsync(GetText("convert", value, originUnit.Triggers.Last(), res, targetUnit.Triggers.Last())).ConfigureAwait(false);
|
||||
await SendConfirmAsync(GetText("convert", value, originUnit.Triggers.Last(), res, targetUnit.Triggers.Last())).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -53,14 +53,14 @@ namespace NadekoBot.Modules.Utility
|
||||
if (CREmbed.TryParse(message, out var embedData))
|
||||
{
|
||||
rep.Replace(embedData);
|
||||
await channel.EmbedAsync(embedData, sanitizeAll: !((IGuildUser)Context.User).GuildPermissions.MentionEveryone).ConfigureAwait(false);
|
||||
await channel.EmbedAsync(embedData, _eb, sanitizeAll: !((IGuildUser)Context.User).GuildPermissions.MentionEveryone).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
var msg = rep.Replace(message);
|
||||
if (!string.IsNullOrWhiteSpace(msg))
|
||||
{
|
||||
await channel.SendConfirmAsync(msg).ConfigureAwait(false);
|
||||
await channel.SendConfirmAsync(_eb, msg).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace NadekoBot.Modules.Utility
|
||||
await ReplyErrorLocalizedAsync("nobody_playing_game").ConfigureAwait(false);
|
||||
else
|
||||
{
|
||||
await ctx.Channel.SendConfirmAsync("```css\n" + string.Join("\n", arr.GroupBy(item => (i++) / 2)
|
||||
await SendConfirmAsync("```css\n" + string.Join("\n", arr.GroupBy(item => (i++) / 2)
|
||||
.Select(ig => string.Concat(ig.Select(el => $"• {el,-27}")))) + "\n```")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
@@ -128,9 +128,9 @@ namespace NadekoBot.Modules.Utility
|
||||
.ToList();
|
||||
|
||||
if (pageUsers.Count == 0)
|
||||
return new EmbedBuilder().WithOkColor().WithDescription(GetText("no_user_on_this_page"));
|
||||
return _eb.Create().WithOkColor().WithDescription(GetText("no_user_on_this_page"));
|
||||
|
||||
return new EmbedBuilder().WithOkColor()
|
||||
return _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("inrole_list", Format.Bold(role?.Name ?? "No Role")) + $" - {roleUsers.Length}")
|
||||
.WithDescription(string.Join("\n", pageUsers));
|
||||
}, roleUsers.Length, 20).ConfigureAwait(false);
|
||||
@@ -157,7 +157,7 @@ namespace NadekoBot.Modules.Utility
|
||||
{
|
||||
builder.AppendLine($"{p.Name} : {p.GetValue(perms, null)}");
|
||||
}
|
||||
await ctx.Channel.SendConfirmAsync(builder.ToString()).ConfigureAwait(false);
|
||||
await SendConfirmAsync(builder.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -196,8 +196,7 @@ namespace NadekoBot.Modules.Utility
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task Roles(IGuildUser target, int page = 1)
|
||||
{
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
var guild = channel.Guild;
|
||||
var guild = ctx.Guild;
|
||||
|
||||
const int rolesPerPage = 20;
|
||||
|
||||
@@ -214,7 +213,7 @@ namespace NadekoBot.Modules.Utility
|
||||
else
|
||||
{
|
||||
|
||||
await channel.SendConfirmAsync(GetText("roles_page", page, Format.Bold(target.ToString())),
|
||||
await SendConfirmAsync(GetText("roles_page", page, Format.Bold(target.ToString())),
|
||||
"\n• " + string.Join("\n• ", (IEnumerable<IRole>)roles).SanitizeMentions(true)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -227,7 +226,7 @@ namespace NadekoBot.Modules.Utility
|
||||
}
|
||||
else
|
||||
{
|
||||
await channel.SendConfirmAsync(GetText("roles_all_page", page),
|
||||
await SendConfirmAsync(GetText("roles_all_page", page),
|
||||
"\n• " + string.Join("\n• ", (IEnumerable<IRole>)roles).SanitizeMentions(true)).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -249,7 +248,7 @@ namespace NadekoBot.Modules.Utility
|
||||
if (string.IsNullOrWhiteSpace(topic))
|
||||
await ReplyErrorLocalizedAsync("no_topic_set").ConfigureAwait(false);
|
||||
else
|
||||
await ctx.Channel.SendConfirmAsync(GetText("channel_topic"), topic).ConfigureAwait(false);
|
||||
await SendConfirmAsync(GetText("channel_topic"), topic).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
@@ -260,7 +259,7 @@ namespace NadekoBot.Modules.Utility
|
||||
ownerIds = "-";
|
||||
|
||||
await ctx.Channel.EmbedAsync(
|
||||
new EmbedBuilder().WithOkColor()
|
||||
_eb.Create().WithOkColor()
|
||||
.WithAuthor($"NadekoBot v{StatsService.BotVersion}",
|
||||
"https://nadeko-pictures.nyc3.digitaloceanspaces.com/other/avatar.png",
|
||||
"https://nadekobot.readthedocs.io/en/latest/")
|
||||
@@ -309,7 +308,8 @@ namespace NadekoBot.Modules.Utility
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithOkColor();
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor();
|
||||
foreach (var guild in guilds)
|
||||
embed.AddField(guild.Name,
|
||||
GetText("listservers", guild.Id, guild.MemberCount, guild.OwnerId),
|
||||
@@ -374,7 +374,7 @@ namespace NadekoBot.Modules.Utility
|
||||
sw.Stop();
|
||||
msg.DeleteAfter(0);
|
||||
|
||||
await ctx.Channel.SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} 🏓 {(int)sw.Elapsed.TotalMilliseconds}ms").ConfigureAwait(false);
|
||||
await SendConfirmAsync($"{Format.Bold(ctx.User.ToString())} 🏓 {(int)sw.Elapsed.TotalMilliseconds}ms").ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -413,7 +413,7 @@ namespace NadekoBot.Modules.Utility
|
||||
//
|
||||
// var inviteUsers = await _inviteService.GetInviteUsersAsync(ctx.Guild.Id);
|
||||
//
|
||||
// var embed = new EmbedBuilder()
|
||||
// var embed = _eb.Create()
|
||||
// .WithOkColor();
|
||||
//
|
||||
// await ctx.SendPaginatedConfirmAsync(page, (curPage) =>
|
||||
|
Reference in New Issue
Block a user