Part2 of the response system rework

This commit is contained in:
Kwoth
2024-04-29 01:13:45 +00:00
parent 4bab94b329
commit d28c7b500d
128 changed files with 2723 additions and 2289 deletions

View File

@@ -49,9 +49,9 @@ public partial class Administration : NadekoModule<AdministrationService>
{
var newValue = await _somethingOnly.ToggleImageOnlyChannelAsync(ctx.Guild.Id, ctx.Channel.Id);
if (newValue)
await ReplyConfirmLocalizedAsync(strs.imageonly_enable);
await Response().Confirm(strs.imageonly_enable).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.imageonly_disable);
await Response().Pending(strs.imageonly_disable).SendAsync();
}
[Cmd]
@@ -62,9 +62,9 @@ public partial class Administration : NadekoModule<AdministrationService>
{
var newValue = await _somethingOnly.ToggleLinkOnlyChannelAsync(ctx.Guild.Id, ctx.Channel.Id);
if (newValue)
await ReplyConfirmLocalizedAsync(strs.linkonly_enable);
await Response().Confirm(strs.linkonly_enable).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.linkonly_disable);
await Response().Pending(strs.linkonly_disable).SendAsync();
}
[Cmd]
@@ -95,7 +95,7 @@ public partial class Administration : NadekoModule<AdministrationService>
var guild = (SocketGuild)ctx.Guild;
var (enabled, channels) = _service.GetDelMsgOnCmdData(ctx.Guild.Id);
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithOkColor()
.WithTitle(GetText(strs.server_delmsgoncmd))
.WithDescription(enabled ? "✅" : "❌");
@@ -113,7 +113,7 @@ public partial class Administration : NadekoModule<AdministrationService>
embed.AddField(GetText(strs.channel_delmsgoncmd), str);
await EmbedAsync(embed);
await Response().Embed(embed).SendAsync();
}
[Cmd]
@@ -126,12 +126,12 @@ public partial class Administration : NadekoModule<AdministrationService>
if (_service.ToggleDeleteMessageOnCommand(ctx.Guild.Id))
{
_service.DeleteMessagesOnCommand.Add(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.delmsg_on);
await Response().Confirm(strs.delmsg_on).SendAsync();
}
else
{
_service.DeleteMessagesOnCommand.TryRemove(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.delmsg_off);
await Response().Confirm(strs.delmsg_off).SendAsync();
}
}
@@ -154,11 +154,11 @@ public partial class Administration : NadekoModule<AdministrationService>
await _service.SetDelMsgOnCmdState(ctx.Guild.Id, actualChId, s);
if (s == State.Disable)
await ReplyConfirmLocalizedAsync(strs.delmsg_channel_off);
await Response().Confirm(strs.delmsg_channel_off).SendAsync();
else if (s == State.Enable)
await ReplyConfirmLocalizedAsync(strs.delmsg_channel_on);
await Response().Confirm(strs.delmsg_channel_on).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.delmsg_channel_inherit);
await Response().Confirm(strs.delmsg_channel_inherit).SendAsync();
}
[Cmd]
@@ -168,7 +168,7 @@ public partial class Administration : NadekoModule<AdministrationService>
public async Task Deafen(params IGuildUser[] users)
{
await _service.DeafenUsers(true, users);
await ReplyConfirmLocalizedAsync(strs.deafen);
await Response().Confirm(strs.deafen).SendAsync();
}
[Cmd]
@@ -178,7 +178,7 @@ public partial class Administration : NadekoModule<AdministrationService>
public async Task UnDeafen(params IGuildUser[] users)
{
await _service.DeafenUsers(false, users);
await ReplyConfirmLocalizedAsync(strs.undeafen);
await Response().Confirm(strs.undeafen).SendAsync();
}
[Cmd]
@@ -188,7 +188,7 @@ public partial class Administration : NadekoModule<AdministrationService>
public async Task DelVoiChanl([Leftover] IVoiceChannel voiceChannel)
{
await voiceChannel.DeleteAsync();
await ReplyConfirmLocalizedAsync(strs.delvoich(Format.Bold(voiceChannel.Name)));
await Response().Confirm(strs.delvoich(Format.Bold(voiceChannel.Name))).SendAsync();
}
[Cmd]
@@ -198,7 +198,7 @@ public partial class Administration : NadekoModule<AdministrationService>
public async Task CreatVoiChanl([Leftover] string channelName)
{
var ch = await ctx.Guild.CreateVoiceChannelAsync(channelName);
await ReplyConfirmLocalizedAsync(strs.createvoich(Format.Bold(ch.Name)));
await Response().Confirm(strs.createvoich(Format.Bold(ch.Name))).SendAsync();
}
[Cmd]
@@ -208,7 +208,7 @@ public partial class Administration : NadekoModule<AdministrationService>
public async Task DelTxtChanl([Leftover] ITextChannel toDelete)
{
await toDelete.DeleteAsync();
await ReplyConfirmLocalizedAsync(strs.deltextchan(Format.Bold(toDelete.Name)));
await Response().Confirm(strs.deltextchan(Format.Bold(toDelete.Name))).SendAsync();
}
[Cmd]
@@ -218,7 +218,7 @@ public partial class Administration : NadekoModule<AdministrationService>
public async Task CreaTxtChanl([Leftover] string channelName)
{
var txtCh = await ctx.Guild.CreateTextChannelAsync(channelName);
await ReplyConfirmLocalizedAsync(strs.createtextchan(Format.Bold(txtCh.Name)));
await Response().Confirm(strs.createtextchan(Format.Bold(txtCh.Name))).SendAsync();
}
[Cmd]
@@ -230,7 +230,7 @@ public partial class Administration : NadekoModule<AdministrationService>
var channel = (ITextChannel)ctx.Channel;
topic ??= "";
await channel.ModifyAsync(c => c.Topic = topic);
await ReplyConfirmLocalizedAsync(strs.set_topic);
await Response().Confirm(strs.set_topic).SendAsync();
}
[Cmd]
@@ -241,7 +241,7 @@ public partial class Administration : NadekoModule<AdministrationService>
{
var channel = (ITextChannel)ctx.Channel;
await channel.ModifyAsync(c => c.Name = name);
await ReplyConfirmLocalizedAsync(strs.set_channel_name);
await Response().Confirm(strs.set_channel_name).SendAsync();
}
[Cmd]
@@ -256,9 +256,9 @@ public partial class Administration : NadekoModule<AdministrationService>
await channel.ModifyAsync(c => c.IsNsfw = !isEnabled);
if (isEnabled)
await ReplyConfirmLocalizedAsync(strs.nsfw_set_false);
await Response().Confirm(strs.nsfw_set_false).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.nsfw_set_true);
await Response().Confirm(strs.nsfw_set_true).SendAsync();
}
[Cmd]
@@ -277,13 +277,13 @@ public partial class Administration : NadekoModule<AdministrationService>
var botPerms = ((SocketGuild)ctx.Guild).CurrentUser.GetPermissions(channel);
if (!userPerms.Has(ChannelPermission.ManageMessages))
{
await ReplyErrorLocalizedAsync(strs.insuf_perms_u);
await Response().Error(strs.insuf_perms_u).SendAsync();
return;
}
if (!botPerms.Has(ChannelPermission.ViewChannel))
{
await ReplyErrorLocalizedAsync(strs.insuf_perms_i);
await Response().Error(strs.insuf_perms_i).SendAsync();
return;
}
@@ -312,13 +312,13 @@ public partial class Administration : NadekoModule<AdministrationService>
var botPerms = ((SocketGuild)ctx.Guild).CurrentUser.GetPermissions(channel);
if (!userPerms.Has(ChannelPermission.ManageMessages))
{
await ReplyErrorLocalizedAsync(strs.insuf_perms_u);
await Response().Error(strs.insuf_perms_u).SendAsync();
return;
}
if (!botPerms.Has(ChannelPermission.ManageMessages))
{
await ReplyErrorLocalizedAsync(strs.insuf_perms_i);
await Response().Error(strs.insuf_perms_i).SendAsync();
return;
}
@@ -326,7 +326,7 @@ public partial class Administration : NadekoModule<AdministrationService>
var msg = await channel.GetMessageAsync(messageId);
if (msg is null)
{
await ReplyErrorLocalizedAsync(strs.msg_not_found);
await Response().Error(strs.msg_not_found).SendAsync();
return;
}
@@ -342,7 +342,7 @@ public partial class Administration : NadekoModule<AdministrationService>
}
else
{
await ReplyErrorLocalizedAsync(strs.time_too_long);
await Response().Error(strs.time_too_long).SendAsync();
return;
}
@@ -373,7 +373,7 @@ public partial class Administration : NadekoModule<AdministrationService>
if (t is null)
{
await ReplyErrorLocalizedAsync(strs.not_found);
await Response().Error(strs.not_found).SendAsync();
return;
}
@@ -387,7 +387,7 @@ public partial class Administration : NadekoModule<AdministrationService>
{
if (ctx.Channel.GetChannelType() != ChannelType.News)
{
await ReplyErrorLocalizedAsync(strs.req_announcement_channel);
await Response().Error(strs.req_announcement_channel).SendAsync();
return;
}
@@ -395,11 +395,11 @@ public partial class Administration : NadekoModule<AdministrationService>
if (newState)
{
await ReplyConfirmLocalizedAsync(strs.autopublish_enable);
await Response().Confirm(strs.autopublish_enable).SendAsync();
}
else
{
await ReplyConfirmLocalizedAsync(strs.autopublish_disable);
await Response().Confirm(strs.autopublish_disable).SendAsync();
}
}
}

View File

@@ -21,17 +21,17 @@ public partial class Administration
// the user can't aar the role which is higher or equal to his highest role
if (ctx.User.Id != guser.Guild.OwnerId && guser.GetRoles().Max(x => x.Position) <= role.Position)
{
await ReplyErrorLocalizedAsync(strs.hierarchy);
await Response().Error(strs.hierarchy).SendAsync();
return;
}
var roles = await _service.ToggleAarAsync(ctx.Guild.Id, role.Id);
if (roles.Count == 0)
await ReplyConfirmLocalizedAsync(strs.aar_disabled);
await Response().Confirm(strs.aar_disabled).SendAsync();
else if (roles.Contains(role.Id))
await AutoAssignRole();
else
await ReplyConfirmLocalizedAsync(strs.aar_role_removed(Format.Bold(role.ToString())));
await Response().Confirm(strs.aar_role_removed(Format.Bold(role.ToString()))).SendAsync();
}
[Cmd]
@@ -42,7 +42,7 @@ public partial class Administration
{
if (!_service.TryGetRoles(ctx.Guild.Id, out var roles))
{
await ReplyConfirmLocalizedAsync(strs.aar_none);
await Response().Confirm(strs.aar_none).SendAsync();
return;
}
@@ -51,8 +51,10 @@ public partial class Administration
if (existing.Count != roles.Count)
await _service.SetAarRolesAsync(ctx.Guild.Id, existing.Select(x => x.Id));
await ReplyConfirmLocalizedAsync(strs.aar_roles(
'\n' + existing.Select(x => Format.Bold(x.ToString())).Join(",\n")));
await Response()
.Confirm(strs.aar_roles(
'\n' + existing.Select(x => Format.Bold(x.ToString())).Join(",\n")))
.SendAsync();
}
}
}

View File

