Added many more braces for multiline if's, Improved .crypto command quite a bit and applied locale-specific format

This commit is contained in:
Kwoth
2022-02-04 06:00:17 +01:00
parent f77f2f433f
commit eda38e64d1
129 changed files with 635 additions and 233 deletions

View File

@@ -129,11 +129,15 @@ public partial class Permissions
_service.UnBlacklist(type, id);
if (action == AddRemove.Add)
{
await ReplyConfirmLocalizedAsync(strs.blacklisted(Format.Code(type.ToString()),
Format.Code(id.ToString())));
}
else
{
await ReplyConfirmLocalizedAsync(strs.unblacklisted(Format.Code(type.ToString()),
Format.Code(id.ToString())));
}
}
}
}

View File

@@ -69,9 +69,7 @@ public partial class Permissions
await ReplyConfirmLocalizedAsync(strs.cmdcd_cleared(Format.Bold(name)));
}
else
{
await ReplyConfirmLocalizedAsync(strs.cmdcd_add(Format.Bold(name), Format.Bold(secs.ToString())));
}
}
[Cmd]
@@ -84,10 +82,12 @@ public partial class Permissions
if (!localSet.Any())
await ReplyConfirmLocalizedAsync(strs.cmdcd_none);
else
{
await channel.SendTableAsync("",
localSet.Select(c => c.CommandName + ": " + c.Seconds + GetText(strs.sec)),
s => $"{s,-30}",
2);
}
}
}
}

View File

@@ -230,10 +230,12 @@ public partial class Permissions
removed = config.FilteredWords.FirstOrDefault(fw => fw.Word.Trim().ToLowerInvariant() == word);
if (removed is null)
{
config.FilteredWords.Add(new()
{
Word = word
});
}
else
uow.Remove(removed);

View File

@@ -132,6 +132,7 @@ public sealed class FilterService : IEarlyBehavior
var filteredServerWords = FilteredWordsForServer(guild.Id) ?? new ConcurrentHashSet<string>();
var wordsInMessage = usrMsg.Content.ToLowerInvariant().Split(' ');
if (filteredChannelWords.Count != 0 || filteredServerWords.Count != 0)
{
foreach (var word in wordsInMessage)
{
if (filteredChannelWords.Contains(word) || filteredServerWords.Contains(word))
@@ -155,6 +156,7 @@ public sealed class FilterService : IEarlyBehavior
return true;
}
}
}
return false;
}

View File

@@ -43,9 +43,7 @@ public class GlobalPermissionService : ILateBlocker, INService
_bss.ModifyConfig(bs =>
{
if (bs.Blocked.Modules.Add(moduleName))
{
added = true;
}
else
{
bs.Blocked.Modules.Remove(moduleName);
@@ -67,9 +65,7 @@ public class GlobalPermissionService : ILateBlocker, INService
_bss.ModifyConfig(bs =>
{
if (bs.Blocked.Commands.Add(commandName))
{
added = true;
}
else
{
bs.Blocked.Commands.Remove(commandName);

View File

@@ -155,6 +155,7 @@ public partial class Permissions : NadekoModule<PermissionService>
from -= 1;
to -= 1;
if (!(from == to || from < 0 || to < 0))
{
try
{
Permissionv2 fromPerm;
@@ -163,12 +164,12 @@ 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 ReplyErrorLocalizedAsync(strs.perm_not_found(++@from));
return;
}
@@ -178,9 +179,9 @@ public partial class Permissions : NadekoModule<PermissionService>
return;
}
fromPerm = permsCol[from];
fromPerm = permsCol[@from];
permsCol.RemoveAt(from);
permsCol.RemoveAt(@from);
permsCol.Insert(to, fromPerm);
await uow.SaveChangesAsync();
_service.UpdateCache(config);
@@ -188,7 +189,7 @@ public partial class Permissions : NadekoModule<PermissionService>
await ReplyConfirmLocalizedAsync(strs.moved_permission(
Format.Code(fromPerm.GetCommand(prefix, (SocketGuild)ctx.Guild)),
++from,
++@from,
++to));
return;
@@ -196,6 +197,7 @@ public partial class Permissions : NadekoModule<PermissionService>
catch (Exception e) when (e is ArgumentOutOfRangeException or IndexOutOfRangeException)
{
}
}
await ReplyConfirmLocalizedAsync(strs.perm_out_of_range);
}
@@ -257,13 +259,17 @@ 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())));
}
else
{
await ReplyConfirmLocalizedAsync(strs.ux_disable(Format.Code(command.Name),
GetText(strs.of_command),
Format.Code(user.ToString())));
}
}
[Cmd]
@@ -281,13 +287,17 @@ 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())));
}
else
{
await ReplyConfirmLocalizedAsync(strs.ux_disable(Format.Code(module.Name),
GetText(strs.of_module),
Format.Code(user.ToString())));
}
}
[Cmd]
@@ -309,13 +319,17 @@ 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)));
}
else
{
await ReplyConfirmLocalizedAsync(strs.rx_disable(Format.Code(command.Name),
GetText(strs.of_command),
Format.Code(role.Name)));
}
}
[Cmd]
@@ -337,13 +351,17 @@ 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)));
}
else
{
await ReplyConfirmLocalizedAsync(strs.rx_disable(Format.Code(module.Name),
GetText(strs.of_module),
Format.Code(role.Name)));
}
}
[Cmd]
@@ -362,13 +380,17 @@ 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)));
}
else
{
await ReplyConfirmLocalizedAsync(strs.cx_disable(Format.Code(command.Name),
GetText(strs.of_command),
Format.Code(chnl.Name)));
}
}
[Cmd]
@@ -386,13 +408,17 @@ 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)));
}
else
{
await ReplyConfirmLocalizedAsync(strs.cx_disable(Format.Code(module.Name),
GetText(strs.of_module),
Format.Code(chnl.Name)));
}
}
[Cmd]

View File

@@ -112,6 +112,7 @@ public class PermissionService : ILateBlocker, INService
if (!resetCommand && !pc.Permissions.CheckPermissions(msg, commandName, moduleName, out var index))
{
if (pc.Verbose)
{
try
{
await channel.SendErrorAsync(_eb,
@@ -123,6 +124,7 @@ public class PermissionService : ILateBlocker, INService
catch
{
}
}
return true;
}
@@ -145,8 +147,10 @@ public class PermissionService : ILateBlocker, INService
{
returnMsg = "You need Admin permissions in order to use permission commands.";
if (pc.Verbose)
{
try { await channel.SendErrorAsync(_eb, returnMsg); }
catch { }
}
return true;
}
@@ -155,8 +159,10 @@ public class PermissionService : ILateBlocker, 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); }
catch { }
}
return true;
}