Added and applied styles for private readonly fields, private fields to Extensions and Common folders.

- Some renamings and code cleanups
- Chained method calls, binary expressions and binary patterns will now break into newlines
- Type param constraints and base constructor calls will be on the new line
This commit is contained in:
Kwoth
2021-12-27 03:46:30 +01:00
parent 9ae030a5c5
commit 1b0392dfab
85 changed files with 1015 additions and 906 deletions

View File

@@ -152,8 +152,7 @@ public class ReactionEvent : ICurrencyEvent
{
if (_emote.Name != r.Emote.Name)
return;
var gu = (r.User.IsSpecified ? r.User.Value : null) as IGuildUser;
if (gu is null // no unknown users, as they could be bots, or alts
if ((r.User.IsSpecified ? r.User.Value : null) is not IGuildUser gu // no unknown users, as they could be bots, or alts
|| msg.Id != _msg.Id // same message
|| gu.IsBot // no bots
|| (DateTime.UtcNow - gu.CreatedAt).TotalDays <= 5 // no recently created accounts

View File

@@ -35,7 +35,7 @@ public partial class Gambling : GamblingModule<GamblingService>
private string n(long cur)
{
var flowersCi = (CultureInfo)_cultureInfo.Clone();
var flowersCi = (CultureInfo)Culture.Clone();
flowersCi.NumberFormat.CurrencySymbol = CurrencySign;
Log.Information(string.Join(",", flowersCi.NumberFormat.NativeDigits));
return cur.ToString("C0", flowersCi);
@@ -59,12 +59,12 @@ public partial class Gambling : GamblingModule<GamblingService>
}
var embed = _eb.Create()
.WithTitle(GetText(strs.economy_state))
.AddField(GetText(strs.currency_owned), ((BigInteger)(ec.Cash - ec.Bot)).ToString("N", _cultureInfo) + CurrencySign)
.AddField(GetText(strs.currency_owned), ((BigInteger)(ec.Cash - ec.Bot)).ToString("N", Culture) + CurrencySign)
.AddField(GetText(strs.currency_one_percent), (onePercent * 100).ToString("F2") + "%")
.AddField(GetText(strs.currency_planted), (BigInteger)ec.Planted)
.AddField(GetText(strs.owned_waifus_total), (BigInteger)ec.Waifus + CurrencySign)
.AddField(GetText(strs.bot_currency), n(ec.Bot))
.AddField(GetText(strs.total), ((BigInteger)(ec.Cash + ec.Planted + ec.Waifus)).ToString("N", _cultureInfo) + CurrencySign)
.AddField(GetText(strs.total), ((BigInteger)(ec.Cash + ec.Planted + ec.Waifus)).ToString("N", Culture) + CurrencySign)
.WithOkColor();
// ec.Cash already contains ec.Bot as it's the total of all values in the CurrencyAmount column of the DiscordUser table
await ctx.Channel.EmbedAsync(embed).ConfigureAwait(false);

View File

@@ -27,8 +27,7 @@ public class CurrencyEventsService : INService
EventOptions opts, Func<CurrencyEvent.Type, EventOptions, long, IEmbedBuilder> embed)
{
var g = _client.GetGuild(guildId);
var ch = g?.GetChannel(channelId) as SocketTextChannel;
if (ch is null)
if (g?.GetChannel(channelId) is not SocketTextChannel ch)
return false;
ICurrencyEvent ce;

View File

@@ -159,8 +159,7 @@ public class PlantPickService : INService
private Task PotentialFlowerGeneration(IUserMessage imsg)
{
var msg = imsg as SocketUserMessage;
if (msg is null || msg.Author.IsBot)
if (imsg is not SocketUserMessage msg || msg.Author.IsBot)
return Task.CompletedTask;
if (imsg.Channel is not ITextChannel channel)