@@ -41,9 +41,9 @@ public partial class Administration
var items = result.Results.Skip(cur * 20).Take(20).ToList();
if (!items.Any())
return _eb.Create().WithErrorColor().WithFooter(sql).WithDescription("-");
return new EmbedBuilder().WithErrorColor().WithFooter(sql).WithDescription("-");
return _eb.Create()
return new EmbedBuilder()
.WithOkColor()
.WithFooter(sql)
.WithTitle(string.Join(" ║ ", result.ColumnNames))
@@ -99,7 +99,7 @@ public partial class Administration
{
try
{
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithTitle(GetText(strs.sql_confirm_exec))
.WithDescription(Format.Code(sql));
@@ -107,11 +107,11 @@ public partial class Administration
return;
var res = await _ds.ExecuteSql(sql);
await SendConfirmAsync(res.ToString());
await Response().Confirm(res.ToString()).SendAsync();
}
catch (Exception ex)
{
await SendErrorAsync(ex.ToString());
await Response().Error(ex.ToString()).SendAsync();
}
}
@@ -119,7 +119,7 @@ public partial class Administration
[OwnerOnly]
public async Task PurgeUser(ulong userId)
{
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithDescription(GetText(strs.purge_user_confirm(Format.Bold(userId.ToString()))));
if (!await PromptUserConfirmAsync(embed))

View File

@@ -18,18 +18,18 @@ public partial class Administration
if (vch is null)
{
await ReplyErrorLocalizedAsync(strs.not_in_voice);
await Response().Error(strs.not_in_voice).SendAsync();
return;
}
var id = _service.ToggleGameVoiceChannel(ctx.Guild.Id, vch.Id);
if (id is null)
await ReplyConfirmLocalizedAsync(strs.gvc_disabled);
await Response().Confirm(strs.gvc_disabled).SendAsync();
else
{
_service.GameVoiceChannels.Add(vch.Id);
await ReplyConfirmLocalizedAsync(strs.gvc_enabled(Format.Bold(vch.Name)));
await Response().Confirm(strs.gvc_enabled(Format.Bold(vch.Name))).SendAsync();
}
}
}

View File

@@ -13,9 +13,9 @@ public partial class Administration
var enabled = await _service.ToggleBoost(ctx.Guild.Id, ctx.Channel.Id);
if (enabled)
await ReplyConfirmLocalizedAsync(strs.boost_on);
await Response().Confirm(strs.boost_on).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.boost_off);
await Response().Pending(strs.boost_off).SendAsync();
}
[Cmd]
@@ -29,9 +29,9 @@ public partial class Administration
await _service.SetBoostDel(ctx.Guild.Id, timer);
if (timer > 0)
await ReplyConfirmLocalizedAsync(strs.boostdel_on(timer));
await Response().Confirm(strs.boostdel_on(timer)).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.boostdel_off);
await Response().Pending(strs.boostdel_off).SendAsync();
}
[Cmd]
@@ -42,15 +42,15 @@ public partial class Administration
if (string.IsNullOrWhiteSpace(text))
{
var boostMessage = _service.GetBoostMessage(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.boostmsg_cur(boostMessage?.SanitizeMentions()));
await Response().Confirm(strs.boostmsg_cur(boostMessage?.SanitizeMentions())).SendAsync();
return;
}
var sendBoostEnabled = _service.SetBoostMessage(ctx.Guild.Id, ref text);
await ReplyConfirmLocalizedAsync(strs.boostmsg_new);
await Response().Confirm(strs.boostmsg_new).SendAsync();
if (!sendBoostEnabled)
await ReplyPendingLocalizedAsync(strs.boostmsg_enable($"`{prefix}boost`"));
await Response().Pending(strs.boostmsg_enable($"`{prefix}boost`")).SendAsync();
}
[Cmd]
@@ -64,9 +64,9 @@ public partial class Administration
await _service.SetGreetDel(ctx.Guild.Id, timer);
if (timer > 0)
await ReplyConfirmLocalizedAsync(strs.greetdel_on(timer));
await Response().Confirm(strs.greetdel_on(timer)).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.greetdel_off);
await Response().Pending(strs.greetdel_off).SendAsync();
}
[Cmd]
@@ -77,9 +77,9 @@ public partial class Administration
var enabled = await _service.SetGreet(ctx.Guild.Id, ctx.Channel.Id);
if (enabled)
await ReplyConfirmLocalizedAsync(strs.greet_on);
await Response().Confirm(strs.greet_on).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.greet_off);
await Response().Pending(strs.greet_off).SendAsync();
}
[Cmd]
@@ -90,16 +90,16 @@ public partial class Administration
if (string.IsNullOrWhiteSpace(text))
{
var greetMsg = _service.GetGreetMsg(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.greetmsg_cur(greetMsg?.SanitizeMentions()));
await Response().Confirm(strs.greetmsg_cur(greetMsg?.SanitizeMentions())).SendAsync();
return;
}
var sendGreetEnabled = _service.SetGreetMessage(ctx.Guild.Id, ref text);
await ReplyConfirmLocalizedAsync(strs.greetmsg_new);
await Response().Confirm(strs.greetmsg_new).SendAsync();
if (!sendGreetEnabled)
await ReplyPendingLocalizedAsync(strs.greetmsg_enable($"`{prefix}greet`"));
await Response().Pending(strs.greetmsg_enable($"`{prefix}greet`")).SendAsync();
}
[Cmd]
@@ -110,9 +110,9 @@ public partial class Administration
var enabled = await _service.SetGreetDm(ctx.Guild.Id);
if (enabled)
await ReplyConfirmLocalizedAsync(strs.greetdm_on);
await Response().Confirm(strs.greetdm_on).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.greetdm_off);
await Response().Confirm(strs.greetdm_off).SendAsync();
}
[Cmd]
@@ -123,15 +123,15 @@ public partial class Administration
if (string.IsNullOrWhiteSpace(text))
{
var dmGreetMsg = _service.GetDmGreetMsg(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.greetdmmsg_cur(dmGreetMsg?.SanitizeMentions()));
await Response().Confirm(strs.greetdmmsg_cur(dmGreetMsg?.SanitizeMentions())).SendAsync();
return;
}
var sendGreetEnabled = _service.SetGreetDmMessage(ctx.Guild.Id, ref text);
await ReplyConfirmLocalizedAsync(strs.greetdmmsg_new);
await Response().Confirm(strs.greetdmmsg_new).SendAsync();
if (!sendGreetEnabled)
await ReplyPendingLocalizedAsync(strs.greetdmmsg_enable($"`{prefix}greetdm`"));
await Response().Pending(strs.greetdmmsg_enable($"`{prefix}greetdm`")).SendAsync();
}
[Cmd]
@@ -142,9 +142,9 @@ public partial class Administration
var enabled = await _service.SetBye(ctx.Guild.Id, ctx.Channel.Id);
if (enabled)
await ReplyConfirmLocalizedAsync(strs.bye_on);
await Response().Confirm(strs.bye_on).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.bye_off);
await Response().Confirm(strs.bye_off).SendAsync();
}
[Cmd]
@@ -155,15 +155,15 @@ public partial class Administration
if (string.IsNullOrWhiteSpace(text))
{
var byeMsg = _service.GetByeMessage(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.byemsg_cur(byeMsg?.SanitizeMentions()));
await Response().Confirm(strs.byemsg_cur(byeMsg?.SanitizeMentions())).SendAsync();
return;
}
var sendByeEnabled = _service.SetByeMessage(ctx.Guild.Id, ref text);
await ReplyConfirmLocalizedAsync(strs.byemsg_new);
await Response().Confirm(strs.byemsg_new).SendAsync();
if (!sendByeEnabled)
await ReplyPendingLocalizedAsync(strs.byemsg_enable($"`{prefix}bye`"));
await Response().Pending(strs.byemsg_enable($"`{prefix}bye`")).SendAsync();
}
[Cmd]
@@ -174,9 +174,9 @@ public partial class Administration
await _service.SetByeDel(ctx.Guild.Id, timer);
if (timer > 0)
await ReplyConfirmLocalizedAsync(strs.byedel_on(timer));
await Response().Confirm(strs.byedel_on(timer)).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.byedel_off);
await Response().Pending(strs.byedel_off).SendAsync();
}
@@ -191,7 +191,7 @@ public partial class Administration
await _service.ByeTest((ITextChannel)ctx.Channel, user);
var enabled = _service.GetByeEnabled(ctx.Guild.Id);
if (!enabled)
await ReplyPendingLocalizedAsync(strs.byemsg_enable($"`{prefix}bye`"));
await Response().Pending(strs.byemsg_enable($"`{prefix}bye`")).SendAsync();
}
[Cmd]
@@ -205,7 +205,7 @@ public partial class Administration
await _service.GreetTest((ITextChannel)ctx.Channel, user);
var enabled = _service.GetGreetEnabled(ctx.Guild.Id);
if (!enabled)
await ReplyPendingLocalizedAsync(strs.greetmsg_enable($"`{prefix}greet`"));
await Response().Pending(strs.greetmsg_enable($"`{prefix}greet`")).SendAsync();
}
[Cmd]
@@ -223,7 +223,7 @@ public partial class Administration
await ctx.WarningAsync();
var enabled = _service.GetGreetDmEnabled(ctx.Guild.Id);
if (!enabled)
await ReplyPendingLocalizedAsync(strs.greetdmmsg_enable($"`{prefix}greetdm`"));
await Response().Pending(strs.greetdmmsg_enable($"`{prefix}greetdm`")).SendAsync();
}
}
}

View File

