mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
part 3 of the response rework
This commit is contained in:
@@ -19,18 +19,21 @@ public class GreetService : INService, IReadyExecutor
|
||||
private readonly GreetGrouper<IUser> _byes = new();
|
||||
private readonly BotConfigService _bss;
|
||||
private readonly IReplacementService _repSvc;
|
||||
private readonly IMessageSenderService _sender;
|
||||
|
||||
public GreetService(
|
||||
DiscordSocketClient client,
|
||||
IBot bot,
|
||||
DbService db,
|
||||
BotConfigService bss,
|
||||
IMessageSenderService sender,
|
||||
IReplacementService repSvc)
|
||||
{
|
||||
_db = db;
|
||||
_client = client;
|
||||
_bss = bss;
|
||||
_repSvc = repSvc;
|
||||
_sender = sender;
|
||||
|
||||
_guildConfigsCache = new(bot.AllGuildConfigs.ToDictionary(g => g.GuildId, GreetSettings.Create));
|
||||
|
||||
@@ -281,6 +284,7 @@ public class GreetService : INService, IReadyExecutor
|
||||
FullMode = BoundedChannelFullMode.DropNewest
|
||||
});
|
||||
|
||||
|
||||
private async Task<bool> GreetDmUser(GreetSettings conf, IGuildUser user)
|
||||
{
|
||||
var completionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
@@ -298,32 +302,32 @@ public class GreetService : INService, IReadyExecutor
|
||||
// .Build();
|
||||
|
||||
var repCtx = new ReplacementContext(client: _client, guild: user.Guild, users: user);
|
||||
var text = SmartText.CreateFrom(conf.DmGreetMessageText);
|
||||
text = await _repSvc.ReplaceAsync(text, repCtx);
|
||||
var smartText = SmartText.CreateFrom(conf.DmGreetMessageText);
|
||||
smartText = await _repSvc.ReplaceAsync(smartText, repCtx);
|
||||
|
||||
if (text is SmartPlainText pt)
|
||||
if (smartText is SmartPlainText pt)
|
||||
{
|
||||
text = new SmartEmbedText()
|
||||
smartText = new SmartEmbedText()
|
||||
{
|
||||
Description = pt.Text
|
||||
};
|
||||
}
|
||||
|
||||
if (text is SmartEmbedText set)
|
||||
if (smartText is SmartEmbedText set)
|
||||
{
|
||||
text = set with
|
||||
smartText = set with
|
||||
{
|
||||
Footer = CreateFooterSource(user)
|
||||
};
|
||||
}
|
||||
else if (text is SmartEmbedTextArray seta)
|
||||
else if (smartText is SmartEmbedTextArray seta)
|
||||
{
|
||||
// if the greet dm message is a text array
|
||||
var ebElem = seta.Embeds.LastOrDefault();
|
||||
if (ebElem is null)
|
||||
{
|
||||
// if there are no embeds, add an embed with the footer
|
||||
text = seta with
|
||||
smartText = seta with
|
||||
{
|
||||
Embeds = new[]
|
||||
{
|
||||
@@ -355,7 +359,7 @@ public class GreetService : INService, IReadyExecutor
|
||||
}
|
||||
}
|
||||
|
||||
await user.SendAsync(text);
|
||||
await _sender.Response(user).Text(smartText).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@@ -31,13 +31,13 @@ public class MuteService : INService
|
||||
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly DbService _db;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly IMessageSenderService _sender;
|
||||
|
||||
public MuteService(DiscordSocketClient client, DbService db, IEmbedBuilderService eb)
|
||||
public MuteService(DiscordSocketClient client, DbService db, IMessageSenderService sender)
|
||||
{
|
||||
_client = client;
|
||||
_db = db;
|
||||
_eb = eb;
|
||||
_sender = sender;
|
||||
|
||||
using (var uow = db.GetDbContext())
|
||||
{
|
||||
@@ -122,13 +122,13 @@ public class MuteService : INService
|
||||
if (string.IsNullOrWhiteSpace(reason))
|
||||
return;
|
||||
|
||||
_ = Task.Run(() => user.SendMessageAsync(embed: new EmbedBuilder()
|
||||
.WithDescription(
|
||||
$"You've been muted in {user.Guild} server")
|
||||
.AddField("Mute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason)
|
||||
.Build()));
|
||||
_ = Task.Run(() => _sender.Response(user)
|
||||
.Embed(new EmbedBuilder()
|
||||
.WithDescription($"You've been muted in {user.Guild} server")
|
||||
.AddField("Mute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
}
|
||||
|
||||
private void OnUserUnmuted(
|
||||
@@ -140,13 +140,13 @@ public class MuteService : INService
|
||||
if (string.IsNullOrWhiteSpace(reason))
|
||||
return;
|
||||
|
||||
_ = Task.Run(() => user.SendMessageAsync(embed: new EmbedBuilder()
|
||||
.WithDescription(
|
||||
$"You've been unmuted in {user.Guild} server")
|
||||
.AddField("Unmute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason)
|
||||
.Build()));
|
||||
_ = Task.Run(() => _sender.Response(user)
|
||||
.Embed(new EmbedBuilder()
|
||||
.WithDescription($"You've been unmuted in {user.Guild} server")
|
||||
.AddField("Unmute Type", type.ToString())
|
||||
.AddField("Moderator", mod.ToString())
|
||||
.AddField("Reason", reason))
|
||||
.SendAsync());
|
||||
}
|
||||
|
||||
private Task Client_UserJoined(IGuildUser usr)
|
||||
|
@@ -10,16 +10,16 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor
|
||||
private readonly IBotCredsProvider _bcp;
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly IEmbedBuilderService _ebs;
|
||||
private readonly IMessageSenderService _sender;
|
||||
|
||||
public CheckForUpdatesService(BotConfigService bcs, IBotCredsProvider bcp, IHttpClientFactory httpFactory,
|
||||
DiscordSocketClient client, IEmbedBuilderService ebs)
|
||||
DiscordSocketClient client, IMessageSenderService sender)
|
||||
{
|
||||
_bcs = bcs;
|
||||
_bcp = bcp;
|
||||
_httpFactory = httpFactory;
|
||||
_client = client;
|
||||
_ebs = ebs;
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
public async Task OnReadyAsync()
|
||||
@@ -86,7 +86,7 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor
|
||||
.WithDescription(thisVersionChangelog.TrimTo(4096))
|
||||
.WithFooter("You may disable these messages by typing '.conf bot checkforupdates false'");
|
||||
|
||||
await user.EmbedAsync(eb);
|
||||
await _sender.Response(user).Embed(eb).SendAsync();
|
||||
}).WhenAll();
|
||||
}
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
private readonly BotConfigService _bss;
|
||||
private readonly IPubSub _pubSub;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly IMessageSenderService _sender;
|
||||
|
||||
//keys
|
||||
private readonly TypedKey<ActivityPubData> _activitySetKey;
|
||||
@@ -40,7 +40,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
|
||||
IHttpClientFactory factory,
|
||||
BotConfigService bss,
|
||||
IPubSub pubSub,
|
||||
IEmbedBuilderService eb)
|
||||
IMessageSenderService sender)
|
||||
{
|
||||
_cmdHandler = cmdHandler;
|
||||
_db = db;
|
||||
@@ -50,7 +50,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
|
||||
_httpFactory = factory;
|
||||
_bss = bss;
|
||||
_pubSub = pubSub;
|
||||
_eb = eb;
|
||||
_sender = sender;
|
||||
_activitySetKey = new("activity.set");
|
||||
_guildLeaveKey = new("guild.leave");
|
||||
|
||||
@@ -225,7 +225,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
|
||||
{
|
||||
try
|
||||
{
|
||||
await ownerCh.Response(_strings, _eb).Confirm(title, toSend).SendAsync();
|
||||
await _sender.Response(ownerCh).Confirm(title, toSend).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -238,7 +238,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
|
||||
try
|
||||
{
|
||||
if (_client.GetChannel(cid) is ITextChannel ch)
|
||||
await ch.Response(_strings, _eb).Confirm(title, toSend).SendAsync();
|
||||
await _sender.Response(ch).Confirm(title, toSend).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -252,7 +252,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
|
||||
{
|
||||
try
|
||||
{
|
||||
await firstOwnerChannel.Response(_strings, _eb).Confirm(title, toSend).SendAsync();
|
||||
await _sender.Response(firstOwnerChannel).Confirm(title, toSend).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@@ -22,7 +22,6 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
private readonly MuteService _mute;
|
||||
private readonly ProtectionService _prot;
|
||||
private readonly GuildTimezoneService _tz;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
|
||||
private readonly ConcurrentHashSet<ulong> _ignoreMessageIds = new();
|
||||
@@ -37,20 +36,18 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
ProtectionService prot,
|
||||
GuildTimezoneService tz,
|
||||
IMemoryCache memoryCache,
|
||||
IEmbedBuilderService eb,
|
||||
UserPunishService punishService,
|
||||
IMessageSenderService sender)
|
||||
{
|
||||
_client = client;
|
||||
_memoryCache = memoryCache;
|
||||
_eb = eb;
|
||||
_sender = sender;
|
||||
_strings = strings;
|
||||
_db = db;
|
||||
_mute = mute;
|
||||
_prot = prot;
|
||||
_tz = tz;
|
||||
_punishService = punishService;
|
||||
_sender = sender;
|
||||
|
||||
using (var uow = db.GetDbContext())
|
||||
{
|
||||
@@ -73,7 +70,6 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
_client.UserLeft += _client_UserLeft;
|
||||
// _client.PresenceUpdated += _client_UserPresenceUpdated;
|
||||
_client.UserVoiceStateUpdated += _client_UserVoiceStateUpdated;
|
||||
_client.UserVoiceStateUpdated += _client_UserVoiceStateUpdated_TTS;
|
||||
_client.GuildMemberUpdated += _client_GuildUserUpdated;
|
||||
_client.PresenceUpdated += _client_PresenceUpdated;
|
||||
_client.UserUpdated += _client_UserUpdated;
|
||||
@@ -168,11 +164,11 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
|
||||
var title = GetText(logChannel.Guild, strs.thread_deleted);
|
||||
|
||||
await logChannel.EmbedAsync(new EmbedBuilder()
|
||||
await _sender.Response(logChannel).Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("🗑 " + title)
|
||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||
.WithFooter(CurrentTime(ch.Guild)));
|
||||
.WithFooter(CurrentTime(ch.Guild))).SendAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -198,11 +194,11 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
|
||||
var title = GetText(logChannel.Guild, strs.thread_created);
|
||||
|
||||
await logChannel.EmbedAsync(new EmbedBuilder()
|
||||
await _sender.Response(logChannel).Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("🆕 " + title)
|
||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||
.WithFooter(CurrentTime(ch.Guild)));
|
||||
.WithFooter(CurrentTime(ch.Guild))).SendAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -313,7 +309,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
logSetting.UserLeftId = logSetting.UserBannedId = logSetting.UserUnbannedId = logSetting.UserUpdatedId =
|
||||
logSetting.ChannelCreatedId = logSetting.ChannelDestroyedId = logSetting.ChannelUpdatedId =
|
||||
logSetting.LogUserPresenceId = logSetting.LogVoicePresenceId = logSetting.UserMutedId =
|
||||
logSetting.LogVoicePresenceTTSId = logSetting.ThreadCreatedId = logSetting.ThreadDeletedId
|
||||
logSetting.ThreadCreatedId = logSetting.ThreadDeletedId
|
||||
= logSetting.LogWarnsId = value ? channelId : null;
|
||||
await uow.SaveChangesAsync();
|
||||
GuildLogSettings.AddOrUpdate(guildId, _ => logSetting, (_, _) => logSetting);
|
||||
@@ -339,7 +335,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
.AddField("Reason", string.IsNullOrWhiteSpace(arg.Reason) ? "-" : arg.Reason, true)
|
||||
.WithFooter(CurrentTime(g));
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
private Task _client_UserUpdated(SocketUser before, SocketUser uAfter)
|
||||
@@ -389,7 +385,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
else
|
||||
return;
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -451,10 +447,6 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
case LogType.VoicePresence:
|
||||
channelId = logSetting.LogVoicePresenceId = logSetting.LogVoicePresenceId is null ? cid : default;
|
||||
break;
|
||||
case LogType.VoicePresenceTts:
|
||||
channelId = logSetting.LogVoicePresenceTTSId =
|
||||
logSetting.LogVoicePresenceTTSId is null ? cid : default;
|
||||
break;
|
||||
case LogType.UserWarned:
|
||||
channelId = logSetting.LogWarnsId = logSetting.LogWarnsId is null ? cid : default;
|
||||
break;
|
||||
@@ -472,48 +464,6 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
return channelId is not null;
|
||||
}
|
||||
|
||||
private Task _client_UserVoiceStateUpdated_TTS(SocketUser iusr, SocketVoiceState before, SocketVoiceState after)
|
||||
{
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (iusr is not IGuildUser usr)
|
||||
return;
|
||||
|
||||
var beforeVch = before.VoiceChannel;
|
||||
var afterVch = after.VoiceChannel;
|
||||
|
||||
if (beforeVch == afterVch)
|
||||
return;
|
||||
|
||||
if (!GuildLogSettings.TryGetValue(usr.Guild.Id, out var logSetting)
|
||||
|| logSetting.LogVoicePresenceTTSId is null)
|
||||
return;
|
||||
|
||||
ITextChannel? logChannel;
|
||||
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.VoicePresenceTts)) is null)
|
||||
return;
|
||||
|
||||
var str = string.Empty;
|
||||
if (beforeVch?.Guild == afterVch?.Guild)
|
||||
str = GetText(logChannel.Guild, strs.log_vc_moved(usr.Username, beforeVch?.Name, afterVch?.Name));
|
||||
else if (beforeVch is null)
|
||||
str = GetText(logChannel.Guild, strs.log_vc_joined(usr.Username, afterVch?.Name));
|
||||
else if (afterVch is null)
|
||||
str = GetText(logChannel.Guild, strs.log_vc_left(usr.Username, beforeVch.Name));
|
||||
|
||||
var toDelete = await logChannel.SendMessageAsync(str, true);
|
||||
toDelete.DeleteAfter(5);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void MuteCommands_UserMuted(
|
||||
IGuildUser usr,
|
||||
IUser mod,
|
||||
@@ -551,7 +501,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
.WithFooter(CurrentTime(usr.Guild))
|
||||
.WithOkColor();
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -601,7 +551,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
if (!string.IsNullOrWhiteSpace(reason))
|
||||
embed.WithDescription(reason);
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -653,7 +603,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
.WithFooter(CurrentTime(logChannel.Guild))
|
||||
.WithOkColor();
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -711,7 +661,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
.AddField(GetText(logChannel.Guild, strs.new_nick),
|
||||
$"{after.Nickname}#{after.Discriminator}");
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
else if (!before.Roles.SequenceEqual(after.Roles))
|
||||
{
|
||||
@@ -721,7 +671,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
embed.WithAuthor("⚔ " + GetText(logChannel.Guild, strs.user_role_add))
|
||||
.WithDescription(string.Join(", ", diffRoles).SanitizeMentions());
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
else if (before.Roles.Count > after.Roles.Count)
|
||||
{
|
||||
@@ -735,7 +685,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
embed.WithAuthor("⚔ " + GetText(logChannel.Guild, strs.user_role_rem))
|
||||
.WithDescription(string.Join(", ", diffRoles).SanitizeMentions());
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -791,7 +741,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
else
|
||||
return;
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -826,11 +776,11 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
else
|
||||
title = GetText(logChannel.Guild, strs.text_chan_destroyed);
|
||||
|
||||
await logChannel.EmbedAsync(new EmbedBuilder()
|
||||
await _sender.Response(logChannel).Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("🆕 " + title)
|
||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||
.WithFooter(CurrentTime(ch.Guild)));
|
||||
.WithFooter(CurrentTime(ch.Guild))).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -862,11 +812,11 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
else
|
||||
title = GetText(logChannel.Guild, strs.text_chan_created);
|
||||
|
||||
await logChannel.EmbedAsync(new EmbedBuilder()
|
||||
await _sender.Response(logChannel).Embed(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("🆕 " + title)
|
||||
.WithDescription($"{ch.Name} | {ch.Id}")
|
||||
.WithFooter(CurrentTime(ch.Guild)));
|
||||
.WithFooter(CurrentTime(ch.Guild))).SendAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -975,7 +925,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
if (Uri.IsWellFormedUriString(usr.GetAvatarUrl(), UriKind.Absolute))
|
||||
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -1014,7 +964,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
if (Uri.IsWellFormedUriString(usr.GetAvatarUrl(), UriKind.Absolute))
|
||||
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -1049,7 +999,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
if (Uri.IsWellFormedUriString(usr.GetAvatarUrl(), UriKind.Absolute))
|
||||
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -1099,7 +1049,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
if (Uri.IsWellFormedUriString(avatarUrl, UriKind.Absolute))
|
||||
embed.WithThumbnailUrl(usr.GetAvatarUrl());
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -1152,7 +1102,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
string.Join(", ", msg.Attachments.Select(a => a.Url)));
|
||||
}
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -1212,7 +1162,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
.AddField("Id", after.Id.ToString())
|
||||
.WithFooter(CurrentTime(channel.Guild));
|
||||
|
||||
await logChannel.EmbedAsync(embed);
|
||||
await _sender.Response(logChannel).Embed(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -1266,9 +1216,6 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
case LogType.VoicePresence:
|
||||
id = logSetting.LogVoicePresenceId;
|
||||
break;
|
||||
case LogType.VoicePresenceTts:
|
||||
id = logSetting.LogVoicePresenceTTSId;
|
||||
break;
|
||||
case LogType.UserMuted:
|
||||
id = logSetting.UserMutedId;
|
||||
break;
|
||||
@@ -1348,9 +1295,6 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|
||||
case LogType.VoicePresence:
|
||||
newLogSetting.LogVoicePresenceId = null;
|
||||
break;
|
||||
case LogType.VoicePresenceTts:
|
||||
newLogSetting.LogVoicePresenceTTSId = null;
|
||||
break;
|
||||
case LogType.UserWarned:
|
||||
newLogSetting.LogWarnsId = null;
|
||||
break;
|
||||
|
@@ -145,8 +145,6 @@ public partial class Administration
|
||||
return l.LogUserPresenceId;
|
||||
case LogType.VoicePresence:
|
||||
return l.LogVoicePresenceId;
|
||||
case LogType.VoicePresenceTts:
|
||||
return l.LogVoicePresenceTTSId;
|
||||
case LogType.UserMuted:
|
||||
return l.UserMutedId;
|
||||
case LogType.UserWarned:
|
||||
|
@@ -65,11 +65,13 @@ public partial class Administration
|
||||
var dmFailed = false;
|
||||
try
|
||||
{
|
||||
await user.EmbedAsync(new EmbedBuilder()
|
||||
.WithErrorColor()
|
||||
.WithDescription(GetText(strs.warned_on(ctx.Guild.ToString())))
|
||||
.AddField(GetText(strs.moderator), ctx.User.ToString())
|
||||
.AddField(GetText(strs.reason), reason ?? "-"));
|
||||
await _sender.Response(user)
|
||||
.Embed(new EmbedBuilder()
|
||||
.WithErrorColor()
|
||||
.WithDescription(GetText(strs.warned_on(ctx.Guild.ToString())))
|
||||
.AddField(GetText(strs.moderator), ctx.User.ToString())
|
||||
.AddField(GetText(strs.reason), reason ?? "-"))
|
||||
.SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -84,7 +86,8 @@ public partial class Administration
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warning(ex, "Exception occured while warning a user");
|
||||
var errorEmbed = new EmbedBuilder().WithErrorColor().WithDescription(GetText(strs.cant_apply_punishment));
|
||||
var errorEmbed = new EmbedBuilder().WithErrorColor()
|
||||
.WithDescription(GetText(strs.cant_apply_punishment));
|
||||
|
||||
if (dmFailed)
|
||||
errorEmbed.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
|
||||
@@ -261,9 +264,9 @@ public partial class Administration
|
||||
});
|
||||
|
||||
return new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.warnings_list))
|
||||
.WithDescription(string.Join("\n", ws));
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.warnings_list))
|
||||
.WithDescription(string.Join("\n", ws));
|
||||
},
|
||||
warnings.Length,
|
||||
15);
|
||||
@@ -433,9 +436,10 @@ public partial class Administration
|
||||
try
|
||||
{
|
||||
var defaultMessage = GetText(strs.bandm(Format.Bold(ctx.Guild.Name), msg));
|
||||
var embed = await _service.GetBanUserDmEmbed(Context, guildUser, defaultMessage, msg, time.Time);
|
||||
if (embed is not null)
|
||||
await guildUser.SendAsync(embed);
|
||||
var smartText =
|
||||
await _service.GetBanUserDmEmbed(Context, guildUser, defaultMessage, msg, time.Time);
|
||||
if (smartText is not null)
|
||||
await Response().User(guildUser).Text(smartText).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -447,13 +451,13 @@ public partial class Administration
|
||||
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
|
||||
await _mute.TimedBan(ctx.Guild, userId, time.Time, (ctx.User + " | " + msg).TrimTo(512), banPrune);
|
||||
var toSend = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText(strs.banned_user))
|
||||
.AddField(GetText(strs.username), user?.ToString() ?? userId.ToString(), true)
|
||||
.AddField("ID", userId.ToString(), true)
|
||||
.AddField(GetText(strs.duration),
|
||||
time.Time.Humanize(3, minUnit: TimeUnit.Minute, culture: Culture),
|
||||
true);
|
||||
.WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText(strs.banned_user))
|
||||
.AddField(GetText(strs.username), user?.ToString() ?? userId.ToString(), true)
|
||||
.AddField("ID", userId.ToString(), true)
|
||||
.AddField(GetText(strs.duration),
|
||||
time.Time.Humanize(3, minUnit: TimeUnit.Minute, culture: Culture),
|
||||
true);
|
||||
|
||||
if (dmFailed)
|
||||
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
|
||||
@@ -475,9 +479,9 @@ public partial class Administration
|
||||
await ctx.Guild.AddBanAsync(userId, banPrune, (ctx.User + " | " + msg).TrimTo(512));
|
||||
|
||||
await ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText(strs.banned_user))
|
||||
.AddField("ID", userId.ToString(), true));
|
||||
.WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText(strs.banned_user))
|
||||
.AddField("ID", userId.ToString(), true));
|
||||
}
|
||||
else
|
||||
await Ban(user, msg);
|
||||
@@ -500,7 +504,7 @@ public partial class Administration
|
||||
var defaultMessage = GetText(strs.bandm(Format.Bold(ctx.Guild.Name), msg));
|
||||
var embed = await _service.GetBanUserDmEmbed(Context, user, defaultMessage, msg, null);
|
||||
if (embed is not null)
|
||||
await user.SendAsync(embed);
|
||||
await Response().User(user).Text(embed).SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -511,10 +515,10 @@ public partial class Administration
|
||||
await ctx.Guild.AddBanAsync(user, banPrune, (ctx.User + " | " + msg).TrimTo(512));
|
||||
|
||||
var toSend = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText(strs.banned_user))
|
||||
.AddField(GetText(strs.username), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
.WithOkColor()
|
||||
.WithTitle("⛔️ " + GetText(strs.banned_user))
|
||||
.AddField(GetText(strs.username), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
|
||||
if (dmFailed)
|
||||
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
|
||||
@@ -594,19 +598,19 @@ public partial class Administration
|
||||
private async Task InternalBanMessageTest(string reason, TimeSpan? duration)
|
||||
{
|
||||
var defaultMessage = GetText(strs.bandm(Format.Bold(ctx.Guild.Name), reason));
|
||||
var embed = await _service.GetBanUserDmEmbed(Context,
|
||||
var smartText = await _service.GetBanUserDmEmbed(Context,
|
||||
(IGuildUser)ctx.User,
|
||||
defaultMessage,
|
||||
reason,
|
||||
duration);
|
||||
|
||||
if (embed is null)
|
||||
if (smartText is null)
|
||||
await Response().Confirm(strs.banmsg_disabled).SendAsync();
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
await ctx.User.SendAsync(embed);
|
||||
await Response().User(ctx.User).Text(smartText).SendAsync();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -692,7 +696,7 @@ public partial class Administration
|
||||
{
|
||||
await Response()
|
||||
.Channel(await user.CreateDMChannelAsync())
|
||||
.Error(GetText(strs.sbdm(Format.Bold(ctx.Guild.Name), msg)))
|
||||
.Error(strs.sbdm(Format.Bold(ctx.Guild.Name), msg))
|
||||
.SendAsync();
|
||||
}
|
||||
catch
|
||||
@@ -706,10 +710,10 @@ public partial class Administration
|
||||
catch { await ctx.Guild.RemoveBanAsync(user); }
|
||||
|
||||
var toSend = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("☣ " + GetText(strs.sb_user))
|
||||
.AddField(GetText(strs.username), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
.WithOkColor()
|
||||
.WithTitle("☣ " + GetText(strs.sb_user))
|
||||
.AddField(GetText(strs.username), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
|
||||
if (dmFailed)
|
||||
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
|
||||
@@ -761,10 +765,10 @@ public partial class Administration
|
||||
await user.KickAsync((ctx.User + " | " + msg).TrimTo(512));
|
||||
|
||||
var toSend = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.kicked_user))
|
||||
.AddField(GetText(strs.username), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
.WithOkColor()
|
||||
.WithTitle(GetText(strs.kicked_user))
|
||||
.AddField(GetText(strs.username), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
|
||||
if (dmFailed)
|
||||
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
|
||||
@@ -792,9 +796,11 @@ public partial class Administration
|
||||
try
|
||||
{
|
||||
var dmMessage = GetText(strs.timeoutdm(Format.Bold(ctx.Guild.Name), msg));
|
||||
await user.EmbedAsync(new EmbedBuilder()
|
||||
.WithPendingColor()
|
||||
.WithDescription(dmMessage));
|
||||
await _sender.Response(user)
|
||||
.Embed(new EmbedBuilder()
|
||||
.WithPendingColor()
|
||||
.WithDescription(dmMessage))
|
||||
.SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -804,10 +810,10 @@ public partial class Administration
|
||||
await user.SetTimeOutAsync(time.Time);
|
||||
|
||||
var toSend = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("⏳ " + GetText(strs.timedout_user))
|
||||
.AddField(GetText(strs.username), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
.WithOkColor()
|
||||
.WithTitle("⏳ " + GetText(strs.timedout_user))
|
||||
.AddField(GetText(strs.username), user.ToString(), true)
|
||||
.AddField("ID", user.Id.ToString(), true);
|
||||
|
||||
if (dmFailed)
|
||||
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
|
||||
@@ -865,9 +871,9 @@ public partial class Administration
|
||||
missStr = "-";
|
||||
|
||||
var toSend = new EmbedBuilder()
|
||||
.WithDescription(GetText(strs.mass_ban_in_progress(banning.Count)))
|
||||
.AddField(GetText(strs.invalid(missing.Count)), missStr)
|
||||
.WithPendingColor();
|
||||
.WithDescription(GetText(strs.mass_ban_in_progress(banning.Count)))
|
||||
.AddField(GetText(strs.invalid(missing.Count)), missStr)
|
||||
.WithPendingColor();
|
||||
|
||||
var banningMessage = await Response().Embed(toSend).SendAsync();
|
||||
|
||||
@@ -885,11 +891,11 @@ public partial class Administration
|
||||
}
|
||||
|
||||
await banningMessage.ModifyAsync(x => x.Embed = new EmbedBuilder()
|
||||
.WithDescription(
|
||||
GetText(strs.mass_ban_completed(banning.Count())))
|
||||
.AddField(GetText(strs.invalid(missing.Count)), missStr)
|
||||
.WithOkColor()
|
||||
.Build());
|
||||
.WithDescription(
|
||||
GetText(strs.mass_ban_completed(banning.Count())))
|
||||
.AddField(GetText(strs.invalid(missing.Count)), missStr)
|
||||
.WithOkColor()
|
||||
.Build());
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -910,10 +916,10 @@ public partial class Administration
|
||||
|
||||
//send a message but don't wait for it
|
||||
var banningMessageTask = ctx.Channel.EmbedAsync(new EmbedBuilder()
|
||||
.WithDescription(
|
||||
GetText(strs.mass_kill_in_progress(bans.Count())))
|
||||
.AddField(GetText(strs.invalid(missing)), missStr)
|
||||
.WithPendingColor());
|
||||
.WithDescription(
|
||||
GetText(strs.mass_kill_in_progress(bans.Count())))
|
||||
.AddField(GetText(strs.invalid(missing)), missStr)
|
||||
.WithPendingColor());
|
||||
|
||||
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
|
||||
//do the banning
|
||||
@@ -930,11 +936,11 @@ public partial class Administration
|
||||
var banningMessage = await banningMessageTask;
|
||||
|
||||
await banningMessage.ModifyAsync(x => x.Embed = new EmbedBuilder()
|
||||
.WithDescription(
|
||||
GetText(strs.mass_kill_completed(bans.Count())))
|
||||
.AddField(GetText(strs.invalid(missing)), missStr)
|
||||
.WithOkColor()
|
||||
.Build());
|
||||
.WithDescription(
|
||||
GetText(strs.mass_kill_completed(bans.Count())))
|
||||
.AddField(GetText(strs.invalid(missing)), missStr)
|
||||
.WithOkColor()
|
||||
.Build());
|
||||
}
|
||||
|
||||
public class WarnExpireOptions : INadekoCommandOptions
|
||||
|
Reference in New Issue
Block a user