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

@@ -26,8 +26,16 @@ public static class DiscordUserExtensions
TotalXp = 0,
CurrencyAmount = 0
},
old => new() { Username = username, Discriminator = discrim, AvatarId = avatarId },
() => new() { UserId = userId });
old => new()
{
Username = username,
Discriminator = discrim,
AvatarId = avatarId
},
() => new()
{
UserId = userId
});
//temp is only used in updatecurrencystate, so that i don't overwrite real usernames/discrims with Unknown
public static DiscordUser GetOrCreateUser(
@@ -72,7 +80,8 @@ public static class DiscordUserExtensions
public static void RemoveFromMany(this DbSet<DiscordUser> users, IEnumerable<ulong> ids)
{
var items = users.AsQueryable().Where(x => ids.Contains(x.UserId));
foreach (var item in items) item.CurrencyAmount = 0;
foreach (var item in items)
item.CurrencyAmount = 0;
}
public static bool TryUpdateCurrencyState(

View File

@@ -11,8 +11,16 @@ public static class GuildConfigExtensions
private static List<WarningPunishment> DefaultWarnPunishments
=> new()
{
new() { Count = 3, Punishment = PunishmentAction.Kick },
new() { Count = 5, Punishment = PunishmentAction.Ban }
new()
{
Count = 3,
Punishment = PunishmentAction.Kick
},
new()
{
Count = 5,
Punishment = PunishmentAction.Ban
}
};
/// <summary>
@@ -105,7 +113,10 @@ public static class GuildConfigExtensions
if (logSetting is null)
{
ctx.LogSettings.Add(logSetting = new() { GuildId = guildId });
ctx.LogSettings.Add(logSetting = new()
{
GuildId = guildId
});
ctx.SaveChanges();
}
@@ -128,7 +139,11 @@ public static class GuildConfigExtensions
if (config is null) // if there is no guildconfig, create new one
{
ctx.GuildConfigs.Add(config = new() { GuildId = guildId, Permissions = Permissionv2.GetDefaultPermlist });
ctx.GuildConfigs.Add(config = new()
{
GuildId = guildId,
Permissions = Permissionv2.GetDefaultPermlist
});
ctx.SaveChanges();
}
else if (config.Permissions is null || !config.Permissions.Any()) // if no perms, add default ones
@@ -181,7 +196,11 @@ public static class GuildConfigExtensions
.Include(x => x.GenerateCurrencyChannelIds)
.Where(x => x.GenerateCurrencyChannelIds.Any())
.SelectMany(x => x.GenerateCurrencyChannelIds)
.Select(x => new GeneratingChannel { ChannelId = x.ChannelId, GuildId = x.GuildConfig.GuildId })
.Select(x => new GeneratingChannel
{
ChannelId = x.ChannelId,
GuildId = x.GuildConfig.GuildId
})
.ToArray();
public class GeneratingChannel

View File

@@ -12,7 +12,11 @@ public static class MusicPlayerSettingsExtensions
if (toReturn is null)
{
var newSettings = new MusicPlayerSettings { GuildId = guildId, PlayerRepeat = PlayerRepeatType.Queue };
var newSettings = new MusicPlayerSettings
{
GuildId = guildId,
PlayerRepeat = PlayerRepeatType.Queue
};
await settings.AddAsync(newSettings);
return newSettings;

View File

@@ -13,6 +13,9 @@ public static class NadekoExpressionExtensions
public static IEnumerable<NadekoExpression> ForId(this DbSet<NadekoExpression> exprs, ulong id)
=> exprs.AsNoTracking().AsQueryable().Where(x => x.GuildId == id).ToList();
public static NadekoExpression GetByGuildIdAndInput(this DbSet<NadekoExpression> exprs, ulong? guildId, string input)
public static NadekoExpression GetByGuildIdAndInput(
this DbSet<NadekoExpression> exprs,
ulong? guildId,
string input)
=> exprs.FirstOrDefault(x => x.GuildId == guildId && x.Trigger.ToUpper() == input);
}

View File

@@ -15,7 +15,10 @@ public static class UserXpExtensions
if (usr is null)
ctx.Add(usr = new()
{
Xp = 0, UserId = userId, NotifyOnLevelUp = XpNotificationLocation.None, GuildId = guildId
Xp = 0,
UserId = userId,
NotifyOnLevelUp = XpNotificationLocation.None,
GuildId = guildId
});
return usr;