Updated editorconfig to (mostly?) require braces around if/else statements, and applied the new formatting rules

This commit is contained in:
Kwoth
2022-02-02 01:44:45 +01:00
parent b22cd5a81e
commit ffa2c3f119
202 changed files with 2108 additions and 920 deletions

View File

@@ -34,8 +34,8 @@ public partial class Permissions
BlacklistType.User => Format.Code(i.ItemId.ToString())
+ " "
+ ((await _client.Rest.GetUserAsync(i.ItemId))
?.ToString()
?? ""),
?.ToString()
?? ""),
BlacklistType.Server => Format.Code(i.ItemId.ToString())
+ " "
+ (_client.GetGuild(i.ItemId)?.ToString() ?? ""),

View File

@@ -75,7 +75,8 @@ public sealed class BlacklistService : IEarlyBehavior
using var uow = _db.GetDbContext();
var toPublish = uow.Blacklist.AsNoTracking().ToArray();
blacklist = toPublish;
if (publish) _pubSub.Pub(_blPubKey, toPublish);
if (publish)
_pubSub.Pub(_blPubKey, toPublish);
}
public void Blacklist(BlacklistType type, ulong id)
@@ -84,7 +85,11 @@ public sealed class BlacklistService : IEarlyBehavior
return;
using var uow = _db.GetDbContext();
var item = new BlacklistEntry { ItemId = id, Type = type };
var item = new BlacklistEntry
{
ItemId = id,
Type = type
};
uow.Blacklist.Add(item);
uow.SaveChanges();
@@ -110,7 +115,11 @@ public sealed class BlacklistService : IEarlyBehavior
{
var bc = uow.Blacklist;
//blacklist the users
bc.AddRange(toBlacklist.Select(x => new BlacklistEntry { ItemId = x, Type = BlacklistType.User }));
bc.AddRange(toBlacklist.Select(x => new BlacklistEntry
{
ItemId = x,
Type = BlacklistType.User
}));
//clear their currencies
uow.DiscordUser.RemoveFromMany(toBlacklist);

View File

@@ -28,9 +28,13 @@ public class CmdCdService : ILateBlocker, INService
if (activeCdsForGuild.FirstOrDefault(ac => ac.UserId == user.Id && ac.Command == commandName) is not null)
return Task.FromResult(true);
activeCdsForGuild.Add(new() { UserId = user.Id, Command = commandName });
activeCdsForGuild.Add(new()
{
UserId = user.Id,
Command = commandName
});
_= Task.Run(async () =>
_ = Task.Run(async () =>
{
try
{

View File

@@ -50,7 +50,11 @@ public partial class Permissions
localSet.RemoveWhere(cc => cc.CommandName == name);
if (secs != 0)
{
var cc = new CommandCooldown { CommandName = name, Seconds = secs };
var cc = new CommandCooldown
{
CommandName = name,
Seconds = secs
};
config.CommandCooldowns.Add(cc);
localSet.Add(cc);
}

View File

@@ -62,7 +62,10 @@ public partial class Permissions
{
var config = uow.GuildConfigsForId(channel.Guild.Id,
set => set.Include(gc => gc.FilterInvitesChannelIds));
var match = new FilterChannelId { ChannelId = channel.Id };
var match = new FilterChannelId
{
ChannelId = channel.Id
};
removed = config.FilterInvitesChannelIds.FirstOrDefault(fc => fc.Equals(match));
if (removed is null)
@@ -121,7 +124,10 @@ public partial class Permissions
{
var config =
uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterLinksChannelIds));
var match = new FilterLinksChannelId { ChannelId = channel.Id };
var match = new FilterLinksChannelId
{
ChannelId = channel.Id
};
removed = config.FilterLinksChannelIds.FirstOrDefault(fc => fc.Equals(match));
if (removed is null)
@@ -181,7 +187,10 @@ public partial class Permissions
var config =
uow.GuildConfigsForId(channel.Guild.Id, set => set.Include(gc => gc.FilterWordsChannelIds));
var match = new FilterWordsChannelId { ChannelId = channel.Id };
var match = new FilterWordsChannelId
{
ChannelId = channel.Id
};
removed = config.FilterWordsChannelIds.FirstOrDefault(fc => fc.Equals(match));
if (removed is null)
config.FilterWordsChannelIds.Add(match);
@@ -221,7 +230,10 @@ public partial class Permissions
removed = config.FilteredWords.FirstOrDefault(fw => fw.Word.Trim().ToLowerInvariant() == word);
if (removed is null)
config.FilteredWords.Add(new() { Word = word });
config.FilteredWords.Add(new()
{
Word = word
});
else
uow.Remove(removed);

View File

@@ -62,7 +62,7 @@ public sealed class FilterService : IEarlyBehavior
client.MessageUpdated += (oldData, newMsg, channel) =>
{
_= Task.Run(() =>
_ = Task.Run(() =>
{
var guild = (channel as ITextChannel)?.Guild;
@@ -132,7 +132,6 @@ 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))
@@ -156,7 +155,6 @@ public sealed class FilterService : IEarlyBehavior
return true;
}
}
}
return false;
}

View File

@@ -20,7 +20,8 @@ public static class PermissionExtensions
var result = perm.CheckPermission(message, commandName, moduleName);
if (result is null) continue;
if (result is null)
continue;
permIndex = i;
return result.Value;
}

View File

@@ -24,7 +24,8 @@ public partial class Permissions : NadekoModule<PermissionService>
await using (var uow = _db.GetDbContext())
{
var config = uow.GcWithPermissionsFor(ctx.Guild.Id);
if (action is null) action = new(!config.VerbosePermissions); // New behaviour, can toggle.
if (action is null)
action = new(!config.VerbosePermissions); // New behaviour, can toggle.
config.VerbosePermissions = action.Value;
await uow.SaveChangesAsync();
_service.UpdateCache(config);

View File

@@ -33,11 +33,15 @@ public class PermissionService : ILateBlocker, INService
using var uow = _db.GetDbContext();
foreach (var x in uow.GuildConfigs.PermissionsForAll(client.Guilds.ToArray().Select(x => x.Id).ToList()))
{
Cache.TryAdd(x.GuildId,
new()
{
Verbose = x.VerbosePermissions, PermRole = x.PermissionRole, Permissions = new(x.Permissions)
Verbose = x.VerbosePermissions,
PermRole = x.PermissionRole,
Permissions = new(x.Permissions)
});
}
}
public PermissionCache GetCacheFor(ulong guildId)
@@ -99,7 +103,8 @@ public class PermissionService : ILateBlocker, INService
var commandName = command.Name.ToLowerInvariant();
await Task.Yield();
if (guild is null) return false;
if (guild is null)
return false;
var resetCommand = commandName == "resetperms";