From d31cfcc5a8940fe3109ce2048422c4dbb54df3c7 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Tue, 1 Feb 2022 08:52:40 +0100 Subject: [PATCH] - Updated changelog - Updated all projects to .net6 - Added some exception handling to the cmd source generator --- CHANGELOG.md | 6 +-- .../NadekoBot.Coordinator.csproj | 2 +- .../Services/CoordinatorRunner.cs | 2 +- .../Command/CommandAttributesGenerator.cs | 39 ++++++++----------- .../NadekoBot.Generators.csproj | 3 +- .../NadekoBot.VotesApi.csproj | 4 +- src/NadekoBot/Bot.cs | 4 ++ 7 files changed, 28 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1846b27c2..61a4ae665 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,11 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog. ## Changes ### Added - - Added `.deleteemptyservers` command - Added `.curtr ` which lets you see full information about one of your own transactions with the specified id +- Added trovo.live support for stream notifications (`.stadd`) ### Fixed - - Fixed an extra whitespace in usage part of command help if the command has no arguments - Possible small fix for `.prune` ratelimiting - `.gvc` should now properly trigger when a user is already in a gvc and changes his activity @@ -21,7 +20,6 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog. - Fixed reference to non-existent command in bot.yml ### Changed - - CustomReactions module (and customreactions db table) has been renamed to Expressions. - This was done to remove confusion about how it relates to discord Reactions (it doesn't, it was created and named before discord reactions existed) - Expression command now start with ex/expr and end with the name of the action or setting. @@ -31,6 +29,7 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog. - If you have custom permissions for other CustomReaction commands - Some of the old aliases like `.acr` `.dcr` `.lcr` and a few others have been kept - Currency output format improvement (will use guild locale now for some commands) +- `.crypto` will now also show CoinMarketCap rank - Improved .curtrs (It will now have a lot more useful data in the database, show Tx ids, and be partially localized) - [dev] Reason renamed to Note - [dev] Added Type, Extra, OtherId fields to the database @@ -41,7 +40,6 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog. - [dev] Moved FilterWordsChannelId to a separate table ### Removed - - Removed `.bce` - use `.config` or `.config bot` specifically for bot config - Removed obsolete placeholders: %users% %servers% %userfull% %username% %userdiscrim% %useravatar% %id% %uid% %chname% %cid% %sid% %members% %server_time% %shardid% %time% %mention% - Removed some obsolete commands and strings diff --git a/src/NadekoBot.Coordinator/NadekoBot.Coordinator.csproj b/src/NadekoBot.Coordinator/NadekoBot.Coordinator.csproj index 4bafbe55c..f70afbdbf 100644 --- a/src/NadekoBot.Coordinator/NadekoBot.Coordinator.csproj +++ b/src/NadekoBot.Coordinator/NadekoBot.Coordinator.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 diff --git a/src/NadekoBot.Coordinator/Services/CoordinatorRunner.cs b/src/NadekoBot.Coordinator/Services/CoordinatorRunner.cs index 874906f3d..b89d09aec 100644 --- a/src/NadekoBot.Coordinator/Services/CoordinatorRunner.cs +++ b/src/NadekoBot.Coordinator/Services/CoordinatorRunner.cs @@ -310,7 +310,7 @@ namespace NadekoBot.Coordinator }) .ToList() }; - var jsonState = JsonSerializer.Serialize(coordState, new () + var jsonState = JsonSerializer.Serialize(coordState, new JsonSerializerOptions() { WriteIndented = true, }); diff --git a/src/NadekoBot.Generators/Command/CommandAttributesGenerator.cs b/src/NadekoBot.Generators/Command/CommandAttributesGenerator.cs index c8b6ac8be..5650ff9c3 100644 --- a/src/NadekoBot.Generators/Command/CommandAttributesGenerator.cs +++ b/src/NadekoBot.Generators/Command/CommandAttributesGenerator.cs @@ -1,4 +1,5 @@ #nullable enable +using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Collections.Immutable; @@ -62,6 +63,9 @@ public class CmdAttribute : System.Attribute public void Initialize(IncrementalGeneratorInitializationContext context) { +// #if DEBUG +// SpinWait.SpinUntil(() => Debugger.IsAttached); +// #endif context.RegisterPostInitializationOutput(static ctx => ctx.AddSource( "CmdAttribute.g.cs", SourceText.From(ATTRIBUTE, Encoding.UTF8))); @@ -90,9 +94,17 @@ public class CmdAttribute : System.Attribute foreach (var model in models) { - var source = GetSourceText(model); - ctx.AddSource($"{model.Namespace}.{string.Join(".", model.ClassHierarchy)}.g.cs", - SourceText.From(source, Encoding.UTF8)); + var name = $"{model.Namespace}.{string.Join(".", model.ClassHierarchy)}.g.cs"; + try + { + Debug.WriteLine($"Writing {name}"); + var source = GetSourceText(model); + ctx.AddSource(name, SourceText.From(source, Encoding.UTF8)); + } + catch (Exception ex) + { + Debug.WriteLine($"Error writing source file {name}\n" + ex); + } } } @@ -226,25 +238,6 @@ public class CmdAttribute : System.Attribute return methodModel; } - // private static IEnumerable GetParams(Compilation compilation, MethodDeclarationSyntax method) - // { - // var semModel = compilation.GetSemanticModel(method.SyntaxTree); - // return method.ParameterList.Parameters.Select(p => - // { - // var prefix = string.Empty; - // - // var typeSymbol = semModel.GetTypeInfo(p).Type; - // - // if (p.Modifiers.Any(static x => x.IsKind(SyntaxKind.ParamsKeyword))) - // prefix += "params "; - // return prefix + $"{typeSymbol?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)} {p.Identifier.ToString()}"; - // }); - // // foreach (var param in method.ParameterList.Parameters) - // // { - // // yield return param.ToString(); - // // } - // } - //https://github.com/andrewlock/NetEscapades.EnumGenerators/blob/main/src/NetEscapades.EnumGenerators/EnumGenerator.cs static string? GetNamespace(MethodDeclarationSyntax declarationSyntax) { @@ -308,7 +301,7 @@ public class CmdAttribute : System.Attribute if (cancel.IsCancellationRequested) return default; - var symbol = ModelExtensions.GetSymbolInfo(ctx.SemanticModel, attSyntax).Symbol; + var symbol = ctx.SemanticModel.GetSymbolInfo(attSyntax).Symbol; if (symbol is not IMethodSymbol attSymbol) continue; diff --git a/src/NadekoBot.Generators/NadekoBot.Generators.csproj b/src/NadekoBot.Generators/NadekoBot.Generators.csproj index 81ee29c8d..4ff08c5d9 100644 --- a/src/NadekoBot.Generators/NadekoBot.Generators.csproj +++ b/src/NadekoBot.Generators/NadekoBot.Generators.csproj @@ -1,9 +1,10 @@ - + netstandard2.0 latest false + true diff --git a/src/NadekoBot.VotesApi/NadekoBot.VotesApi.csproj b/src/NadekoBot.VotesApi/NadekoBot.VotesApi.csproj index 2a8dfaa06..2ceaa9633 100644 --- a/src/NadekoBot.VotesApi/NadekoBot.VotesApi.csproj +++ b/src/NadekoBot.VotesApi/NadekoBot.VotesApi.csproj @@ -1,7 +1,7 @@ - + - net5.0 + net6.0 Linux diff --git a/src/NadekoBot/Bot.cs b/src/NadekoBot/Bot.cs index 8b5c79fee..86340f879 100644 --- a/src/NadekoBot/Bot.cs +++ b/src/NadekoBot/Bot.cs @@ -23,6 +23,8 @@ public sealed class Bot public string Mention { get; private set; } public bool IsReady { get; private set; } + public int ShardId { get; set; } + private readonly IBotCredentials _creds; private readonly CommandService _commandService; private readonly DbService _db; @@ -34,6 +36,7 @@ public sealed class Bot if (shardId < 0) throw new ArgumentOutOfRangeException(nameof(shardId)); + ShardId = shardId; _credsProvider = new BotCredsProvider(totalShards); _creds = _credsProvider.GetCreds(); @@ -64,6 +67,7 @@ public sealed class Bot #endif } + public List GetCurrentGuildIds() => Client.Guilds.Select(x => x.Id).ToList();