mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-11-04 08:34:27 -05:00
- Reworked embed builder
- Use IEmbedBuilderService to create embed builders - Wrapped embed builder and using IEmbedBuilder
This commit is contained in:
@@ -50,7 +50,7 @@ namespace NadekoBot.Modules.Administration
|
||||
var guild = (SocketGuild) ctx.Guild;
|
||||
var (enabled, channels) = _service.GetDelMsgOnCmdData(ctx.Guild.Id);
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("server_delmsgoncmd"))
|
||||
.WithDescription(enabled ? "✅" : "❌");
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace NadekoBot.Modules.Administration
|
||||
sql = string.Format(sql, reps);
|
||||
try
|
||||
{
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithTitle(GetText("sql_confirm_exec"))
|
||||
.WithDescription(Format.Code(sql));
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
|
||||
var res = await _service.ExecuteSql(sql).ConfigureAwait(false);
|
||||
await ctx.Channel.SendConfirmAsync(res.ToString()).ConfigureAwait(false);
|
||||
await SendConfirmAsync(res.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await ctx.Channel.SendErrorAsync(ex.ToString()).ConfigureAwait(false);
|
||||
await SendErrorAsync(ex.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
if (!items.Any())
|
||||
{
|
||||
return new EmbedBuilder()
|
||||
return _eb.Create()
|
||||
.WithErrorColor()
|
||||
.WithFooter(sql)
|
||||
.WithDescription("-");
|
||||
}
|
||||
|
||||
return new EmbedBuilder()
|
||||
return _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithFooter(sql)
|
||||
.WithTitle(string.Join(" ║ ", result.ColumnNames))
|
||||
@@ -106,7 +106,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[OwnerOnly]
|
||||
public async Task PurgeUser(ulong userId)
|
||||
{
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithDescription(GetText("purge_user_confirm", Format.Bold(userId.ToString())));
|
||||
|
||||
if (!await PromptUserConfirmAsync(embed).ConfigureAwait(false))
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[UserPerm(GuildPerm.Administrator)]
|
||||
public async Task DiscordPermOverrideReset()
|
||||
{
|
||||
var result = await PromptUserConfirmAsync(new EmbedBuilder()
|
||||
var result = await PromptUserConfirmAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithDescription(GetText("perm_override_all_confirm")));
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
await ctx.SendPaginatedConfirmAsync(page, curPage =>
|
||||
{
|
||||
var eb = new EmbedBuilder()
|
||||
var eb = _eb.Create()
|
||||
.WithTitle(GetText("perm_overrides"))
|
||||
.WithOkColor();
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[NadekoCommand, Aliases]
|
||||
public async Task LanguagesList()
|
||||
{
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("lang_list"))
|
||||
.WithDescription(string.Join("\n",
|
||||
supportedLocales.Select(x => $"{Format.Code(x.Key),-10} => {x.Value}")))).ConfigureAwait(false);
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace NadekoBot.Modules.Administration
|
||||
return Format.Bold(x);
|
||||
}));
|
||||
|
||||
await ctx.Channel.SendConfirmAsync(Format.Bold(GetText("log_events")) + "\n" +
|
||||
await SendConfirmAsync(Format.Bold(GetText("log_events")) + "\n" +
|
||||
str)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace NadekoBot.Modules.Administration
|
||||
return;
|
||||
}
|
||||
|
||||
await ctx.Channel.SendConfirmAsync(GetText("prot_enable", "Anti-Raid"),
|
||||
await SendConfirmAsync(GetText("prot_enable", "Anti-Raid"),
|
||||
$"{ctx.User.Mention} {GetAntiRaidString(stats)}")
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
var stats = await _service.StartAntiSpamAsync(ctx.Guild.Id, messageCount, action, time, role?.Id).ConfigureAwait(false);
|
||||
|
||||
await ctx.Channel.SendConfirmAsync(GetText("prot_enable", "Anti-Spam"),
|
||||
await SendConfirmAsync(GetText("prot_enable", "Anti-Spam"),
|
||||
$"{ctx.User.Mention} {GetAntiSpamString(stats)}").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace NadekoBot.Modules.Administration
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithOkColor()
|
||||
var embed = _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("prot_active"));
|
||||
|
||||
if (spam != null)
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[UserPerm(GuildPerm.ManageRoles)]
|
||||
public async Task ReactionRolesList()
|
||||
{
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor();
|
||||
if (!_service.Get(ctx.Guild.Id, out var rrs) ||
|
||||
!rrs.Any())
|
||||
@@ -319,7 +319,7 @@ namespace NadekoBot.Modules.Administration
|
||||
[Priority(1)]
|
||||
public async Task RoleColor([Leftover] IRole role)
|
||||
{
|
||||
await ctx.Channel.SendConfirmAsync("Role Color", role.Color.RawValue.ToString("x6")).ConfigureAwait(false);
|
||||
await SendConfirmAsync("Role Color", role.Color.RawValue.ToString("x6")).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Aliases]
|
||||
|
||||
@@ -154,7 +154,7 @@ namespace NadekoBot.Modules.Administration
|
||||
rolesStr.AppendLine();
|
||||
}
|
||||
|
||||
return new EmbedBuilder().WithOkColor()
|
||||
return _eb.Create().WithOkColor()
|
||||
.WithTitle(Format.Bold(GetText("self_assign_list", roles.Count())))
|
||||
.WithDescription(rolesStr.ToString())
|
||||
.WithFooter(exclusive
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace NadekoBot.Modules.Administration
|
||||
};
|
||||
_service.AddNewAutoCommand(cmd);
|
||||
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("scadd"))
|
||||
.AddField(GetText("server"), cmd.GuildId is null ? $"-" : $"{cmd.GuildName}/{cmd.GuildId}", true)
|
||||
.AddField(GetText("channel"), $"{cmd.ChannelName}/{cmd.ChannelId}", true)
|
||||
@@ -113,7 +113,7 @@ namespace NadekoBot.Modules.Administration
|
||||
else
|
||||
{
|
||||
var i = 0;
|
||||
await ctx.Channel.SendConfirmAsync(
|
||||
await SendConfirmAsync(
|
||||
text: string.Join("\n", scmds
|
||||
.Select(x => $@"```css
|
||||
#{++i + page * 5}
|
||||
@@ -145,7 +145,7 @@ namespace NadekoBot.Modules.Administration
|
||||
else
|
||||
{
|
||||
var i = 0;
|
||||
await ctx.Channel.SendConfirmAsync(
|
||||
await SendConfirmAsync(
|
||||
text: string.Join("\n", scmds
|
||||
.Select(x => $@"```css
|
||||
#{++i + page * 5}
|
||||
@@ -173,7 +173,7 @@ namespace NadekoBot.Modules.Administration
|
||||
ctx.Message.DeleteAfter(0);
|
||||
try
|
||||
{
|
||||
var msg = await ctx.Channel.SendConfirmAsync($"⏲ {miliseconds}ms")
|
||||
var msg = await SendConfirmAsync($"⏲ {miliseconds}ms")
|
||||
.ConfigureAwait(false);
|
||||
msg.DeleteAfter(miliseconds / 1000);
|
||||
}
|
||||
@@ -277,7 +277,7 @@ namespace NadekoBot.Modules.Administration
|
||||
if (string.IsNullOrWhiteSpace(str))
|
||||
str = GetText("no_shards_on_page");
|
||||
|
||||
return new EmbedBuilder()
|
||||
return _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithDescription($"{status}\n\n{str}");
|
||||
}, allShardStrings.Length, 25).ConfigureAwait(false);
|
||||
@@ -477,7 +477,7 @@ namespace NadekoBot.Modules.Administration
|
||||
if (CREmbed.TryParse(msg, out var crembed))
|
||||
{
|
||||
rep.Replace(crembed);
|
||||
await ch.EmbedAsync(crembed).ConfigureAwait(false);
|
||||
await ch.EmbedAsync(crembed, _eb).ConfigureAwait(false);
|
||||
await ReplyConfirmLocalizedAsync("message_sent").ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
@@ -495,7 +495,8 @@ namespace NadekoBot.Modules.Administration
|
||||
if (CREmbed.TryParse(msg, out var crembed))
|
||||
{
|
||||
rep.Replace(crembed);
|
||||
await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).EmbedAsync(crembed)
|
||||
await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false))
|
||||
.EmbedAsync(crembed, _eb)
|
||||
.ConfigureAwait(false);
|
||||
await ReplyConfirmLocalizedAsync("message_sent").ConfigureAwait(false);
|
||||
return;
|
||||
|
||||
@@ -24,12 +24,14 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
|
||||
private readonly DbService _db;
|
||||
private readonly ILogCommandService _logService;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
|
||||
public AdministrationService(Bot bot, CommandHandler cmdHandler, DbService db,
|
||||
ILogCommandService logService)
|
||||
ILogCommandService logService, IEmbedBuilderService eb)
|
||||
{
|
||||
_db = db;
|
||||
_logService = logService;
|
||||
_eb = eb;
|
||||
|
||||
DeleteMessagesOnCommand = new ConcurrentHashSet<ulong>(bot.AllGuildConfigs
|
||||
.Where(g => g.DeleteMessageOnCommand)
|
||||
@@ -170,7 +172,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
rep.Replace(crembed);
|
||||
await umsg.ModifyAsync(x =>
|
||||
{
|
||||
x.Embed = crembed.ToEmbed().Build();
|
||||
x.Embed = crembed.ToEmbed(_eb).Build();
|
||||
x.Content = crembed.PlainText?.SanitizeMentions() ?? "";
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -68,13 +68,19 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
private readonly MuteService _mute;
|
||||
private readonly ProtectionService _prot;
|
||||
private readonly GuildTimezoneService _tz;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
private readonly Timer _clearTimer;
|
||||
private readonly ConcurrentHashSet<ulong> _ignoreMessageIds = new ConcurrentHashSet<ulong>();
|
||||
|
||||
public LogCommandService(DiscordSocketClient client, IBotStrings strings,
|
||||
DbService db, MuteService mute, ProtectionService prot, GuildTimezoneService tz,
|
||||
IMemoryCache memoryCache)
|
||||
IMemoryCache memoryCache, IEmbedBuilderService eb)
|
||||
{
|
||||
_client = client;
|
||||
_memoryCache = memoryCache;
|
||||
_memoryCache = memoryCache;
|
||||
_eb = eb;
|
||||
_strings = strings;
|
||||
_db = db;
|
||||
_mute = mute;
|
||||
@@ -111,7 +117,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
{
|
||||
var title = GetText(key.Guild, "presence_updates");
|
||||
var desc = string.Join(Environment.NewLine, msgs);
|
||||
return key.SendConfirmAsync(title, desc.TrimTo(2048));
|
||||
return key.SendConfirmAsync(_eb, title, desc.TrimTo(2048));
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
@@ -148,10 +154,6 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
#endif
|
||||
}
|
||||
|
||||
private readonly Timer _clearTimer;
|
||||
private readonly ConcurrentHashSet<ulong> _ignoreMessageIds = new ConcurrentHashSet<ulong>();
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
public LogSetting GetGuildLogSettings(ulong guildId)
|
||||
{
|
||||
GuildLogSettings.TryGetValue(guildId, out LogSetting logSetting);
|
||||
@@ -254,7 +256,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
await TryGetLogChannel(g, logSetting, LogType.UserUpdated).ConfigureAwait(false)) is null)
|
||||
return;
|
||||
|
||||
var embed = new EmbedBuilder();
|
||||
var embed = _eb.Create();
|
||||
|
||||
if (before.Username != after.Username)
|
||||
{
|
||||
@@ -441,7 +443,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
break;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithAuthor(mutes)
|
||||
var embed = _eb.Create().WithAuthor(mutes)
|
||||
.WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
|
||||
.WithFooter(CurrentTime(usr.Guild))
|
||||
.WithOkColor();
|
||||
@@ -486,7 +488,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
break;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithAuthor(mutes)
|
||||
var embed = _eb.Create().WithAuthor(mutes)
|
||||
.WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
|
||||
.WithFooter($"{CurrentTime(usr.Guild)}")
|
||||
.WithOkColor();
|
||||
@@ -541,7 +543,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
break;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder().WithAuthor($"🛡 Anti-{protection}")
|
||||
var embed = _eb.Create().WithAuthor($"🛡 Anti-{protection}")
|
||||
.WithTitle(GetText(logChannel.Guild, "users") + " " + punishment)
|
||||
.WithDescription(string.Join("\n", users.Select(u => u.ToString())))
|
||||
.WithFooter(CurrentTime(logChannel.Guild))
|
||||
@@ -589,7 +591,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
(logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.UserUpdated)
|
||||
.ConfigureAwait(false)) != null)
|
||||
{
|
||||
var embed = new EmbedBuilder().WithOkColor()
|
||||
var embed = _eb.Create().WithOkColor()
|
||||
.WithFooter(CurrentTime(before.Guild))
|
||||
.WithTitle($"{before.Username}#{before.Discriminator} | {before.Id}");
|
||||
if (before.Nickname != after.Nickname)
|
||||
@@ -691,7 +693,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
.ConfigureAwait(false)) is null)
|
||||
return;
|
||||
|
||||
var embed = new EmbedBuilder().WithOkColor()
|
||||
var embed = _eb.Create().WithOkColor()
|
||||
.WithFooter(CurrentTime(before.Guild));
|
||||
|
||||
var beforeTextChannel = cbefore as ITextChannel;
|
||||
@@ -749,7 +751,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
else
|
||||
title = GetText(logChannel.Guild, "text_chan_destroyed");
|
||||
|
||||
await logChannel.EmbedAsync(new EmbedBuilder()
|
||||
await logChannel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("🆕 " + title)
|
||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||
@@ -788,7 +790,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
else
|
||||
title = GetText(logChannel.Guild, "text_chan_created");
|
||||
|
||||
await logChannel.EmbedAsync(new EmbedBuilder()
|
||||
await logChannel.EmbedAsync(_eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("🆕 " + title)
|
||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||
@@ -920,7 +922,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserLeft)
|
||||
.ConfigureAwait(false)) is null)
|
||||
return;
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("❌ " + GetText(logChannel.Guild, "user_left"))
|
||||
.WithDescription(usr.ToString())
|
||||
@@ -955,7 +957,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
.ConfigureAwait(false)) is null)
|
||||
return;
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("✅ " + GetText(logChannel.Guild, "user_joined"))
|
||||
.WithDescription($"{usr.Mention} `{usr}`")
|
||||
@@ -995,7 +997,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)
|
||||
.ConfigureAwait(false)) is null)
|
||||
return;
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("♻️ " + GetText(logChannel.Guild, "user_unbanned"))
|
||||
.WithDescription(usr.ToString())
|
||||
@@ -1030,7 +1032,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
await TryGetLogChannel(guild, logSetting, LogType.UserBanned).ConfigureAwait(false)) ==
|
||||
null)
|
||||
return;
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("🚫 " + GetText(logChannel.Guild, "user_banned"))
|
||||
.WithDescription(usr.ToString())
|
||||
@@ -1079,7 +1081,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
return;
|
||||
|
||||
var resolvedMessage = msg.Resolve(userHandling: TagHandling.FullName);
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("🗑 " + GetText(logChannel.Guild, "msg_del", ((ITextChannel) msg.Channel).Name))
|
||||
.WithDescription(msg.Author.ToString())
|
||||
@@ -1136,7 +1138,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
.ConfigureAwait(false)) is null || logChannel.Id == after.Channel.Id)
|
||||
return;
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle("📝 " + GetText(logChannel.Guild, "msg_update", ((ITextChannel)after.Channel).Name))
|
||||
.WithDescription(after.Author.ToString())
|
||||
|
||||
@@ -39,12 +39,14 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly DbService _db;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
|
||||
public MuteService(DiscordSocketClient client, DbService db)
|
||||
public MuteService(DiscordSocketClient client, DbService db, IEmbedBuilderService eb)
|
||||
{
|
||||
_client = client;
|
||||
_db = db;
|
||||
|
||||
_eb = eb;
|
||||
|
||||
using (var uow = db.GetDbContext())
|
||||
{
|
||||
var guildIds = client.Guilds.Select(x => x.Id).ToList();
|
||||
@@ -132,7 +134,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
if (string.IsNullOrWhiteSpace(reason))
|
||||
return;
|
||||
|
||||
var _ = Task.Run(() => user.SendMessageAsync(embed: new EmbedBuilder()
|
||||
var _ = Task.Run(() => user.SendMessageAsync(embed: _eb.Create()
|
||||
.WithDescription($"You've been muted in {user.Guild} server")
|
||||
.AddField("Mute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
@@ -145,7 +147,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
if (string.IsNullOrWhiteSpace(reason))
|
||||
return;
|
||||
|
||||
var _ = Task.Run(() => user.SendMessageAsync(embed: new EmbedBuilder()
|
||||
var _ = Task.Run(() => user.SendMessageAsync(embed: _eb.Create()
|
||||
.WithDescription($"You've been unmuted in {user.Guild} server")
|
||||
.AddField("Unmute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
private readonly BotConfigService _bss;
|
||||
private readonly IPubSub _pubSub;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
|
||||
//keys
|
||||
private readonly TypedKey<ActivityPubData> _activitySetKey;
|
||||
@@ -52,7 +53,8 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
IDataCache cache,
|
||||
IHttpClientFactory factory,
|
||||
BotConfigService bss,
|
||||
IPubSub pubSub)
|
||||
IPubSub pubSub,
|
||||
IEmbedBuilderService eb)
|
||||
{
|
||||
_cmdHandler = cmdHandler;
|
||||
_db = db;
|
||||
@@ -63,6 +65,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
_httpFactory = factory;
|
||||
_bss = bss;
|
||||
_pubSub = pubSub;
|
||||
_eb = eb;
|
||||
_activitySetKey = new("activity.set");
|
||||
_imagesReloadKey = new("images.reload");
|
||||
_guildLeaveKey = new("guild.leave");
|
||||
@@ -256,7 +259,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
await ownerCh.SendConfirmAsync(title, toSend).ConfigureAwait(false);
|
||||
await ownerCh.SendConfirmAsync(_eb, title, toSend).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -271,7 +274,7 @@ namespace NadekoBot.Modules.Administration.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
await firstOwnerChannel.SendConfirmAsync(title, toSend).ConfigureAwait(false);
|
||||
await firstOwnerChannel.SendConfirmAsync(_eb, title, toSend).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
|
||||
await ctx.SendPaginatedConfirmAsync(page,
|
||||
(curPage) => new EmbedBuilder()
|
||||
(curPage) => _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("timezones_available"))
|
||||
.WithDescription(string.Join("\n", timezoneStrings
|
||||
@@ -83,7 +83,7 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
_service.SetTimeZone(ctx.Guild.Id, tz);
|
||||
|
||||
await ctx.Channel.SendConfirmAsync(tz.ToString()).ConfigureAwait(false);
|
||||
await SendConfirmAsync(tz.ToString()).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace NadekoBot.Modules.Administration
|
||||
var dmFailed = false;
|
||||
try
|
||||
{
|
||||
await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).EmbedAsync(new EmbedBuilder().WithErrorColor()
|
||||
await (await user.GetOrCreateDMChannelAsync().ConfigureAwait(false)).EmbedAsync(_eb.Create().WithErrorColor()
|
||||
.WithDescription(GetText("warned_on", ctx.Guild.ToString()))
|
||||
.AddField(GetText("moderator"), ctx.User.ToString())
|
||||
.AddField(GetText("reason"), reason ?? "-"))
|
||||
@@ -79,7 +79,7 @@ namespace NadekoBot.Modules.Administration
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex.Message);
|
||||
var errorEmbed = new EmbedBuilder()
|
||||
var errorEmbed = _eb.Create()
|
||||
.WithErrorColor()
|
||||
.WithDescription(GetText("cant_apply_punishment"));
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace NadekoBot.Modules.Administration
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor();
|
||||
if (punishment is null)
|
||||
{
|
||||
@@ -219,7 +219,7 @@ namespace NadekoBot.Modules.Administration
|
||||
.ToArray();
|
||||
|
||||
var user = (ctx.Guild as SocketGuild)?.GetUser(userId)?.ToString() ?? userId.ToString();
|
||||
var embed = new EmbedBuilder()
|
||||
var embed = _eb.Create()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText("warnlog_for", user));
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace NadekoBot.Modules.Administration
|
||||
return (usr?.ToString() ?? x.Key.ToString()) + $" | {total} ({all} - {forgiven})";
|
||||
});
|
||||
|
||||
return new EmbedBuilder().WithOkColor()
|
||||
return _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("warnings_list"))
|
||||
.WithDescription(string.Join("\n", ws));
|
||||
}, warnings.Length, 15).ConfigureAwait(false);
|
||||
@@ -402,7 +402,7 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
list = GetText("warnpl_none");
|
||||
}
|
||||
await ctx.Channel.SendConfirmAsync(
|
||||
await SendConfirmAsync(
|
||||
GetText("warn_punish_list"),
|
||||
list).ConfigureAwait(false);
|
||||
}
|
||||
@@ -433,7 +433,7 @@ namespace NadekoBot.Modules.Administration
|
||||
if (embed is not null)
|
||||
{
|
||||
var userChannel = await guildUser.GetOrCreateDMChannelAsync();
|
||||
await userChannel.EmbedAsync(embed);
|
||||
await userChannel.EmbedAsync(embed, _eb);
|
||||
}
|
||||
}
|
||||
catch
|
||||
@@ -443,7 +443,7 @@ namespace NadekoBot.Modules.Administration
|
||||
}
|
||||
|
||||
await _mute.TimedBan(Context.Guild, user, time.Time, ctx.User.ToString() + " | " + msg).ConfigureAwait(false);
|
||||
var toSend = new EmbedBuilder().WithOkColor()
|
||||
var toSend = _eb.Create().WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText("banned_user"))
|
||||
.AddField(GetText("username"), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true)
|
||||
@@ -470,7 +470,7 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
await ctx.Guild.AddBanAsync(userId, 7, ctx.User.ToString() + " | " + msg);
|
||||
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText("banned_user"))
|
||||
.AddField("ID", userId.ToString(), true))
|
||||
.ConfigureAwait(false);
|
||||
@@ -500,7 +500,7 @@ namespace NadekoBot.Modules.Administration
|
||||
if (embed is not null)
|
||||
{
|
||||
var userChannel = await user.GetOrCreateDMChannelAsync();
|
||||
await userChannel.EmbedAsync(embed);
|
||||
await userChannel.EmbedAsync(embed, _eb);
|
||||
}
|
||||
}
|
||||
catch
|
||||
@@ -510,7 +510,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
await ctx.Guild.AddBanAsync(user, 7, ctx.User.ToString() + " | " + msg).ConfigureAwait(false);
|
||||
|
||||
var toSend = new EmbedBuilder().WithOkColor()
|
||||
var toSend = _eb.Create().WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText("banned_user"))
|
||||
.AddField(GetText("username"), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
@@ -539,7 +539,7 @@ namespace NadekoBot.Modules.Administration
|
||||
return;
|
||||
}
|
||||
|
||||
await Context.Channel.SendConfirmAsync(template);
|
||||
await SendConfirmAsync(template);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -591,7 +591,7 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
try
|
||||
{
|
||||
await dmChannel.EmbedAsync(crEmbed);
|
||||
await dmChannel.EmbedAsync(crEmbed, _eb);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -677,7 +677,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
try
|
||||
{
|
||||
await user.SendErrorAsync(GetText("sbdm", Format.Bold(ctx.Guild.Name), msg)).ConfigureAwait(false);
|
||||
await user.SendErrorAsync(_eb, GetText("sbdm", Format.Bold(ctx.Guild.Name), msg)).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -688,7 +688,7 @@ namespace NadekoBot.Modules.Administration
|
||||
try { await ctx.Guild.RemoveBanAsync(user).ConfigureAwait(false); }
|
||||
catch { await ctx.Guild.RemoveBanAsync(user).ConfigureAwait(false); }
|
||||
|
||||
var toSend = new EmbedBuilder().WithOkColor()
|
||||
var toSend = _eb.Create().WithOkColor()
|
||||
.WithTitle("☣ " + GetText("sb_user"))
|
||||
.AddField(GetText("username"), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
@@ -733,7 +733,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
try
|
||||
{
|
||||
await user.SendErrorAsync(GetText("kickdm", Format.Bold(ctx.Guild.Name), msg))
|
||||
await user.SendErrorAsync(_eb, GetText("kickdm", Format.Bold(ctx.Guild.Name), msg))
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
@@ -743,7 +743,7 @@ namespace NadekoBot.Modules.Administration
|
||||
|
||||
await user.KickAsync(ctx.User.ToString() + " | " + msg).ConfigureAwait(false);
|
||||
|
||||
var toSend = new EmbedBuilder().WithOkColor()
|
||||
var toSend = _eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("kicked_user"))
|
||||
.AddField(GetText("username"), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
@@ -774,7 +774,7 @@ namespace NadekoBot.Modules.Administration
|
||||
missStr = "-";
|
||||
|
||||
//send a message but don't wait for it
|
||||
var banningMessageTask = ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
var banningMessageTask = ctx.Channel.EmbedAsync(_eb.Create()
|
||||
.WithDescription(GetText("mass_kill_in_progress", bans.Count()))
|
||||
.AddField(GetText("invalid", missing), missStr)
|
||||
.WithOkColor());
|
||||
@@ -791,7 +791,7 @@ namespace NadekoBot.Modules.Administration
|
||||
//wait for the message and edit it
|
||||
var banningMessage = await banningMessageTask.ConfigureAwait(false);
|
||||
|
||||
await banningMessage.ModifyAsync(x => x.Embed = new EmbedBuilder()
|
||||
await banningMessage.ModifyAsync(x => x.Embed = _eb.Create()
|
||||
.WithDescription(GetText("mass_kill_completed", bans.Count()))
|
||||
.AddField(GetText("invalid", missing), missStr)
|
||||
.WithOkColor()
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace NadekoBot.Modules.Administration
|
||||
{
|
||||
text = GetText("no_vcroles");
|
||||
}
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
||||
await ctx.Channel.EmbedAsync(_eb.Create().WithOkColor()
|
||||
.WithTitle(GetText("vc_role_list"))
|
||||
.WithDescription(text))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user