mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Part2 of the response system rework
This commit is contained in:
@@ -58,9 +58,9 @@ public partial class Permissions
|
||||
var pageItems = items.Skip(10 * curPage).Take(10).ToList();
|
||||
|
||||
if (pageItems.Count == 0)
|
||||
return _eb.Create().WithOkColor().WithTitle(title).WithDescription(GetText(strs.empty_page));
|
||||
return new EmbedBuilder().WithOkColor().WithTitle(title).WithDescription(GetText(strs.empty_page));
|
||||
|
||||
return _eb.Create().WithTitle(title).WithDescription(pageItems.Join('\n')).WithOkColor();
|
||||
return new EmbedBuilder().WithTitle(title).WithDescription(pageItems.Join('\n')).WithOkColor();
|
||||
},
|
||||
items.Length,
|
||||
10);
|
||||
@@ -130,13 +130,13 @@ public partial class Permissions
|
||||
|
||||
if (action == AddRemove.Add)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.blacklisted(Format.Code(type.ToString()),
|
||||
Format.Code(id.ToString())));
|
||||
await Response().Confirm(strs.blacklisted(Format.Code(type.ToString()),
|
||||
Format.Code(id.ToString()))).SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.unblacklisted(Format.Code(type.ToString()),
|
||||
Format.Code(id.ToString())));
|
||||
await Response().Confirm(strs.unblacklisted(Format.Code(type.ToString()),
|
||||
Format.Code(id.ToString()))).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ public partial class Permissions
|
||||
var channel = (ITextChannel)ctx.Channel;
|
||||
if (secs is < 0 or > 3600)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.invalid_second_param_between(0, 3600));
|
||||
await Response().Error(strs.invalid_second_param_between(0, 3600)).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,10 +56,10 @@ public partial class Permissions
|
||||
if (secs == 0)
|
||||
{
|
||||
_service.ClearCooldowns(ctx.Guild.Id, cmdName);
|
||||
await ReplyConfirmLocalizedAsync(strs.cmdcd_cleared(Format.Bold(name)));
|
||||
await Response().Confirm(strs.cmdcd_cleared(Format.Bold(name))).SendAsync();
|
||||
}
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.cmdcd_add(Format.Bold(name), Format.Bold(secs.ToString())));
|
||||
await Response().Confirm(strs.cmdcd_add(Format.Bold(name), Format.Bold(secs.ToString()))).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -85,7 +85,7 @@ public partial class Permissions
|
||||
var localSet = _service.GetCommandCooldowns(ctx.Guild.Id);
|
||||
|
||||
if (!localSet.Any())
|
||||
await ReplyConfirmLocalizedAsync(strs.cmdcd_none);
|
||||
await Response().Confirm(strs.cmdcd_none).SendAsync();
|
||||
else
|
||||
{
|
||||
await ctx.SendPaginatedConfirmAsync(page, curPage =>
|
||||
@@ -94,7 +94,7 @@ public partial class Permissions
|
||||
.Take(15)
|
||||
.Select(x => $"{Format.Code(x.CommandName)}: {x.Seconds.Seconds().Humanize(maxUnit: TimeUnit.Second, culture: Culture)}");
|
||||
|
||||
return _eb.Create(ctx)
|
||||
return new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithDescription(items.Join("\n"));
|
||||
|
||||
|
@@ -22,14 +22,14 @@ public partial class Permissions
|
||||
public async Task FwClear()
|
||||
{
|
||||
_service.ClearFilteredWords(ctx.Guild.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.fw_cleared);
|
||||
await Response().Confirm(strs.fw_cleared).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
public async Task FilterList()
|
||||
{
|
||||
var embed = _eb.Create(ctx)
|
||||
var embed = new EmbedBuilder()
|
||||
.WithOkColor()
|
||||
.WithTitle("Server filter settings");
|
||||
|
||||
@@ -63,7 +63,7 @@ public partial class Permissions
|
||||
embed.AddField($"{GetEnabledEmoji(config.FilterInvitesEnabled)} Filter Invites",
|
||||
await GetChannelListAsync(config.FilterInvitesChannels));
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -83,12 +83,12 @@ public partial class Permissions
|
||||
if (enabled)
|
||||
{
|
||||
_service.InviteFilteringServers.Add(channel.Guild.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.invite_filter_server_on);
|
||||
await Response().Confirm(strs.invite_filter_server_on).SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
_service.InviteFilteringServers.TryRemove(channel.Guild.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.invite_filter_server_off);
|
||||
await Response().Confirm(strs.invite_filter_server_off).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,12 +119,12 @@ public partial class Permissions
|
||||
if (removed is null)
|
||||
{
|
||||
_service.InviteFilteringChannels.Add(channel.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.invite_filter_channel_on);
|
||||
await Response().Confirm(strs.invite_filter_channel_on).SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
_service.InviteFilteringChannels.TryRemove(channel.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.invite_filter_channel_off);
|
||||
await Response().Confirm(strs.invite_filter_channel_off).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,12 +145,12 @@ public partial class Permissions
|
||||
if (enabled)
|
||||
{
|
||||
_service.LinkFilteringServers.Add(channel.Guild.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.link_filter_server_on);
|
||||
await Response().Confirm(strs.link_filter_server_on).SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
_service.LinkFilteringServers.TryRemove(channel.Guild.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.link_filter_server_off);
|
||||
await Response().Confirm(strs.link_filter_server_off).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,12 +181,12 @@ public partial class Permissions
|
||||
if (removed is null)
|
||||
{
|
||||
_service.LinkFilteringChannels.Add(channel.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.link_filter_channel_on);
|
||||
await Response().Confirm(strs.link_filter_channel_on).SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
_service.LinkFilteringChannels.TryRemove(channel.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.link_filter_channel_off);
|
||||
await Response().Confirm(strs.link_filter_channel_off).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,12 +207,12 @@ public partial class Permissions
|
||||
if (enabled)
|
||||
{
|
||||
_service.WordFilteringServers.Add(channel.Guild.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.word_filter_server_on);
|
||||
await Response().Confirm(strs.word_filter_server_on).SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
_service.WordFilteringServers.TryRemove(channel.Guild.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.word_filter_server_off);
|
||||
await Response().Confirm(strs.word_filter_server_off).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,12 +243,12 @@ public partial class Permissions
|
||||
if (removed is null)
|
||||
{
|
||||
_service.WordFilteringChannels.Add(channel.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.word_filter_channel_on);
|
||||
await Response().Confirm(strs.word_filter_channel_on).SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
_service.WordFilteringChannels.TryRemove(channel.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.word_filter_channel_off);
|
||||
await Response().Confirm(strs.word_filter_channel_off).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,12 +289,12 @@ public partial class Permissions
|
||||
if (removed is null)
|
||||
{
|
||||
filteredWords.Add(word);
|
||||
await ReplyConfirmLocalizedAsync(strs.filter_word_add(Format.Code(word)));
|
||||
await Response().Confirm(strs.filter_word_add(Format.Code(word))).SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
filteredWords.TryRemove(word);
|
||||
await ReplyConfirmLocalizedAsync(strs.filter_word_remove(Format.Code(word)));
|
||||
await Response().Confirm(strs.filter_word_remove(Format.Code(word))).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ public partial class Permissions
|
||||
var fws = fwHash.ToArray();
|
||||
|
||||
await ctx.SendPaginatedConfirmAsync(page,
|
||||
curPage => _eb.Create()
|
||||
curPage => new EmbedBuilder()
|
||||
.WithTitle(GetText(strs.filter_word_list))
|
||||
.WithDescription(string.Join("\n", fws.Skip(curPage * 10).Take(10)))
|
||||
.WithOkColor(),
|
||||
|
@@ -26,11 +26,11 @@ public partial class Permissions
|
||||
var blockedCommands = _service.BlockedCommands;
|
||||
if (!blockedModule.Any() && !blockedCommands.Any())
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.lgp_none);
|
||||
await Response().Error(strs.lgp_none).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
var embed = _eb.Create().WithOkColor();
|
||||
var embed = new EmbedBuilder().WithOkColor();
|
||||
|
||||
if (blockedModule.Any())
|
||||
embed.AddField(GetText(strs.blocked_modules), string.Join("\n", _service.BlockedModules));
|
||||
@@ -38,7 +38,7 @@ public partial class Permissions
|
||||
if (blockedCommands.Any())
|
||||
embed.AddField(GetText(strs.blocked_commands), string.Join("\n", _service.BlockedCommands));
|
||||
|
||||
await EmbedAsync(embed);
|
||||
await Response().Embed(embed).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -51,11 +51,11 @@ public partial class Permissions
|
||||
|
||||
if (added)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.gmod_add(Format.Bold(module.Name)));
|
||||
await Response().Confirm(strs.gmod_add(Format.Bold(module.Name))).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.gmod_remove(Format.Bold(module.Name)));
|
||||
await Response().Confirm(strs.gmod_remove(Format.Bold(module.Name))).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -67,11 +67,11 @@ public partial class Permissions
|
||||
|
||||
if (added)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.gcmd_add(Format.Bold(cmd.Name)));
|
||||
await Response().Confirm(strs.gcmd_add(Format.Bold(cmd.Name))).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.gcmd_remove(Format.Bold(cmd.Name)));
|
||||
await Response().Confirm(strs.gcmd_remove(Format.Bold(cmd.Name))).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,9 +32,9 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
}
|
||||
|
||||
if (action.Value)
|
||||
await ReplyConfirmLocalizedAsync(strs.verbose_true);
|
||||
await Response().Confirm(strs.verbose_true).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.verbose_false);
|
||||
await Response().Confirm(strs.verbose_false).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -51,9 +51,9 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
var cache = _service.GetCacheFor(ctx.Guild.Id);
|
||||
if (!ulong.TryParse(cache.PermRole, out var roleId)
|
||||
|| (role = ((SocketGuild)ctx.Guild).GetRole(roleId)) is null)
|
||||
await ReplyConfirmLocalizedAsync(strs.permrole_not_set);
|
||||
await Response().Confirm(strs.permrole_not_set).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.permrole(Format.Bold(role.ToString())));
|
||||
await Response().Confirm(strs.permrole(Format.Bold(role.ToString()))).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
_service.UpdateCache(config);
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.permrole_changed(Format.Bold(role.Name)));
|
||||
await Response().Confirm(strs.permrole_changed(Format.Bold(role.Name))).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -82,7 +82,7 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
_service.UpdateCache(config);
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.permrole_reset);
|
||||
await Response().Confirm(strs.permrole_reset).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -115,7 +115,7 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
return str;
|
||||
}));
|
||||
|
||||
await SendConfirmAsync(toSend);
|
||||
await Response().Confirm(toSend).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -139,12 +139,14 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
_service.UpdateCache(config);
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.removed(index + 1,
|
||||
Format.Code(p.GetCommand(prefix, (SocketGuild)ctx.Guild))));
|
||||
await Response()
|
||||
.Confirm(strs.removed(index + 1,
|
||||
Format.Code(p.GetCommand(prefix, (SocketGuild)ctx.Guild))))
|
||||
.SendAsync();
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.perm_out_of_range);
|
||||
await Response().Error(strs.perm_out_of_range).SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,33 +166,35 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
var config = uow.GcWithPermissionsFor(ctx.Guild.Id);
|
||||
var permsCol = new PermissionsCollection<Permissionv2>(config.Permissions);
|
||||
|
||||
var fromFound = @from < permsCol.Count;
|
||||
var fromFound = from < permsCol.Count;
|
||||
var toFound = to < permsCol.Count;
|
||||
|
||||
if (!fromFound)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.perm_not_found(++@from));
|
||||
await Response().Error(strs.perm_not_found(++from)).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!toFound)
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.perm_not_found(++to));
|
||||
await Response().Error(strs.perm_not_found(++to)).SendAsync();
|
||||
return;
|
||||
}
|
||||
|
||||
fromPerm = permsCol[@from];
|
||||
fromPerm = permsCol[from];
|
||||
|
||||
permsCol.RemoveAt(@from);
|
||||
permsCol.RemoveAt(from);
|
||||
permsCol.Insert(to, fromPerm);
|
||||
await uow.SaveChangesAsync();
|
||||
_service.UpdateCache(config);
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.moved_permission(
|
||||
Format.Code(fromPerm.GetCommand(prefix, (SocketGuild)ctx.Guild)),
|
||||
++@from,
|
||||
++to));
|
||||
await Response()
|
||||
.Confirm(strs.moved_permission(
|
||||
Format.Code(fromPerm.GetCommand(prefix, (SocketGuild)ctx.Guild)),
|
||||
++from,
|
||||
++to))
|
||||
.SendAsync();
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -199,7 +203,7 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
}
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalizedAsync(strs.perm_out_of_range);
|
||||
await Response().Confirm(strs.perm_out_of_range).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -218,9 +222,9 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
});
|
||||
|
||||
if (action.Value)
|
||||
await ReplyConfirmLocalizedAsync(strs.sx_enable(Format.Code(command.Name), GetText(strs.of_command)));
|
||||
await Response().Confirm(strs.sx_enable(Format.Code(command.Name), GetText(strs.of_command))).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.sx_disable(Format.Code(command.Name), GetText(strs.of_command)));
|
||||
await Response().Confirm(strs.sx_disable(Format.Code(command.Name), GetText(strs.of_command))).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -238,9 +242,9 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
});
|
||||
|
||||
if (action.Value)
|
||||
await ReplyConfirmLocalizedAsync(strs.sx_enable(Format.Code(module.Name), GetText(strs.of_module)));
|
||||
await Response().Confirm(strs.sx_enable(Format.Code(module.Name), GetText(strs.of_module))).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.sx_disable(Format.Code(module.Name), GetText(strs.of_module)));
|
||||
await Response().Confirm(strs.sx_disable(Format.Code(module.Name), GetText(strs.of_module))).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -260,15 +264,19 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
|
||||
if (action.Value)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.ux_enable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(user.ToString())));
|
||||
await Response()
|
||||
.Confirm(strs.ux_enable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(user.ToString())))
|
||||
.SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.ux_disable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(user.ToString())));
|
||||
await Response()
|
||||
.Confirm(strs.ux_disable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(user.ToString())))
|
||||
.SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,15 +296,19 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
|
||||
if (action.Value)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.ux_enable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(user.ToString())));
|
||||
await Response()
|
||||
.Confirm(strs.ux_enable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(user.ToString())))
|
||||
.SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.ux_disable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(user.ToString())));
|
||||
await Response()
|
||||
.Confirm(strs.ux_disable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(user.ToString())))
|
||||
.SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,15 +332,19 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
|
||||
if (action.Value)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.rx_enable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(role.Name)));
|
||||
await Response()
|
||||
.Confirm(strs.rx_enable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(role.Name)))
|
||||
.SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.rx_disable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(role.Name)));
|
||||
await Response()
|
||||
.Confirm(strs.rx_disable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(role.Name)))
|
||||
.SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,15 +368,19 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
|
||||
if (action.Value)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.rx_enable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(role.Name)));
|
||||
await Response()
|
||||
.Confirm(strs.rx_enable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(role.Name)))
|
||||
.SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.rx_disable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(role.Name)));
|
||||
await Response()
|
||||
.Confirm(strs.rx_disable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(role.Name)))
|
||||
.SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,15 +401,19 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
|
||||
if (action.Value)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.cx_enable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(chnl.Name)));
|
||||
await Response()
|
||||
.Confirm(strs.cx_enable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(chnl.Name)))
|
||||
.SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.cx_disable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(chnl.Name)));
|
||||
await Response()
|
||||
.Confirm(strs.cx_disable(Format.Code(command.Name),
|
||||
GetText(strs.of_command),
|
||||
Format.Code(chnl.Name)))
|
||||
.SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,15 +433,19 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
|
||||
if (action.Value)
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.cx_enable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(chnl.Name)));
|
||||
await Response()
|
||||
.Confirm(strs.cx_enable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(chnl.Name)))
|
||||
.SendAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await ReplyConfirmLocalizedAsync(strs.cx_disable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(chnl.Name)));
|
||||
await Response()
|
||||
.Confirm(strs.cx_disable(Format.Code(module.Name),
|
||||
GetText(strs.of_module),
|
||||
Format.Code(chnl.Name)))
|
||||
.SendAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,9 +464,9 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
});
|
||||
|
||||
if (action.Value)
|
||||
await ReplyConfirmLocalizedAsync(strs.acm_enable(Format.Code(chnl.Name)));
|
||||
await Response().Confirm(strs.acm_enable(Format.Code(chnl.Name))).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.acm_disable(Format.Code(chnl.Name)));
|
||||
await Response().Confirm(strs.acm_disable(Format.Code(chnl.Name))).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -459,9 +487,9 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
});
|
||||
|
||||
if (action.Value)
|
||||
await ReplyConfirmLocalizedAsync(strs.arm_enable(Format.Code(role.Name)));
|
||||
await Response().Confirm(strs.arm_enable(Format.Code(role.Name))).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.arm_disable(Format.Code(role.Name)));
|
||||
await Response().Confirm(strs.arm_disable(Format.Code(role.Name))).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -479,9 +507,9 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
});
|
||||
|
||||
if (action.Value)
|
||||
await ReplyConfirmLocalizedAsync(strs.aum_enable(Format.Code(user.ToString())));
|
||||
await Response().Confirm(strs.aum_enable(Format.Code(user.ToString()))).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.aum_disable(Format.Code(user.ToString())));
|
||||
await Response().Confirm(strs.aum_disable(Format.Code(user.ToString()))).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -509,8 +537,8 @@ public partial class Permissions : NadekoModule<PermissionService>
|
||||
await _service.AddPermissions(ctx.Guild.Id, newPerm, allowUser);
|
||||
|
||||
if (action.Value)
|
||||
await ReplyConfirmLocalizedAsync(strs.asm_enable);
|
||||
await Response().Confirm(strs.asm_enable).SendAsync();
|
||||
else
|
||||
await ReplyConfirmLocalizedAsync(strs.asm_disable);
|
||||
await Response().Confirm(strs.asm_disable).SendAsync();
|
||||
}
|
||||
}
|
@@ -18,18 +18,21 @@ public class PermissionService : IExecPreCommand, INService
|
||||
private readonly CommandHandler _cmd;
|
||||
private readonly IBotStrings _strings;
|
||||
private readonly IEmbedBuilderService _eb;
|
||||
private readonly IMessageSenderService _sender;
|
||||
|
||||
public PermissionService(
|
||||
DiscordSocketClient client,
|
||||
DbService db,
|
||||
CommandHandler cmd,
|
||||
IBotStrings strings,
|
||||
IEmbedBuilderService eb)
|
||||
IEmbedBuilderService eb,
|
||||
IMessageSenderService sender)
|
||||
{
|
||||
_db = db;
|
||||
_cmd = cmd;
|
||||
_strings = strings;
|
||||
_eb = eb;
|
||||
_sender = sender;
|
||||
|
||||
using var uow = _db.GetDbContext();
|
||||
foreach (var x in uow.Set<GuildConfig>().PermissionsForAll(client.Guilds.ToArray().Select(x => x.Id).ToList()))
|
||||
@@ -115,11 +118,12 @@ public class PermissionService : IExecPreCommand, INService
|
||||
{
|
||||
try
|
||||
{
|
||||
await channel.SendErrorAsync(_eb,
|
||||
_strings.GetText(strs.perm_prevent(index + 1,
|
||||
Format.Bold(pc.Permissions[index]
|
||||
.GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild))),
|
||||
guild.Id));
|
||||
await _sender.Response(channel)
|
||||
.Error(_strings.GetText(strs.perm_prevent(index + 1,
|
||||
Format.Bold(pc.Permissions[index]
|
||||
.GetCommand(_cmd.GetPrefix(guild), (SocketGuild)guild))),
|
||||
guild.Id))
|
||||
.SendAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -148,7 +152,7 @@ public class PermissionService : IExecPreCommand, INService
|
||||
returnMsg = "You need Admin permissions in order to use permission commands.";
|
||||
if (pc.Verbose)
|
||||
{
|
||||
try { await channel.SendErrorAsync(_eb, returnMsg); }
|
||||
try { await _sender.Response(channel).Error(returnMsg).SendAsync(); }
|
||||
catch { }
|
||||
}
|
||||
|
||||
@@ -160,7 +164,7 @@ public class PermissionService : IExecPreCommand, INService
|
||||
returnMsg = $"You need the {Format.Bold(role.Name)} role in order to use permission commands.";
|
||||
if (pc.Verbose)
|
||||
{
|
||||
try { await channel.SendErrorAsync(_eb, returnMsg); }
|
||||
try { await _sender.Response(channel).Error(returnMsg).SendAsync(); }
|
||||
catch { }
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ public partial class Permissions
|
||||
public async Task ResetPerms()
|
||||
{
|
||||
await _perms.Reset(ctx.Guild.Id);
|
||||
await ReplyConfirmLocalizedAsync(strs.perms_reset);
|
||||
await Response().Confirm(strs.perms_reset).SendAsync();
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
@@ -31,7 +31,7 @@ public partial class Permissions
|
||||
public async Task ResetGlobalPerms()
|
||||
{
|
||||
await _gps.Reset();
|
||||
await ReplyConfirmLocalizedAsync(strs.global_perms_reset);
|
||||
await Response().Confirm(strs.global_perms_reset).SendAsync();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user