mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Updated editorconfig to (mostly?) require braces around if/else statements, and applied the new formatting rules
This commit is contained in:
@@ -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() ?? ""),
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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";
|
||||
|
||||
|
Reference in New Issue
Block a user