@@ -42,8 +42,8 @@ public partial class Administration
[RequireContext(ContextType.Guild)]
[Priority(0)]
public async Task LanguageSet()
=> await ReplyConfirmLocalizedAsync(strs.lang_set_show(Format.Bold(Culture.ToString()),
Format.Bold(Culture.NativeName)));
=> await Response().Confirm(strs.lang_set_show(Format.Bold(Culture.ToString()),
Format.Bold(Culture.NativeName))).SendAsync();
[Cmd]
[RequireContext(ContextType.Guild)]
@@ -68,11 +68,11 @@ public partial class Administration
var nativeName = ci.NativeName;
if (ci.Name == "ts-TS")
nativeName = _supportedLocales[ci.Name];
await ReplyConfirmLocalizedAsync(strs.lang_set(Format.Bold(ci.ToString()), Format.Bold(nativeName)));
await Response().Confirm(strs.lang_set(Format.Bold(ci.ToString()), Format.Bold(nativeName))).SendAsync();
}
catch (Exception)
{
await ReplyErrorLocalizedAsync(strs.lang_set_fail);
await Response().Error(strs.lang_set_fail).SendAsync();
}
}
@@ -80,7 +80,7 @@ public partial class Administration
public async Task LanguageSetDefault()
{
var cul = _localization.DefaultCultureInfo;
await ReplyErrorLocalizedAsync(strs.lang_set_bot_show(cul, cul.NativeName));
await Response().Error(strs.lang_set_bot_show(cul, cul.NativeName)).SendAsync();
}
[Cmd]
@@ -101,23 +101,23 @@ public partial class Administration
_localization.SetDefaultCulture(ci);
}
await ReplyConfirmLocalizedAsync(strs.lang_set_bot(Format.Bold(ci.ToString()),
Format.Bold(ci.NativeName)));
await Response().Confirm(strs.lang_set_bot(Format.Bold(ci.ToString()),
Format.Bold(ci.NativeName))).SendAsync();
}
catch (Exception)
{
await ReplyErrorLocalizedAsync(strs.lang_set_fail);
await Response().Error(strs.lang_set_fail).SendAsync();
}
}
[Cmd]
public async Task LanguagesList()
=> await EmbedAsync(_eb.Create()
=> await Response().Embed(new EmbedBuilder()
.WithOkColor()
.WithTitle(GetText(strs.lang_list))
.WithDescription(string.Join("\n",
_supportedLocales.Select(
x => $"{Format.Code(x.Key),-10} => {x.Value}"))));
x => $"{Format.Code(x.Key),-10} => {x.Value}")))).SendAsync();
}
}
/* list of language codes for reference.

View File

@@ -16,7 +16,7 @@ public partial class Administration
if (runnerUser.Id != ctx.Guild.OwnerId
&& runnerUserRoles.Max(x => x.Position) <= targetUserRoles.Max(x => x.Position))
{
await ReplyErrorLocalizedAsync(strs.mute_perms);
await Response().Error(strs.mute_perms).SendAsync();
return false;
}
@@ -31,20 +31,20 @@ public partial class Administration
if (role is null)
{
var muteRole = await _service.GetMuteRole(ctx.Guild);
await ReplyConfirmLocalizedAsync(strs.mute_role(Format.Code(muteRole.Name)));
await Response().Confirm(strs.mute_role(Format.Code(muteRole.Name))).SendAsync();
return;
}
if (ctx.User.Id != ctx.Guild.OwnerId
&& role.Position >= ((SocketGuildUser)ctx.User).Roles.Max(x => x.Position))
{
await ReplyErrorLocalizedAsync(strs.insuf_perms_u);
await Response().Error(strs.insuf_perms_u).SendAsync();
return;
}
await _service.SetMuteRoleAsync(ctx.Guild.Id, role.Name);
await ReplyConfirmLocalizedAsync(strs.mute_role_set);
await Response().Confirm(strs.mute_role_set).SendAsync();
}
[Cmd]
@@ -59,12 +59,12 @@ public partial class Administration
return;
await _service.MuteUser(target, ctx.User, reason: reason);
await ReplyConfirmLocalizedAsync(strs.user_muted(Format.Bold(target.ToString())));
await Response().Confirm(strs.user_muted(Format.Bold(target.ToString()))).SendAsync();
}
catch (Exception ex)
{
Log.Warning(ex, "Exception in the mute command");
await ReplyErrorLocalizedAsync(strs.mute_error);
await Response().Error(strs.mute_error).SendAsync();
}
}
@@ -82,13 +82,13 @@ public partial class Administration
return;
await _service.TimedMute(user, ctx.User, time.Time, reason: reason);
await ReplyConfirmLocalizedAsync(strs.user_muted_time(Format.Bold(user.ToString()),
(int)time.Time.TotalMinutes));
await Response().Confirm(strs.user_muted_time(Format.Bold(user.ToString()),
(int)time.Time.TotalMinutes)).SendAsync();
}
catch (Exception ex)
{
Log.Warning(ex, "Error in mute command");
await ReplyErrorLocalizedAsync(strs.mute_error);
await Response().Error(strs.mute_error).SendAsync();
}
}
@@ -100,11 +100,11 @@ public partial class Administration
try
{
await _service.UnmuteUser(user.GuildId, user.Id, ctx.User, reason: reason);
await ReplyConfirmLocalizedAsync(strs.user_unmuted(Format.Bold(user.ToString())));
await Response().Confirm(strs.user_unmuted(Format.Bold(user.ToString()))).SendAsync();
}
catch
{
await ReplyErrorLocalizedAsync(strs.mute_error);
await Response().Error(strs.mute_error).SendAsync();
}
}
@@ -120,12 +120,12 @@ public partial class Administration
return;
await _service.MuteUser(user, ctx.User, MuteType.Chat, reason);
await ReplyConfirmLocalizedAsync(strs.user_chat_mute(Format.Bold(user.ToString())));
await Response().Confirm(strs.user_chat_mute(Format.Bold(user.ToString()))).SendAsync();
}
catch (Exception ex)
{
Log.Warning(ex, "Exception in the chatmute command");
await ReplyErrorLocalizedAsync(strs.mute_error);
await Response().Error(strs.mute_error).SendAsync();
}
}
@@ -143,13 +143,13 @@ public partial class Administration
return;
await _service.TimedMute(user, ctx.User, time.Time, MuteType.Chat, reason);
await ReplyConfirmLocalizedAsync(strs.user_chat_mute_time(Format.Bold(user.ToString()),
(int)time.Time.TotalMinutes));
await Response().Confirm(strs.user_chat_mute_time(Format.Bold(user.ToString()),
(int)time.Time.TotalMinutes)).SendAsync();
}
catch (Exception ex)
{
Log.Warning(ex, "Error in chatmute command");
await ReplyErrorLocalizedAsync(strs.mute_error);
await Response().Error(strs.mute_error).SendAsync();
}
}
@@ -161,11 +161,11 @@ public partial class Administration
try
{
await _service.UnmuteUser(user.Guild.Id, user.Id, ctx.User, MuteType.Chat, reason);
await ReplyConfirmLocalizedAsync(strs.user_chat_unmute(Format.Bold(user.ToString())));
await Response().Confirm(strs.user_chat_unmute(Format.Bold(user.ToString()))).SendAsync();
}
catch
{
await ReplyErrorLocalizedAsync(strs.mute_error);
await Response().Error(strs.mute_error).SendAsync();
}
}
@@ -181,11 +181,11 @@ public partial class Administration
return;
await _service.MuteUser(user, ctx.User, MuteType.Voice, reason);
await ReplyConfirmLocalizedAsync(strs.user_voice_mute(Format.Bold(user.ToString())));
await Response().Confirm(strs.user_voice_mute(Format.Bold(user.ToString()))).SendAsync();
}
catch
{
await ReplyErrorLocalizedAsync(strs.mute_error);
await Response().Error(strs.mute_error).SendAsync();
}
}
@@ -203,12 +203,12 @@ public partial class Administration
return;
await _service.TimedMute(user, ctx.User, time.Time, MuteType.Voice, reason);
await ReplyConfirmLocalizedAsync(strs.user_voice_mute_time(Format.Bold(user.ToString()),
(int)time.Time.TotalMinutes));
await Response().Confirm(strs.user_voice_mute_time(Format.Bold(user.ToString()),
(int)time.Time.TotalMinutes)).SendAsync();
}
catch
{
await ReplyErrorLocalizedAsync(strs.mute_error);
await Response().Error(strs.mute_error).SendAsync();
}
}
@@ -220,11 +220,11 @@ public partial class Administration
try
{
await _service.UnmuteUser(user.GuildId, user.Id, ctx.User, MuteType.Voice, reason);
await ReplyConfirmLocalizedAsync(strs.user_voice_unmute(Format.Bold(user.ToString())));
await Response().Confirm(strs.user_voice_unmute(Format.Bold(user.ToString()))).SendAsync();
}
catch
{
await ReplyErrorLocalizedAsync(strs.mute_error);
await Response().Error(strs.mute_error).SendAsync();
}
}
}

View File

@@ -122,7 +122,7 @@ public class MuteService : INService
if (string.IsNullOrWhiteSpace(reason))
return;
_ = Task.Run(() => user.SendMessageAsync(embed: _eb.Create()
_ = Task.Run(() => user.SendMessageAsync(embed: new EmbedBuilder()
.WithDescription(
$"You've been muted in {user.Guild} server")
.AddField("Mute Type", type.ToString())
@@ -140,7 +140,7 @@ public class MuteService : INService
if (string.IsNullOrWhiteSpace(reason))
return;
_ = Task.Run(() => user.SendMessageAsync(embed: _eb.Create()
_ = Task.Run(() => user.SendMessageAsync(embed: new EmbedBuilder()
.WithDescription(
$"You've been unmuted in {user.Guild} server")
.AddField("Unmute Type", type.ToString())

View File

@@ -18,15 +18,15 @@ public partial class Administration
if (perms is null || perms.Length == 0)
{
await _service.RemoveOverride(ctx.Guild.Id, cmd.Name);
await ReplyConfirmLocalizedAsync(strs.perm_override_reset);
await Response().Confirm(strs.perm_override_reset).SendAsync();
return;
}
var aggregatePerms = perms.Aggregate((acc, seed) => seed | acc);
await _service.AddOverride(ctx.Guild.Id, cmd.Name, aggregatePerms);
await ReplyConfirmLocalizedAsync(strs.perm_override(Format.Bold(aggregatePerms.ToString()),
Format.Code(cmd.Name)));
await Response().Confirm(strs.perm_override(Format.Bold(aggregatePerms.ToString()),
Format.Code(cmd.Name))).SendAsync();
}
[Cmd]
@@ -34,7 +34,7 @@ public partial class Administration
[UserPerm(GuildPerm.Administrator)]
public async Task DiscordPermOverrideReset()
{
var result = await PromptUserConfirmAsync(_eb.Create()
var result = await PromptUserConfirmAsync(new EmbedBuilder()
.WithOkColor()
.WithDescription(GetText(strs.perm_override_all_confirm)));
@@ -43,7 +43,7 @@ public partial class Administration
await _service.ClearAllOverrides(ctx.Guild.Id);
await ReplyConfirmLocalizedAsync(strs.perm_override_all);
await Response().Confirm(strs.perm_override_all).SendAsync();
}
[Cmd]
@@ -59,7 +59,7 @@ public partial class Administration
await ctx.SendPaginatedConfirmAsync(page,
curPage =>
{
var eb = _eb.Create().WithTitle(GetText(strs.perm_overrides)).WithOkColor();
var eb = new EmbedBuilder().WithTitle(GetText(strs.perm_overrides)).WithOkColor();
var thisPageOverrides = overrides.Skip(9 * curPage).Take(9).ToList();

View File

@@ -13,9 +13,9 @@ public partial class Administration
public async Task RotatePlaying()
{
if (_service.ToggleRotatePlaying())
await ReplyConfirmLocalizedAsync(strs.ropl_enabled);
await Response().Confirm(strs.ropl_enabled).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.ropl_disabled);
await Response().Confirm(strs.ropl_disabled).SendAsync();
}
[Cmd]
@@ -24,7 +24,7 @@ public partial class Administration
{
await _service.AddPlaying(t, status);
await ReplyConfirmLocalizedAsync(strs.ropl_added);
await Response().Confirm(strs.ropl_added).SendAsync();
}
[Cmd]
@@ -34,12 +34,14 @@ public partial class Administration
var statuses = _service.GetRotatingStatuses();
if (!statuses.Any())
await ReplyErrorLocalizedAsync(strs.ropl_not_set);
await Response().Error(strs.ropl_not_set).SendAsync();
else
{
var i = 1;
await ReplyConfirmLocalizedAsync(strs.ropl_list(string.Join("\n\t",
statuses.Select(rs => $"`{i++}.` *{rs.Type}* {rs.Status}"))));
await Response()
.Confirm(strs.ropl_list(string.Join("\n\t",
statuses.Select(rs => $"`{i++}.` *{rs.Type}* {rs.Status}"))))
.SendAsync();
}
}
@@ -54,7 +56,7 @@ public partial class Administration
if (msg is null)
return;
await ReplyConfirmLocalizedAsync(strs.reprm(msg));
await Response().Confirm(strs.reprm(msg)).SendAsync();
}
}
}

View File

@@ -14,7 +14,7 @@ public partial class Administration
[Cmd]
[Priority(1)]
public async Task Prefix()
=> await ReplyConfirmLocalizedAsync(strs.prefix_current(Format.Code(_cmdHandler.GetPrefix(ctx.Guild))));
=> await Response().Confirm(strs.prefix_current(Format.Code(_cmdHandler.GetPrefix(ctx.Guild)))).SendAsync();
[Cmd]
[RequireContext(ContextType.Guild)]
@@ -35,7 +35,7 @@ public partial class Administration
var oldPrefix = prefix;
var newPrefix = _cmdHandler.SetPrefix(ctx.Guild, toSet);
await ReplyConfirmLocalizedAsync(strs.prefix_new(Format.Code(oldPrefix), Format.Code(newPrefix)));
await Response().Confirm(strs.prefix_new(Format.Code(oldPrefix), Format.Code(newPrefix))).SendAsync();
}
[Cmd]
@@ -44,14 +44,14 @@ public partial class Administration
{
if (string.IsNullOrWhiteSpace(toSet))
{
await ReplyConfirmLocalizedAsync(strs.defprefix_current(_cmdHandler.GetPrefix()));
await Response().Confirm(strs.defprefix_current(_cmdHandler.GetPrefix())).SendAsync();
return;
}
var oldPrefix = _cmdHandler.GetPrefix();
var newPrefix = _cmdHandler.SetDefaultPrefix(toSet);
await ReplyConfirmLocalizedAsync(strs.defprefix_new(Format.Code(oldPrefix), Format.Code(newPrefix)));
await Response().Confirm(strs.defprefix_new(Format.Code(oldPrefix), Format.Code(newPrefix))).SendAsync();
}
}
}

View File

@@ -17,11 +17,11 @@ public partial class Administration
{
if (await _service.TryStopAntiAlt(ctx.Guild.Id))
{
await ReplyConfirmLocalizedAsync(strs.prot_disable("Anti-Alt"));
await Response().Confirm(strs.prot_disable("Anti-Alt")).SendAsync();
return;
}
await ReplyConfirmLocalizedAsync(strs.protection_not_running("Anti-Alt"));
await Response().Confirm(strs.protection_not_running("Anti-Alt")).SendAsync();
}
[Cmd]
@@ -74,8 +74,8 @@ public partial class Administration
public Task AntiRaid()
{
if (_service.TryStopAntiRaid(ctx.Guild.Id))
return ReplyConfirmLocalizedAsync(strs.prot_disable("Anti-Raid"));
return ReplyPendingLocalizedAsync(strs.protection_not_running("Anti-Raid"));
return Response().Confirm(strs.prot_disable("Anti-Raid")).SendAsync();
return Response().Pending(strs.protection_not_running("Anti-Raid")).SendAsync();
}
[Cmd]
@@ -104,33 +104,33 @@ public partial class Administration
{
if (action == PunishmentAction.AddRole)
{
await ReplyErrorLocalizedAsync(strs.punishment_unsupported(action));
await Response().Error(strs.punishment_unsupported(action)).SendAsync();
return;
}
if (userThreshold is < 2 or > 30)
{
await ReplyErrorLocalizedAsync(strs.raid_cnt(2, 30));
await Response().Error(strs.raid_cnt(2, 30)).SendAsync();
return;
}
if (seconds is < 2 or > 300)
{
await ReplyErrorLocalizedAsync(strs.raid_time(2, 300));
await Response().Error(strs.raid_time(2, 300)).SendAsync();
return;
}
if (punishTime is not null)
{
if (!_service.IsDurationAllowed(action))
await ReplyErrorLocalizedAsync(strs.prot_cant_use_time);
await Response().Error(strs.prot_cant_use_time).SendAsync();
}
var time = (int?)punishTime?.Time.TotalMinutes ?? 0;
if (time is < 0 or > 60 * 24)
return;
if(action is PunishmentAction.TimeOut && time < 1)
if (action is PunishmentAction.TimeOut && time < 1)
return;
var stats = await _service.StartAntiRaidAsync(ctx.Guild.Id, userThreshold, seconds, action, time);
@@ -138,8 +138,10 @@ public partial class Administration
if (stats is null)
return;
await SendConfirmAsync(GetText(strs.prot_enable("Anti-Raid")),
$"{ctx.User.Mention} {GetAntiRaidString(stats)}");
await Response()
.Confirm(GetText(strs.prot_enable("Anti-Raid")),
$"{ctx.User.Mention} {GetAntiRaidString(stats)}")
.SendAsync();
}
[Cmd]
@@ -148,8 +150,8 @@ public partial class Administration
public Task AntiSpam()
{
if (_service.TryStopAntiSpam(ctx.Guild.Id))
return ReplyConfirmLocalizedAsync(strs.prot_disable("Anti-Spam"));
return ReplyPendingLocalizedAsync(strs.protection_not_running("Anti-Spam"));
return Response().Confirm(strs.prot_disable("Anti-Spam")).SendAsync();
return Response().Pending(strs.protection_not_running("Anti-Spam")).SendAsync();
}
[Cmd]
@@ -190,7 +192,7 @@ public partial class Administration
if (timeData is not null)
{
if (!_service.IsDurationAllowed(action))
await ReplyErrorLocalizedAsync(strs.prot_cant_use_time);
await Response().Error(strs.prot_cant_use_time).SendAsync();
}
var time = (int?)timeData?.Time.TotalMinutes ?? 0;
@@ -202,8 +204,10 @@ public partial class Administration
var stats = await _service.StartAntiSpamAsync(ctx.Guild.Id, messageCount, action, time, role?.Id);
await SendConfirmAsync(GetText(strs.prot_enable("Anti-Spam")),
$"{ctx.User.Mention} {GetAntiSpamString(stats)}");
await Response()
.Confirm(GetText(strs.prot_enable("Anti-Spam")),
$"{ctx.User.Mention} {GetAntiSpamString(stats)}")
.SendAsync();
}
[Cmd]
@@ -215,14 +219,14 @@ public partial class Administration
if (added is null)
{
await ReplyErrorLocalizedAsync(strs.protection_not_running("Anti-Spam"));
await Response().Error(strs.protection_not_running("Anti-Spam")).SendAsync();
return;
}
if (added.Value)
await ReplyConfirmLocalizedAsync(strs.spam_ignore("Anti-Spam"));
await Response().Confirm(strs.spam_ignore("Anti-Spam")).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.spam_not_ignore("Anti-Spam"));
await Response().Confirm(strs.spam_not_ignore("Anti-Spam")).SendAsync();
}
[Cmd]
@@ -233,11 +237,11 @@ public partial class Administration
if (spam is null && raid is null && alt is null)
{
await ReplyConfirmLocalizedAsync(strs.prot_none);
await Response().Confirm(strs.prot_none).SendAsync();
return;
}
var embed = _eb.Create().WithOkColor().WithTitle(GetText(strs.prot_active));
var embed = new EmbedBuilder().WithOkColor().WithTitle(GetText(strs.prot_active));
if (spam is not null)
embed.AddField("Anti-Spam", GetAntiSpamString(spam).TrimTo(1024), true);
@@ -248,7 +252,7 @@ public partial class Administration
if (alt is not null)
embed.AddField("Anti-Alt", GetAntiAltString(alt), true);
await ctx.Channel.EmbedAsync(embed);
await Response().Embed(embed).SendAsync();
}
private string GetAntiAltString(AntiAltStats alt)

View File

@@ -33,13 +33,13 @@ public partial class Administration
var msg = await ctx.Channel.GetMessageAsync(messageId);
if (msg is null)
{
await ReplyErrorLocalizedAsync(strs.not_found);
await Response().Error(strs.not_found).SendAsync();
return;
}
if (ctx.User.Id != ctx.Guild.OwnerId && ((IGuildUser)ctx.User).GetRoles().Max(x => x.Position) <= role.Position)
{
await ReplyErrorLocalizedAsync(strs.hierarchy);
await Response().Error(strs.hierarchy).SendAsync();
return;
}
@@ -58,8 +58,8 @@ public partial class Administration
{
_ = msg.RemoveReactionAsync(emote, ctx.Client.CurrentUser);
return !fl.IsPatronLimit
? ReplyErrorLocalizedAsync(strs.limit_reached(fl.Quota))
: ReplyPendingLocalizedAsync(strs.feature_limit_reached_owner(fl.Quota, fl.Name));
? Response().Error(strs.limit_reached(fl.Quota)).SendAsync()
: Response().Pending(strs.feature_limit_reached_owner(fl.Quota, fl.Name)).SendAsync();
});
}
@@ -76,7 +76,7 @@ public partial class Administration
await ctx.SendPaginatedConfirmAsync(page, curPage =>
{
var embed = _eb.Create(ctx)
var embed = new EmbedBuilder()
.WithOkColor();
var content = string.Empty;

View File

@@ -36,13 +36,13 @@ public partial class Administration
{
await targetUser.AddRoleAsync(roleToAdd);
await ReplyConfirmLocalizedAsync(strs.setrole(Format.Bold(roleToAdd.Name),
Format.Bold(targetUser.ToString())));
await Response().Confirm(strs.setrole(Format.Bold(roleToAdd.Name),
Format.Bold(targetUser.ToString()))).SendAsync();
}
catch (Exception ex)
{
Log.Warning(ex, "Error in setrole command");
await ReplyErrorLocalizedAsync(strs.setrole_err);
await Response().Error(strs.setrole_err).SendAsync();
}
}
@@ -59,12 +59,12 @@ public partial class Administration
try
{
await targetUser.RemoveRoleAsync(roleToRemove);
await ReplyConfirmLocalizedAsync(strs.remrole(Format.Bold(roleToRemove.Name),
Format.Bold(targetUser.ToString())));
await Response().Confirm(strs.remrole(Format.Bold(roleToRemove.Name),
Format.Bold(targetUser.ToString()))).SendAsync();
}
catch
{
await ReplyErrorLocalizedAsync(strs.remrole_err);
await Response().Error(strs.remrole_err).SendAsync();
}
}
@@ -81,16 +81,16 @@ public partial class Administration
{
if (roleToEdit.Position > (await ctx.Guild.GetCurrentUserAsync()).GetRoles().Max(r => r.Position))
{
await ReplyErrorLocalizedAsync(strs.renrole_perms);
await Response().Error(strs.renrole_perms).SendAsync();
return;
}
await roleToEdit.ModifyAsync(g => g.Name = newname);
await ReplyConfirmLocalizedAsync(strs.renrole);
await Response().Confirm(strs.renrole).SendAsync();
}
catch (Exception)
{
await ReplyErrorLocalizedAsync(strs.renrole_err);
await Response().Error(strs.renrole_err).SendAsync();
}
}
@@ -111,11 +111,11 @@ public partial class Administration
try
{
await user.RemoveRolesAsync(userRoles);
await ReplyConfirmLocalizedAsync(strs.rar(Format.Bold(user.ToString())));
await Response().Confirm(strs.rar(Format.Bold(user.ToString()))).SendAsync();
}
catch (Exception)
{
await ReplyErrorLocalizedAsync(strs.rar_err);
await Response().Error(strs.rar_err).SendAsync();
}
}
@@ -129,7 +129,7 @@ public partial class Administration
return;
var r = await ctx.Guild.CreateRoleAsync(roleName, isMentionable: false);
await ReplyConfirmLocalizedAsync(strs.cr(Format.Bold(r.Name)));
await Response().Confirm(strs.cr(Format.Bold(r.Name))).SendAsync();
}
[Cmd]
@@ -143,7 +143,7 @@ public partial class Administration
return;
await role.DeleteAsync();
await ReplyConfirmLocalizedAsync(strs.dr(Format.Bold(role.Name)));
await Response().Confirm(strs.dr(Format.Bold(role.Name))).SendAsync();
}
[Cmd]
@@ -155,16 +155,16 @@ public partial class Administration
var newHoisted = !role.IsHoisted;
await role.ModifyAsync(r => r.Hoist = newHoisted);
if (newHoisted)
await ReplyConfirmLocalizedAsync(strs.rolehoist_enabled(Format.Bold(role.Name)));
await Response().Confirm(strs.rolehoist_enabled(Format.Bold(role.Name))).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.rolehoist_disabled(Format.Bold(role.Name)));
await Response().Confirm(strs.rolehoist_disabled(Format.Bold(role.Name))).SendAsync();
}
[Cmd]
[RequireContext(ContextType.Guild)]
[Priority(1)]
public async Task RoleColor([Leftover] IRole role)
=> await SendConfirmAsync("Role Color", role.Color.RawValue.ToString("x6"));
=> await Response().Confirm("Role Color", role.Color.RawValue.ToString("x6")).SendAsync();
[Cmd]
[RequireContext(ContextType.Guild)]
@@ -177,11 +177,11 @@ public partial class Administration
{
var rgba32 = color.ToPixel<Rgba32>();
await role.ModifyAsync(r => r.Color = new Discord.Color(rgba32.R, rgba32.G, rgba32.B));
await ReplyConfirmLocalizedAsync(strs.rc(Format.Bold(role.Name)));
await Response().Confirm(strs.rc(Format.Bold(role.Name))).SendAsync();
}
catch (Exception)
{
await ReplyErrorLocalizedAsync(strs.rc_perms);
await Response().Error(strs.rc_perms).SendAsync();
}
}
@@ -195,11 +195,11 @@ public partial class Administration
if (newState)
{
await ReplyConfirmLocalizedAsync(strs.sticky_roles_enabled);
await Response().Confirm(strs.sticky_roles_enabled).SendAsync();
}
else
{
await ReplyConfirmLocalizedAsync(strs.sticky_roles_disabled);
await Response().Confirm(strs.sticky_roles_disabled).SendAsync();
}
}
}

View File

@@ -78,7 +78,7 @@ public sealed class CheckForUpdatesService : INService, IReadyExecutor
if (user is null)
return;
var eb = _ebs.Create()
var eb = new EmbedBuilder()
.WithOkColor()
.WithAuthor($"NadekoBot v{latestVersion} Released!")
.WithTitle("Changelog")

View File

@@ -50,22 +50,22 @@ public partial class Administration
public async Task CacheUsers(IGuild guild)
{
var downloadUsersTask = guild.DownloadUsersAsync();
var message = await ReplyPendingLocalizedAsync(strs.cache_users_pending);
var message = await Response().Pending(strs.cache_users_pending).SendAsync();
using var dbContext = _db.GetDbContext();
await downloadUsersTask;
var users = (await guild.GetUsersAsync(CacheMode.CacheOnly))
.Cast<IUser>()
.ToList();
.Cast<IUser>()
.ToList();
var (added, updated) = await _service.RefreshUsersAsync(users);
await message.ModifyAsync(x =>
x.Embed = _eb.Create()
.WithDescription(GetText(strs.cache_users_done(added, updated)))
.WithOkColor()
.Build()
x.Embed = new EmbedBuilder()
.WithDescription(GetText(strs.cache_users_done(added, updated)))
.WithOkColor()
.Build()
);
}
@@ -76,16 +76,17 @@ public partial class Administration
if (ctx.User is not IGuildUser { GuildPermissions.Administrator: true })
return;
if (ctx.Guild is SocketGuild sg && ctx.Channel is ISocketMessageChannel ch
if (ctx.Guild is SocketGuild sg
&& ctx.Channel is ISocketMessageChannel ch
&& ctx.Message is SocketUserMessage msg)
{
var fakeMessage = new DoAsUserMessage(msg, user, message);
await _cmdHandler.TryRunCommand(sg, ch, fakeMessage);
}
else
{
await ReplyErrorLocalizedAsync(strs.error_occured);
await Response().Error(strs.error_occured).SendAsync();
}
}
@@ -112,14 +113,14 @@ public partial class Administration
};
_service.AddNewAutoCommand(cmd);
await EmbedAsync(_eb.Create()
.WithOkColor()
.WithTitle(GetText(strs.scadd))
.AddField(GetText(strs.server),
cmd.GuildId is null ? "-" : $"{cmd.GuildName}/{cmd.GuildId}",
true)
.AddField(GetText(strs.channel), $"{cmd.ChannelName}/{cmd.ChannelId}", true)
.AddField(GetText(strs.command_text), cmdText));
await Response().Embed(new EmbedBuilder()
.WithOkColor()
.WithTitle(GetText(strs.scadd))
.AddField(GetText(strs.server),
cmd.GuildId is null ? "-" : $"{cmd.GuildName}/{cmd.GuildId}",
true)
.AddField(GetText(strs.channel), $"{cmd.ChannelName}/{cmd.ChannelId}", true)
.AddField(GetText(strs.command_text), cmdText)).SendAsync();
}
[Cmd]
@@ -148,7 +149,7 @@ public partial class Administration
};
_service.AddNewAutoCommand(cmd);
await ReplyConfirmLocalizedAsync(strs.autocmd_add(Format.Code(Format.Sanitize(cmdText)), cmd.Interval));
await Response().Confirm(strs.autocmd_add(Format.Code(Format.Sanitize(cmdText)), cmd.Interval)).SendAsync();
}
[Cmd]
@@ -162,18 +163,20 @@ public partial class Administration
var scmds = _service.GetStartupCommands().Skip(page * 5).Take(5).ToList();
if (scmds.Count == 0)
await ReplyErrorLocalizedAsync(strs.startcmdlist_none);
await Response().Error(strs.startcmdlist_none).SendAsync();
else
{
var i = 0;
await SendConfirmAsync(text: string.Join("\n",
scmds.Select(x => $@"```css
await Response()
.Confirm(text: string.Join("\n",
scmds.Select(x => $@"```css
#{++i + (page * 5)}
[{GetText(strs.server)}]: {(x.GuildId.HasValue ? $"{x.GuildName} #{x.GuildId}" : "-")}
[{GetText(strs.channel)}]: {x.ChannelName} #{x.ChannelId}
[{GetText(strs.command_text)}]: {x.CommandText}```")),
title: string.Empty,
footer: GetText(strs.page(page + 1)));
title: string.Empty,
footer: GetText(strs.page(page + 1)))
.SendAsync();
}
}
@@ -187,19 +190,21 @@ public partial class Administration
var scmds = _service.GetAutoCommands().Skip(page * 5).Take(5).ToList();
if (!scmds.Any())
await ReplyErrorLocalizedAsync(strs.autocmdlist_none);
await Response().Error(strs.autocmdlist_none).SendAsync();
else
{
var i = 0;
await SendConfirmAsync(text: string.Join("\n",
scmds.Select(x => $@"```css
await Response()
.Confirm(text: string.Join("\n",
scmds.Select(x => $@"```css
#{++i + (page * 5)}
[{GetText(strs.server)}]: {(x.GuildId.HasValue ? $"{x.GuildName} #{x.GuildId}" : "-")}
[{GetText(strs.channel)}]: {x.ChannelName} #{x.ChannelId}
{GetIntervalText(x.Interval)}
[{GetText(strs.command_text)}]: {x.CommandText}```")),
title: string.Empty,
footer: GetText(strs.page(page + 1)));
title: string.Empty,
footer: GetText(strs.page(page + 1)))
.SendAsync();
}
}
@@ -215,7 +220,7 @@ public partial class Administration
ctx.Message.DeleteAfter(0);
try
{
var msg = await SendConfirmAsync($"⏲ {miliseconds}ms");
var msg = await Response().Confirm($"⏲ {miliseconds}ms").SendAsync();
msg.DeleteAfter(miliseconds / 1000);
}
catch { }
@@ -231,7 +236,7 @@ public partial class Administration
{
if (!_service.RemoveAutoCommand(--index, out _))
{
await ReplyErrorLocalizedAsync(strs.acrm_fail);
await Response().Error(strs.acrm_fail).SendAsync();
return;
}
@@ -244,9 +249,9 @@ public partial class Administration
public async Task StartupCommandRemove([Leftover] int index)
{
if (!_service.RemoveStartupCommand(--index, out _))
await ReplyErrorLocalizedAsync(strs.scrm_fail);
await Response().Error(strs.scrm_fail).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.scrm);
await Response().Confirm(strs.scrm).SendAsync();
}
[Cmd]
@@ -257,7 +262,7 @@ public partial class Administration
{
_service.ClearStartupCommands();
await ReplyConfirmLocalizedAsync(strs.startcmds_cleared);
await Response().Confirm(strs.startcmds_cleared).SendAsync();
}
[Cmd]
@@ -267,9 +272,9 @@ public partial class Administration
var enabled = _service.ForwardMessages();
if (enabled)
await ReplyConfirmLocalizedAsync(strs.fwdm_start);
await Response().Confirm(strs.fwdm_start).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.fwdm_stop);
await Response().Pending(strs.fwdm_stop).SendAsync();
}
[Cmd]
@@ -279,9 +284,9 @@ public partial class Administration
var enabled = _service.ForwardToAll();
if (enabled)
await ReplyConfirmLocalizedAsync(strs.fwall_start);
await Response().Confirm(strs.fwall_start).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.fwall_stop);
await Response().Pending(strs.fwall_stop).SendAsync();
}
[Cmd]
@@ -292,9 +297,9 @@ public partial class Administration
var enabled = _service.ForwardToChannel(ctx.Channel.Id);
if (enabled)
await ReplyConfirmLocalizedAsync(strs.fwch_start);
await Response().Confirm(strs.fwch_start).SendAsync();
else
await ReplyPendingLocalizedAsync(strs.fwch_stop);
await Response().Pending(strs.fwch_stop).SendAsync();
}
[Cmd]
@@ -331,7 +336,7 @@ public partial class Administration
if (string.IsNullOrWhiteSpace(str))
str = GetText(strs.no_shards_on_page);
return _eb.Create().WithOkColor().WithDescription($"{status}\n\n{str}");
return new EmbedBuilder().WithOkColor().WithDescription($"{status}\n\n{str}");
},
allShardStrings.Length,
25);
@@ -355,9 +360,9 @@ public partial class Administration
{
var success = _coord.RestartShard(shardId);
if (success)
await ReplyConfirmLocalizedAsync(strs.shard_reconnecting(Format.Bold("#" + shardId)));
await Response().Confirm(strs.shard_reconnecting(Format.Bold("#" + shardId))).SendAsync();
else
await ReplyErrorLocalizedAsync(strs.no_shard_id);
await Response().Error(strs.no_shard_id).SendAsync();
}
[Cmd]
@@ -393,7 +398,7 @@ public partial class Administration
}
}
await ReplyConfirmLocalizedAsync(strs.deleted_x_servers(toLeave.Count));
await Response().Confirm(strs.deleted_x_servers(toLeave.Count)).SendAsync();
}
[Cmd]
@@ -403,8 +408,8 @@ public partial class Administration
try
{
await _client.SetStatusAsync(UserStatus.Invisible);
_ = _client.StopAsync();
await ReplyConfirmLocalizedAsync(strs.shutting_down);
_ = _client.StopAsync();
await Response().Confirm(strs.shutting_down).SendAsync();
}
catch
{
@@ -422,11 +427,11 @@ public partial class Administration
var success = _coord.RestartBot();
if (!success)
{
await ReplyErrorLocalizedAsync(strs.restart_fail);
await Response().Error(strs.restart_fail).SendAsync();
return;
}
try { await ReplyConfirmLocalizedAsync(strs.restarting); }
try { await Response().Confirm(strs.restarting).SendAsync(); }
catch { }
}
@@ -446,7 +451,7 @@ public partial class Administration
Log.Warning("You've been ratelimited. Wait 2 hours to change your name");
}
await ReplyConfirmLocalizedAsync(strs.bot_name(Format.Bold(newName)));
await Response().Confirm(strs.bot_name(Format.Bold(newName))).SendAsync();
}
[Cmd]
@@ -460,7 +465,7 @@ public partial class Administration
var curUser = await ctx.Guild.GetCurrentUserAsync();
await curUser.ModifyAsync(u => u.Nickname = newNick);
await ReplyConfirmLocalizedAsync(strs.bot_nick(Format.Bold(newNick) ?? "-"));
await Response().Confirm(strs.bot_nick(Format.Bold(newNick) ?? "-")).SendAsync();
}
[Cmd]
@@ -473,13 +478,15 @@ public partial class Administration
if (sg.OwnerId == gu.Id
|| gu.GetRoles().Max(r => r.Position) >= sg.CurrentUser.GetRoles().Max(r => r.Position))
{
await ReplyErrorLocalizedAsync(strs.insuf_perms_i);
await Response().Error(strs.insuf_perms_i).SendAsync();
return;
}
await gu.ModifyAsync(u => u.Nickname = newNick);
await ReplyConfirmLocalizedAsync(strs.user_nick(Format.Bold(gu.ToString()), Format.Bold(newNick) ?? "-"));
await Response()
.Confirm(strs.user_nick(Format.Bold(gu.ToString()), Format.Bold(newNick) ?? "-"))
.SendAsync();
}
[Cmd]
@@ -488,7 +495,7 @@ public partial class Administration
{
await _client.SetStatusAsync(SettableUserStatusToUserStatus(status));
await ReplyConfirmLocalizedAsync(strs.bot_status(Format.Bold(status.ToString())));
await Response().Confirm(strs.bot_status(Format.Bold(status.ToString()))).SendAsync();
}
[Cmd]
@@ -498,9 +505,9 @@ public partial class Administration
var success = await _service.SetAvatar(img);
if (success)
await ReplyConfirmLocalizedAsync(strs.set_avatar);
await Response().Confirm(strs.set_avatar).SendAsync();
}
[Cmd]
[OwnerOnly]
public async Task SetBanner([Leftover] string img = null)
@@ -508,7 +515,7 @@ public partial class Administration
var success = await _service.SetBanner(img);
if (success)
await ReplyConfirmLocalizedAsync(strs.set_banner);
await Response().Confirm(strs.set_banner).SendAsync();
}
[Cmd]
@@ -520,7 +527,7 @@ public partial class Administration
var repCtx = new ReplacementContext(ctx);
await _service.SetGameAsync(game is null ? game : await repSvc.ReplaceAsync(game, repCtx), type);
await ReplyConfirmLocalizedAsync(strs.set_game);
await Response().Confirm(strs.set_game).SendAsync();
}
[Cmd]
@@ -531,7 +538,7 @@ public partial class Administration
await _service.SetStreamAsync(name, url);
await ReplyConfirmLocalizedAsync(strs.set_stream);
await Response().Confirm(strs.set_stream).SendAsync();
}
[Cmd]
@@ -574,11 +581,11 @@ public partial class Administration
}
else
{
await ReplyErrorLocalizedAsync(strs.invalid_format);
await Response().Error(strs.invalid_format).SendAsync();
return;
}
await ReplyConfirmLocalizedAsync(strs.message_sent);
await Response().Confirm(strs.message_sent).SendAsync();
}
[Cmd]
@@ -587,7 +594,7 @@ public partial class Administration
{
_strings.Reload();
await _medusaLoader.ReloadStrings();
await ReplyConfirmLocalizedAsync(strs.bot_strings_reloaded);
await Response().Confirm(strs.bot_strings_reloaded).SendAsync();
}
[Cmd]

View File

@@ -225,7 +225,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
{
try
{
await ownerCh.SendConfirmAsync(_eb, title, toSend);
await ownerCh.Response(_strings, _eb).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.SendConfirmAsync(_eb, title, toSend);
await ch.Response(_strings, _eb).Confirm(title, toSend).SendAsync();
}
catch
{
@@ -252,7 +252,7 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, INService
{
try
{
await firstOwnerChannel.SendConfirmAsync(_eb, title, toSend);
await firstOwnerChannel.Response(_strings, _eb).Confirm(title, toSend).SendAsync();
}
catch
{

View File

@@ -18,9 +18,9 @@ public partial class Administration
var newVal = _service.ToggleAdSarm(ctx.Guild.Id);
if (newVal)
await ReplyConfirmLocalizedAsync(strs.adsarm_enable(prefix));
await Response().Confirm(strs.adsarm_enable(prefix)).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.adsarm_disable(prefix));
await Response().Confirm(strs.adsarm_disable(prefix)).SendAsync();
}
[Cmd]
@@ -46,11 +46,12 @@ public partial class Administration
if (succ)
{
await ReplyConfirmLocalizedAsync(strs.role_added(Format.Bold(role.Name),
Format.Bold(@group.ToString())));
await Response()
.Confirm(strs.role_added(Format.Bold(role.Name), Format.Bold(group.ToString())))
.SendAsync();
}
else
await ReplyErrorLocalizedAsync(strs.role_in_list(Format.Bold(role.Name)));
await Response().Error(strs.role_in_list(Format.Bold(role.Name))).SendAsync();
}
[Cmd]
@@ -64,11 +65,12 @@ public partial class Administration
if (set)
{
await ReplyConfirmLocalizedAsync(
strs.group_name_added(Format.Bold(@group.ToString()), Format.Bold(name)));
await Response()
.Confirm(strs.group_name_added(Format.Bold(group.ToString()), Format.Bold(name)))
.SendAsync();
}
else
await ReplyConfirmLocalizedAsync(strs.group_name_removed(Format.Bold(group.ToString())));
await Response().Confirm(strs.group_name_removed(Format.Bold(group.ToString()))).SendAsync();
}
[Cmd]
@@ -82,9 +84,9 @@ public partial class Administration
var success = _service.RemoveSar(role.Guild.Id, role.Id);
if (!success)
await ReplyErrorLocalizedAsync(strs.self_assign_not);
await Response().Error(strs.self_assign_not).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.self_assign_rem(Format.Bold(role.Name)));
await Response().Confirm(strs.self_assign_rem(Format.Bold(role.Name))).SendAsync();
}
[Cmd]
@@ -133,7 +135,7 @@ public partial class Administration
rolesStr.AppendLine();
}
return _eb.Create()
return new EmbedBuilder()
.WithOkColor()
.WithTitle(Format.Bold(GetText(strs.self_assign_list(roles.Count()))))
.WithDescription(rolesStr.ToString())
@@ -153,9 +155,9 @@ public partial class Administration
{
var areExclusive = _service.ToggleEsar(ctx.Guild.Id);
if (areExclusive)
await ReplyConfirmLocalizedAsync(strs.self_assign_excl);
await Response().Confirm(strs.self_assign_excl).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.self_assign_no_excl);
await Response().Confirm(strs.self_assign_no_excl).SendAsync();
}
[Cmd]
@@ -171,12 +173,14 @@ public partial class Administration
if (!succ)
{
await ReplyErrorLocalizedAsync(strs.self_assign_not);
await Response().Error(strs.self_assign_not).SendAsync();
return;
}
await ReplyConfirmLocalizedAsync(strs.self_assign_level_req(Format.Bold(role.Name),
Format.Bold(level.ToString())));
await Response()
.Confirm(strs.self_assign_level_req(Format.Bold(role.Name),
Format.Bold(level.ToString())))
.SendAsync();
}
[Cmd]
@@ -189,15 +193,15 @@ public partial class Administration
IUserMessage msg;
if (result == SelfAssignedRolesService.AssignResult.ErrNotAssignable)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_not);
msg = await Response().Error(strs.self_assign_not).SendAsync();
else if (result == SelfAssignedRolesService.AssignResult.ErrLvlReq)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_not_level(Format.Bold(extra.ToString())));
msg = await Response().Error(strs.self_assign_not_level(Format.Bold(extra.ToString()))).SendAsync();
else if (result == SelfAssignedRolesService.AssignResult.ErrAlreadyHave)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_already(Format.Bold(role.Name)));
msg = await Response().Error(strs.self_assign_already(Format.Bold(role.Name))).SendAsync();
else if (result == SelfAssignedRolesService.AssignResult.ErrNotPerms)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_perms);
msg = await Response().Error(strs.self_assign_perms).SendAsync();
else
msg = await ReplyConfirmLocalizedAsync(strs.self_assign_success(Format.Bold(role.Name)));
msg = await Response().Confirm(strs.self_assign_success(Format.Bold(role.Name))).SendAsync();
if (autoDelete)
{
@@ -216,13 +220,13 @@ public partial class Administration
IUserMessage msg;
if (result == SelfAssignedRolesService.RemoveResult.ErrNotAssignable)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_not);
msg = await Response().Error(strs.self_assign_not).SendAsync();
else if (result == SelfAssignedRolesService.RemoveResult.ErrNotHave)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_not_have(Format.Bold(role.Name)));
msg = await Response().Error(strs.self_assign_not_have(Format.Bold(role.Name))).SendAsync();
else if (result == SelfAssignedRolesService.RemoveResult.ErrNotPerms)
msg = await ReplyErrorLocalizedAsync(strs.self_assign_perms);
msg = await Response().Error(strs.self_assign_perms).SendAsync();
else
msg = await ReplyConfirmLocalizedAsync(strs.self_assign_remove(Format.Bold(role.Name)));
msg = await Response().Confirm(strs.self_assign_remove(Format.Bold(role.Name))).SendAsync();
if (autoDelete)
{

View File

@@ -27,6 +27,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
private readonly ConcurrentHashSet<ulong> _ignoreMessageIds = new();
private readonly UserPunishService _punishService;
private readonly IMessageSenderService _sender;
public LogCommandService(
DiscordSocketClient client,
@@ -37,7 +38,8 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
GuildTimezoneService tz,
IMemoryCache memoryCache,
IEmbedBuilderService eb,
UserPunishService punishService)
UserPunishService punishService,
IMessageSenderService sender)
{
_client = client;
_memoryCache = memoryCache;
@@ -48,6 +50,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
_prot = prot;
_tz = tz;
_punishService = punishService;
_sender = sender;
using (var uow = db.GetDbContext())
{
@@ -165,7 +168,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
var title = GetText(logChannel.Guild, strs.thread_deleted);
await logChannel.EmbedAsync(_eb.Create()
await logChannel.EmbedAsync(new EmbedBuilder()
.WithOkColor()
.WithTitle("🗑 " + title)
.WithDescription($"{ch.Name} | {ch.Id}")
@@ -195,7 +198,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
var title = GetText(logChannel.Guild, strs.thread_created);
await logChannel.EmbedAsync(_eb.Create()
await logChannel.EmbedAsync(new EmbedBuilder()
.WithOkColor()
.WithTitle("🆕 " + title)
.WithDescription($"{ch.Name} | {ch.Id}")
@@ -229,16 +232,16 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
{
var keys = PresenceUpdates.Keys.ToList();
await keys.Select(key =>
await keys.Select(channel =>
{
if (!((SocketGuild)key.Guild).CurrentUser.GetPermissions(key).SendMessages)
if (!((SocketGuild)channel.Guild).CurrentUser.GetPermissions(channel).SendMessages)
return Task.CompletedTask;
if (PresenceUpdates.TryRemove(key, out var msgs))
if (PresenceUpdates.TryRemove(channel, out var msgs))
{
var title = GetText(key.Guild, strs.presence_updates);
var title = GetText(channel.Guild, strs.presence_updates);
var desc = string.Join(Environment.NewLine, msgs);
return key.SendConfirmAsync(_eb, title, desc.TrimTo(2048)!);
return _sender.Response(channel).Confirm(title, desc.TrimTo(2048)!).SendAsync();
}
return Task.CompletedTask;
@@ -328,7 +331,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
if ((logChannel = await TryGetLogChannel(g, logSetting, LogType.UserWarned)) is null)
return;
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithOkColor()
.WithTitle($"⚠️ User Warned")
.WithDescription($"<@{arg.UserId}> | {arg.UserId}")
@@ -357,7 +360,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
if ((logChannel = await TryGetLogChannel(g, logSetting, LogType.UserUpdated)) is null)
return;
var embed = _eb.Create();
var embed = new EmbedBuilder();
if (before.Username != after.Username)
{
@@ -542,7 +545,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
break;
}
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithAuthor(mutes)
.WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
.WithFooter(CurrentTime(usr.Guild))
@@ -589,7 +592,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
break;
}
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithAuthor(mutes)
.WithTitle($"{usr.Username}#{usr.Discriminator} | {usr.Id}")
.WithFooter($"{CurrentTime(usr.Guild)}")
@@ -643,7 +646,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
break;
}
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithAuthor($"🛡 Anti-{protection}")
.WithTitle(GetText(logChannel.Guild, strs.users) + " " + punishment)
.WithDescription(string.Join("\n", users.Select(u => u.ToString())))
@@ -696,7 +699,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
if (logSetting.UserUpdatedId is not null
&& (logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.UserUpdated)) is not null)
{
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithOkColor()
.WithFooter(CurrentTime(before.Guild))
.WithTitle($"{before.Username}#{before.Discriminator} | {before.Id}");
@@ -767,7 +770,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
if ((logChannel = await TryGetLogChannel(before.Guild, logSetting, LogType.ChannelUpdated)) is null)
return;
var embed = _eb.Create().WithOkColor().WithFooter(CurrentTime(before.Guild));
var embed = new EmbedBuilder().WithOkColor().WithFooter(CurrentTime(before.Guild));
var beforeTextChannel = cbefore as ITextChannel;
var afterTextChannel = cafter as ITextChannel;
@@ -823,7 +826,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
else
title = GetText(logChannel.Guild, strs.text_chan_destroyed);
await logChannel.EmbedAsync(_eb.Create()
await logChannel.EmbedAsync(new EmbedBuilder()
.WithOkColor()
.WithTitle("🆕 " + title)
.WithDescription($"{ch.Name} | {ch.Id}")
@@ -859,7 +862,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
else
title = GetText(logChannel.Guild, strs.text_chan_created);
await logChannel.EmbedAsync(_eb.Create()
await logChannel.EmbedAsync(new EmbedBuilder()
.WithOkColor()
.WithTitle("🆕 " + title)
.WithDescription($"{ch.Name} | {ch.Id}")
@@ -962,7 +965,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
ITextChannel? logChannel;
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserLeft)) is null)
return;
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithOkColor()
.WithTitle("❌ " + GetText(logChannel.Guild, strs.user_left))
.WithDescription(usr.ToString())
@@ -995,7 +998,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
if ((logChannel = await TryGetLogChannel(usr.Guild, logSetting, LogType.UserJoined)) is null)
return;
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithOkColor()
.WithTitle("✅ " + GetText(logChannel.Guild, strs.user_joined))
.WithDescription($"{usr.Mention} `{usr}`")
@@ -1036,7 +1039,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
ITextChannel? logChannel;
if ((logChannel = await TryGetLogChannel(guild, logSetting, LogType.UserUnbanned)) is null)
return;
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithOkColor()
.WithTitle("♻️ " + GetText(logChannel.Guild, strs.user_unbanned))
.WithDescription(usr.ToString()!)
@@ -1083,7 +1086,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
{
}
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithOkColor()
.WithTitle("🚫 " + GetText(logChannel.Guild, strs.user_banned))
.WithDescription(usr.ToString()!)
@@ -1134,7 +1137,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
return;
var resolvedMessage = msg.Resolve(TagHandling.FullName);
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithOkColor()
.WithTitle("🗑 "
+ GetText(logChannel.Guild, strs.msg_del(((ITextChannel)msg.Channel).Name)))
@@ -1194,7 +1197,7 @@ public sealed class LogCommandService : ILogCommandService, IReadyExecutor
|| logChannel.Id == after.Channel.Id)
return;
var embed = _eb.Create()
var embed = new EmbedBuilder()
.WithOkColor()
.WithTitle("📝 "
+ GetText(logChannel.Guild,

View File

@@ -17,9 +17,9 @@ public partial class Administration
{
await _service.LogServer(ctx.Guild.Id, ctx.Channel.Id, action.Value);
if (action.Value)
await ReplyConfirmLocalizedAsync(strs.log_all);
await Response().Confirm(strs.log_all).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.log_disabled);
await Response().Confirm(strs.log_disabled).SendAsync();
}
[Cmd]
@@ -35,7 +35,7 @@ public partial class Administration
var usrs = settings?.LogIgnores.Where(x => x.ItemType == IgnoredItemType.User).ToList()
?? new List<IgnoredLogItem>();
var eb = _eb.Create(ctx)
var eb = new EmbedBuilder()
.WithOkColor()
.AddField(GetText(strs.log_ignored_channels),
chs.Count == 0
@@ -46,7 +46,7 @@ public partial class Administration
? "-"
: string.Join('\n', usrs.Select(x => $"{x.LogItemId} | <@{x.LogItemId}>")));
await EmbedAsync(eb);
await Response().Embed(eb).SendAsync();
}
[Cmd]
@@ -59,13 +59,17 @@ public partial class Administration
if (!removed)
{
await ReplyConfirmLocalizedAsync(
strs.log_ignore_chan(Format.Bold(target.Mention + "(" + target.Id + ")")));
await Response()
.Confirm(
strs.log_ignore_chan(Format.Bold(target.Mention + "(" + target.Id + ")")))
.SendAsync();
}
else
{
await ReplyConfirmLocalizedAsync(
strs.log_not_ignore_chan(Format.Bold(target.Mention + "(" + target.Id + ")")));
await Response()
.Confirm(
strs.log_not_ignore_chan(Format.Bold(target.Mention + "(" + target.Id + ")")))
.SendAsync();
}
}
@@ -79,13 +83,15 @@ public partial class Administration
if (!removed)
{
await ReplyConfirmLocalizedAsync(
strs.log_ignore_user(Format.Bold(target.Mention + "(" + target.Id + ")")));
await Response()
.Confirm(strs.log_ignore_user(Format.Bold(target.Mention + "(" + target.Id + ")")))
.SendAsync();
}
else
{
await ReplyConfirmLocalizedAsync(
strs.log_not_ignore_user(Format.Bold(target.Mention + "(" + target.Id + ")")));
await Response()
.Confirm(strs.log_not_ignore_user(Format.Bold(target.Mention + "(" + target.Id + ")")))
.SendAsync();
}
}
@@ -106,7 +112,7 @@ public partial class Administration
return Format.Bold(x);
}));
await SendConfirmAsync(Format.Bold(GetText(strs.log_events)) + "\n" + str);
await Response().Confirm(Format.Bold(GetText(strs.log_events)) + "\n" + str).SendAsync();
}
private static ulong? GetLogProperty(LogSetting l, LogType type)
@@ -163,9 +169,9 @@ public partial class Administration
var val = _service.Log(ctx.Guild.Id, ctx.Channel.Id, type);
if (val)
await ReplyConfirmLocalizedAsync(strs.log(Format.Bold(type.ToString())));
await Response().Confirm(strs.log(Format.Bold(type.ToString()))).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.log_stop(Format.Bold(type.ToString())));
await Response().Confirm(strs.log_stop(Format.Bold(type.ToString()))).SendAsync();
}
}
}

View File

@@ -37,7 +37,7 @@ public partial class Administration
await ctx.SendPaginatedConfirmAsync(page,
curPage => _eb.Create()
curPage => new EmbedBuilder()
.WithOkColor()
.WithTitle(GetText(strs.timezones_available))
.WithDescription(string.Join("\n",
@@ -49,7 +49,7 @@ public partial class Administration
[Cmd]
[RequireContext(ContextType.Guild)]
public async Task Timezone()
=> await ReplyConfirmLocalizedAsync(strs.timezone_guild(_service.GetTimeZoneOrUtc(ctx.Guild.Id)));
=> await Response().Confirm(strs.timezone_guild(_service.GetTimeZoneOrUtc(ctx.Guild.Id))).SendAsync();
[Cmd]
[RequireContext(ContextType.Guild)]
@@ -63,13 +63,13 @@ public partial class Administration
if (tz is null)
{
await ReplyErrorLocalizedAsync(strs.timezone_not_found);
await Response().Error(strs.timezone_not_found).SendAsync();
return;
}
_service.SetTimeZone(ctx.Guild.Id, tz);
await SendConfirmAsync(tz.ToString());
await Response().Confirm(tz.ToString()).SendAsync();
}
}
}

View File

@@ -38,7 +38,7 @@ public partial class Administration
|| (ctx.User.Id != ownerId && targetMaxRole >= modMaxRole)
|| target.Id == ownerId)
{
await ReplyErrorLocalizedAsync(strs.hierarchy);
await Response().Error(strs.hierarchy).SendAsync();
return false;
}
@@ -65,7 +65,7 @@ public partial class Administration
var dmFailed = false;
try
{
await user.EmbedAsync(_eb.Create()
await user.EmbedAsync(new EmbedBuilder()
.WithErrorColor()
.WithDescription(GetText(strs.warned_on(ctx.Guild.ToString())))
.AddField(GetText(strs.moderator), ctx.User.ToString())
@@ -84,16 +84,16 @@ public partial class Administration
catch (Exception ex)
{
Log.Warning(ex, "Exception occured while warning a user");
var errorEmbed = _eb.Create().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));
await ctx.Channel.EmbedAsync(errorEmbed);
await Response().Embed(errorEmbed).SendAsync();
return;
}
var embed = _eb.Create().WithOkColor();
var embed = new EmbedBuilder().WithOkColor();
if (punishment is null)
embed.WithDescription(GetText(strs.user_warned(Format.Bold(user.ToString()))));
else
@@ -105,7 +105,7 @@ public partial class Administration
if (dmFailed)
embed.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
await ctx.Channel.EmbedAsync(embed);
await Response().Embed(embed).SendAsync();
}
[Cmd]
@@ -118,9 +118,9 @@ public partial class Administration
var expireDays = await _service.GetWarnExpire(ctx.Guild.Id);
if (expireDays == 0)
await ReplyConfirmLocalizedAsync(strs.warns_dont_expire);
await Response().Confirm(strs.warns_dont_expire).SendAsync();
else
await ReplyErrorLocalizedAsync(strs.warns_expire_in(expireDays));
await Response().Error(strs.warns_expire_in(expireDays)).SendAsync();
}
[Cmd]
@@ -140,14 +140,14 @@ public partial class Administration
await _service.WarnExpireAsync(ctx.Guild.Id, days, opts.Delete);
if (days == 0)
{
await ReplyConfirmLocalizedAsync(strs.warn_expire_reset);
await Response().Confirm(strs.warn_expire_reset).SendAsync();
return;
}
if (opts.Delete)
await ReplyConfirmLocalizedAsync(strs.warn_expire_set_delete(Format.Bold(days.ToString())));
await Response().Confirm(strs.warn_expire_set_delete(Format.Bold(days.ToString()))).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.warn_expire_set_clear(Format.Bold(days.ToString())));
await Response().Confirm(strs.warn_expire_set_clear(Format.Bold(days.ToString()))).SendAsync();
}
[Cmd]
@@ -200,7 +200,7 @@ public partial class Administration
var warnings = allWarnings.Skip(page * 9).Take(9).ToArray();
var user = (ctx.Guild as SocketGuild)?.GetUser(userId)?.ToString() ?? userId.ToString();
var embed = _eb.Create().WithOkColor().WithTitle(GetText(strs.warnlog_for(user)));
var embed = new EmbedBuilder().WithOkColor().WithTitle(GetText(strs.warnlog_for(user)));
if (!warnings.Any())
embed.WithDescription(GetText(strs.warnings_none));
@@ -260,7 +260,7 @@ public partial class Administration
+ $" | {total} ({all} - {forgiven})";
});
return _eb.Create()
return new EmbedBuilder()
.WithOkColor()
.WithTitle(GetText(strs.warnings_list))
.WithDescription(string.Join("\n", ws));
@@ -285,13 +285,13 @@ public partial class Administration
var success = await _service.WarnClearAsync(ctx.Guild.Id, userId, index, ctx.User.ToString());
var userStr = Format.Bold((ctx.Guild as SocketGuild)?.GetUser(userId)?.ToString() ?? userId.ToString());
if (index == 0)
await ReplyErrorLocalizedAsync(strs.warnings_cleared(userStr));
await Response().Error(strs.warnings_cleared(userStr)).SendAsync();
else
{
if (success)
await ReplyConfirmLocalizedAsync(strs.warning_cleared(Format.Bold(index.ToString()), userStr));
await Response().Confirm(strs.warning_cleared(Format.Bold(index.ToString()), userStr)).SendAsync();
else
await ReplyErrorLocalizedAsync(strs.warning_clear_fail);
await Response().Error(strs.warning_clear_fail).SendAsync();
}
}
@@ -310,7 +310,7 @@ public partial class Administration
if (ctx.Guild.OwnerId != ctx.User.Id
&& role.Position >= ((IGuildUser)ctx.User).GetRoles().Max(x => x.Position))
{
await ReplyErrorLocalizedAsync(strs.role_too_high);
await Response().Error(strs.role_too_high).SendAsync();
return;
}
@@ -321,14 +321,18 @@ public partial class Administration
if (time is null)
{
await ReplyConfirmLocalizedAsync(strs.warn_punish_set(Format.Bold(punish.ToString()),
Format.Bold(number.ToString())));
await Response()
.Confirm(strs.warn_punish_set(Format.Bold(punish.ToString()),
Format.Bold(number.ToString())))
.SendAsync();
}
else
{
await ReplyConfirmLocalizedAsync(strs.warn_punish_set_timed(Format.Bold(punish.ToString()),
Format.Bold(number.ToString()),
Format.Bold(time.Input)));
await Response()
.Confirm(strs.warn_punish_set_timed(Format.Bold(punish.ToString()),
Format.Bold(number.ToString()),
Format.Bold(time.Input)))
.SendAsync();
}
}
@@ -353,14 +357,18 @@ public partial class Administration
if (time is null)
{
await ReplyConfirmLocalizedAsync(strs.warn_punish_set(Format.Bold(punish.ToString()),
Format.Bold(number.ToString())));
await Response()
.Confirm(strs.warn_punish_set(Format.Bold(punish.ToString()),
Format.Bold(number.ToString())))
.SendAsync();
}
else
{
await ReplyConfirmLocalizedAsync(strs.warn_punish_set_timed(Format.Bold(punish.ToString()),
Format.Bold(number.ToString()),
Format.Bold(time.Input)));
await Response()
.Confirm(strs.warn_punish_set_timed(Format.Bold(punish.ToString()),
Format.Bold(number.ToString()),
Format.Bold(time.Input)))
.SendAsync();
}
}
@@ -372,7 +380,7 @@ public partial class Administration
if (!_service.WarnPunishRemove(ctx.Guild.Id, number))
return;
await ReplyConfirmLocalizedAsync(strs.warn_punish_rem(Format.Bold(number.ToString())));
await Response().Confirm(strs.warn_punish_rem(Format.Bold(number.ToString()))).SendAsync();
}
[Cmd]
@@ -391,7 +399,7 @@ public partial class Administration
else
list = GetText(strs.warnpl_none);
await SendConfirmAsync(GetText(strs.warn_punish_list), list);
await Response().Confirm(GetText(strs.warn_punish_list), list).SendAsync();
}
[Cmd]
@@ -401,7 +409,7 @@ public partial class Administration
[Priority(1)]
public Task Ban(StoopidTime time, IUser user, [Leftover] string msg = null)
=> Ban(time, user.Id, msg);
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.BanMembers)]
@@ -413,7 +421,7 @@ public partial class Administration
return;
var guildUser = await ((DiscordSocketClient)Context.Client).Rest.GetGuildUserAsync(ctx.Guild.Id, userId);
if (guildUser is not null && !await CheckRoleHierarchy(guildUser))
return;
@@ -438,10 +446,10 @@ public partial class Administration
var user = await ctx.Client.GetUserAsync(userId);
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 = _eb.Create()
var toSend = new EmbedBuilder()
.WithOkColor()
.WithTitle("⛔️ " + GetText(strs.banned_user))
.AddField(GetText(strs.username), user?.ToString() ?? userId.ToString(), true)
.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),
@@ -450,7 +458,7 @@ public partial class Administration
if (dmFailed)
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
await ctx.Channel.EmbedAsync(toSend);
await Response().Embed(toSend).SendAsync();
}
[Cmd]
@@ -466,7 +474,7 @@ public partial class Administration
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
await ctx.Guild.AddBanAsync(userId, banPrune, (ctx.User + " | " + msg).TrimTo(512));
await ctx.Channel.EmbedAsync(_eb.Create()
await ctx.Channel.EmbedAsync(new EmbedBuilder()
.WithOkColor()
.WithTitle("⛔️ " + GetText(strs.banned_user))
.AddField("ID", userId.ToString(), true));
@@ -502,7 +510,7 @@ public partial class Administration
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
await ctx.Guild.AddBanAsync(user, banPrune, (ctx.User + " | " + msg).TrimTo(512));
var toSend = _eb.Create()
var toSend = new EmbedBuilder()
.WithOkColor()
.WithTitle("⛔️ " + GetText(strs.banned_user))
.AddField(GetText(strs.username), user.ToString(), true)
@@ -511,7 +519,7 @@ public partial class Administration
if (dmFailed)
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
await ctx.Channel.EmbedAsync(toSend);
await Response().Embed(toSend).SendAsync();
}
[Cmd]
@@ -522,16 +530,16 @@ public partial class Administration
{
if (days < 0 || days > 7)
{
await ReplyErrorLocalizedAsync(strs.invalid_input);
await Response().Error(strs.invalid_input).SendAsync();
return;
}
await _service.SetBanPruneAsync(ctx.Guild.Id, days);
if (days == 0)
await ReplyConfirmLocalizedAsync(strs.ban_prune_disabled);
await Response().Confirm(strs.ban_prune_disabled).SendAsync();
else
await ReplyConfirmLocalizedAsync(strs.ban_prune(days));
await Response().Confirm(strs.ban_prune(days)).SendAsync();
}
[Cmd]
@@ -545,11 +553,11 @@ public partial class Administration
var template = _service.GetBanTemplate(ctx.Guild.Id);
if (template is null)
{
await ReplyConfirmLocalizedAsync(strs.banmsg_default);
await Response().Confirm(strs.banmsg_default).SendAsync();
return;
}
await SendConfirmAsync(template);
await Response().Confirm(template).SendAsync();
return;
}
@@ -586,10 +594,14 @@ 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, (IGuildUser)ctx.User, defaultMessage, reason, duration);
var embed = await _service.GetBanUserDmEmbed(Context,
(IGuildUser)ctx.User,
defaultMessage,
reason,
duration);
if (embed is null)
await ConfirmLocalizedAsync(strs.banmsg_disabled);
await Response().Confirm(strs.banmsg_disabled).SendAsync();
else
{
try
@@ -598,7 +610,7 @@ public partial class Administration
}
catch (Exception)
{
await ReplyErrorLocalizedAsync(strs.unable_to_dm_user);
await Response().Error(strs.unable_to_dm_user).SendAsync();
return;
}
@@ -618,7 +630,7 @@ public partial class Administration
if (bun is null)
{
await ReplyErrorLocalizedAsync(strs.user_not_found);
await Response().Error(strs.user_not_found).SendAsync();
return;
}
@@ -635,7 +647,7 @@ public partial class Administration
if (bun is null)
{
await ReplyErrorLocalizedAsync(strs.user_not_found);
await Response().Error(strs.user_not_found).SendAsync();
return;
}
@@ -646,7 +658,7 @@ public partial class Administration
{
await ctx.Guild.RemoveBanAsync(user);
await ReplyConfirmLocalizedAsync(strs.unbanned_user(Format.Bold(user.ToString())));
await Response().Confirm(strs.unbanned_user(Format.Bold(user.ToString()))).SendAsync();
}
[Cmd]
@@ -678,7 +690,10 @@ public partial class Administration
try
{
await user.SendErrorAsync(_eb, GetText(strs.sbdm(Format.Bold(ctx.Guild.Name), msg)));
await Response()
.Channel(await user.CreateDMChannelAsync())
.Error(GetText(strs.sbdm(Format.Bold(ctx.Guild.Name), msg)))
.SendAsync();
}
catch
{
@@ -690,7 +705,7 @@ public partial class Administration
try { await ctx.Guild.RemoveBanAsync(user); }
catch { await ctx.Guild.RemoveBanAsync(user); }
var toSend = _eb.Create()
var toSend = new EmbedBuilder()
.WithOkColor()
.WithTitle("☣ " + GetText(strs.sb_user))
.AddField(GetText(strs.username), user.ToString(), true)
@@ -699,7 +714,7 @@ public partial class Administration
if (dmFailed)
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
await ctx.Channel.EmbedAsync(toSend);
await Response().Embed(toSend).SendAsync();
}
[Cmd]
@@ -733,7 +748,10 @@ public partial class Administration
try
{
await user.SendErrorAsync(_eb, GetText(strs.kickdm(Format.Bold(ctx.Guild.Name), msg)));
await Response()
.Channel(await user.CreateDMChannelAsync())
.Error(GetText(strs.kickdm(Format.Bold(ctx.Guild.Name), msg)))
.SendAsync();
}
catch
{
@@ -742,7 +760,7 @@ public partial class Administration
await user.KickAsync((ctx.User + " | " + msg).TrimTo(512));
var toSend = _eb.Create()
var toSend = new EmbedBuilder()
.WithOkColor()
.WithTitle(GetText(strs.kicked_user))
.AddField(GetText(strs.username), user.ToString(), true)
@@ -751,21 +769,21 @@ public partial class Administration
if (dmFailed)
toSend.WithFooter("⚠️ " + GetText(strs.unable_to_dm_user));
await ctx.Channel.EmbedAsync(toSend);
await Response().Embed(toSend).SendAsync();
}
[Cmd]
[RequireContext(ContextType.Guild)]
[UserPerm(GuildPerm.ModerateMembers)]
[BotPerm(GuildPerm.ModerateMembers)]
[Priority(2)]
public async Task Timeout(IUser globalUser, StoopidTime time, [Leftover] string msg = null)
public async Task Timeout(IUser globalUser, StoopidTime time, [Leftover] string msg = null)
{
var user = await ctx.Guild.GetUserAsync(globalUser.Id);
if (user is null)
return;
if (!await CheckRoleHierarchy(user))
return;
@@ -774,27 +792,27 @@ public partial class Administration
try
{
var dmMessage = GetText(strs.timeoutdm(Format.Bold(ctx.Guild.Name), msg));
await user.EmbedAsync(_eb.Create(ctx)
.WithPendingColor()
.WithDescription(dmMessage));
await user.EmbedAsync(new EmbedBuilder()
.WithPendingColor()
.WithDescription(dmMessage));
}
catch
{
dmFailed = true;
}
await user.SetTimeOutAsync(time.Time);
var toSend = _eb.Create()
.WithOkColor()
.WithTitle("⏳ " + GetText(strs.timedout_user))
.AddField(GetText(strs.username), user.ToString(), true)
.AddField("ID", user.Id.ToString(), true);
var toSend = new EmbedBuilder()
.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));
await ctx.Channel.EmbedAsync(toSend);
await Response().Embed(toSend).SendAsync();
}
[Cmd]
@@ -846,12 +864,12 @@ public partial class Administration
if (string.IsNullOrWhiteSpace(missStr))
missStr = "-";
var toSend = _eb.Create(ctx)
var toSend = new EmbedBuilder()
.WithDescription(GetText(strs.mass_ban_in_progress(banning.Count)))
.AddField(GetText(strs.invalid(missing.Count)), missStr)
.WithPendingColor();
var banningMessage = await ctx.Channel.EmbedAsync(toSend);
var banningMessage = await Response().Embed(toSend).SendAsync();
var banPrune = await _service.GetBanPruneAsync(ctx.Guild.Id) ?? 7;
foreach (var toBan in banning)
@@ -866,7 +884,7 @@ public partial class Administration
}
}
await banningMessage.ModifyAsync(x => x.Embed = _eb.Create()
await banningMessage.ModifyAsync(x => x.Embed = new EmbedBuilder()
.WithDescription(
GetText(strs.mass_ban_completed(banning.Count())))
.AddField(GetText(strs.invalid(missing.Count)), missStr)
@@ -891,7 +909,7 @@ public partial class Administration
missStr = "-";
//send a message but don't wait for it
var banningMessageTask = ctx.Channel.EmbedAsync(_eb.Create()
var banningMessageTask = ctx.Channel.EmbedAsync(new EmbedBuilder()
.WithDescription(
GetText(strs.mass_kill_in_progress(bans.Count())))
.AddField(GetText(strs.invalid(missing)), missStr)
@@ -911,7 +929,7 @@ public partial class Administration
//wait for the message and edit it
var banningMessage = await banningMessageTask;
await banningMessage.ModifyAsync(x => x.Embed = _eb.Create()
await banningMessage.ModifyAsync(x => x.Embed = new EmbedBuilder()
.WithDescription(
GetText(strs.mass_kill_completed(bans.Count())))
.AddField(GetText(strs.invalid(missing)), missStr)

View File

@@ -15,9 +15,9 @@ public partial class Administration
public async Task VcRoleRm(ulong vcId)
{
if (_service.RemoveVcRole(ctx.Guild.Id, vcId))
await ReplyConfirmLocalizedAsync(strs.vcrole_removed(Format.Bold(vcId.ToString())));
await Response().Confirm(strs.vcrole_removed(Format.Bold(vcId.ToString()))).SendAsync();
else
await ReplyErrorLocalizedAsync(strs.vcrole_not_found);
await Response().Error(strs.vcrole_not_found).SendAsync();
}
[Cmd]
@@ -32,19 +32,19 @@ public partial class Administration
if (vc is null || vc.GuildId != user.GuildId)
{
await ReplyErrorLocalizedAsync(strs.must_be_in_voice);
await Response().Error(strs.must_be_in_voice).SendAsync();
return;
}
if (role is null)
{
if (_service.RemoveVcRole(ctx.Guild.Id, vc.Id))
await ReplyConfirmLocalizedAsync(strs.vcrole_removed(Format.Bold(vc.Name)));
await Response().Confirm(strs.vcrole_removed(Format.Bold(vc.Name))).SendAsync();
}
else
{
_service.AddVcRole(ctx.Guild.Id, role, vc.Id);
await ReplyConfirmLocalizedAsync(strs.vcrole_added(Format.Bold(vc.Name), Format.Bold(role.Name)));
await Response().Confirm(strs.vcrole_added(Format.Bold(vc.Name), Format.Bold(role.Name))).SendAsync();
}
}
@@ -68,10 +68,10 @@ public partial class Administration
else
text = GetText(strs.no_vcroles);
await EmbedAsync(_eb.Create()
await Response().Embed(new EmbedBuilder()
.WithOkColor()
.WithTitle(GetText(strs.vc_role_list))
.WithDescription(text));
.WithDescription(text)).SendAsync();
}
}
}