NadekoBot.Extensions should now be fully annotated with nullable reference types as well as many classes from NadekoBot.Common

This commit is contained in:
Kwoth
2021-12-28 10:44:00 +01:00
parent 0634470a8a
commit 59f5056035
543 changed files with 1895 additions and 1448 deletions

View File

@@ -1,9 +1,13 @@
root = true
# Remove the line below if you want to inherit .editorconfig settings from higher directories
[obj/**]
generated_code = true
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
@@ -263,7 +267,7 @@ dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, int
dotnet_naming_symbols.non_field_members.required_modifiers =
dotnet_naming_symbols.private_readonly_field.applicable_kinds = field
dotnet_naming_symbols.private_readonly_field.applicable_accessibilities = private
dotnet_naming_symbols.private_readonly_field.applicable_accessibilities = private, protected
dotnet_naming_symbols.private_readonly_field.required_modifiers = readonly
dotnet_naming_symbols.private_field.applicable_kinds = field
@@ -327,7 +331,7 @@ resharper_wrap_before_invocation_rpar = false
resharper_csharp_wrap_after_declaration_lpar = true
resharper_csharp_wrap_before_invocation_rpar = true
resharper_csharp_wrap_parameters_style = chop_if_long
resharper_force_chop_compound_if_expression = true
resharper_force_chop_compound_if_expression = false
resharper_keep_existing_linebreaks = false
resharper_max_formal_parameters_on_line = 3
resharper_wrap_chained_binary_expressions = chop_if_long

View File

@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
#nullable disable
using Microsoft.Extensions.DependencyInjection;
using NadekoBot.Services.Database.Models;
using System.Collections.Immutable;
using System.Diagnostics;
@@ -54,6 +55,7 @@ public sealed class Bot
AlwaysDownloadUsers = false,
AlwaysResolveStickers = false,
AlwaysDownloadDefaultStickers = false,
GatewayIntents = GatewayIntents.All,
});
_commandService = new(new()
@@ -354,4 +356,4 @@ public sealed class Bot
await RunAsync().ConfigureAwait(false);
await Task.Delay(-1).ConfigureAwait(false);
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public enum AddRemove
{
@@ -6,4 +7,4 @@ public enum AddRemove
Remove = int.MinValue + 1,
Rem = int.MinValue + 1,
Rm = int.MinValue + 1,
}
}

View File

@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
#nullable disable
using System.Runtime.CompilerServices;
namespace NadekoBot.Common;
@@ -16,4 +17,4 @@ public class AsyncLazy<T> : Lazy<Task<T>>
public TaskAwaiter<T> GetAwaiter()
=> Value.GetAwaiter();
}
}

View File

@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
namespace NadekoBot.Common.Attributes;
@@ -9,4 +9,4 @@ public sealed class AliasesAttribute : AliasAttribute
: base(CommandNameLoadHelper.GetAliasesFor(memberName))
{
}
}
}

View File

@@ -1,4 +1,4 @@
namespace NadekoBot.Common.Attributes;
namespace NadekoBot.Common.Attributes;
public static class CommandNameLoadHelper
{
@@ -26,4 +26,4 @@ public static class CommandNameLoadHelper
: methodName;
return toReturn;
}
}
}

View File

@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
namespace NadekoBot.Common.Attributes;
@@ -10,4 +10,4 @@ public sealed class NadekoCommandAttribute : CommandAttribute
=> this.MethodName = memberName.ToLowerInvariant();
public string MethodName { get; }
}
}

View File

@@ -1,4 +1,4 @@
namespace NadekoBot.Common.Attributes;
namespace NadekoBot.Common.Attributes;
[AttributeUsage(AttributeTargets.Class)]
internal sealed class NadekoModuleAttribute : GroupAttribute
@@ -7,4 +7,4 @@ internal sealed class NadekoModuleAttribute : GroupAttribute
: base(moduleName)
{
}
}
}

View File

@@ -1,4 +1,4 @@
namespace NadekoBot.Common.Attributes;
namespace NadekoBot.Common.Attributes;
[AttributeUsage(AttributeTargets.Method)]
public sealed class NadekoOptionsAttribute : Attribute
@@ -7,4 +7,4 @@ public sealed class NadekoOptionsAttribute : Attribute
public NadekoOptionsAttribute(Type t)
=> this.OptionType = t;
}
}

View File

@@ -1,4 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
namespace NadekoBot.Common.Attributes;
@@ -17,4 +17,4 @@ public sealed class OwnerOnlyAttribute : PreconditionAttribute
: PreconditionResult.FromError("Not owner")
);
}
}
}

View File

@@ -1,4 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
namespace NadekoBot.Common.Attributes;
@@ -33,4 +33,4 @@ public sealed class RatelimitAttribute : PreconditionAttribute
return Task.FromResult(PreconditionResult.FromError(msgContent));
}
}
}

View File

@@ -1,9 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using NadekoBot.Modules.Administration.Services;
namespace Discord;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
[AttributeUsage(AttributeTargets.Method)]
public class UserPermAttribute : RequireUserPermissionAttribute
{
public override Task<PreconditionResult> CheckPermissionsAsync(
@@ -27,4 +27,4 @@ public class UserPermAttribute : RequireUserPermissionAttribute
: base(permission)
{
}
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Common;
@@ -13,4 +14,4 @@ public class CmdStrings
Usages = usages;
Description = description;
}
}
}

View File

@@ -1,4 +1,5 @@
// License MIT
#nullable disable
// License MIT
// Source: https://github.com/i3arnon/ConcurrentHashSet
using System.Diagnostics;
@@ -810,4 +811,4 @@ public sealed class ConcurrentHashSet<T> : IReadOnlyCollection<T>, ICollection<T
Next = next;
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections;
#nullable disable
using System.Collections;
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Common.Collections;
@@ -142,4 +143,4 @@ public class IndexedCollection<T> : IList<T>
}
}
}
}
}

View File

@@ -1,8 +1,9 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public class CommandData
{
public string Cmd { get; set; }
public string Desc { get; set; }
public string[] Usage { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using System.Globalization;
#nullable disable
using System.Globalization;
using Cloneable;
using NadekoBot.Common.Yml;
using SixLabors.ImageSharp.PixelFormats;
@@ -188,4 +189,4 @@ public enum ConsoleOutputType
Normal = 0,
Simple = 1,
None = 2,
}
}

View File

@@ -1,4 +1,4 @@
namespace NadekoBot.Common.Configs;
namespace NadekoBot.Common.Configs;
/// <summary>
/// Base interface for available config serializers
@@ -8,10 +8,11 @@ public interface IConfigSeria
/// <summary>
/// Serialize the object to string
/// </summary>
public string Serialize<T>(T obj);
public string Serialize<T>(T obj)
where T: notnull;
/// <summary>
/// Deserialize string data into an object of the specified type
/// </summary>
public T Deserialize<T>(string data);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Common.Yml;
#nullable disable
using NadekoBot.Common.Yml;
namespace NadekoBot.Common;
@@ -238,4 +239,4 @@ This should be equivalent to the DiscordsKey in your NadekoBot.Votes api appsett
public string Args { get; set; }
}
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public class DownloadTracker : INService
{
@@ -32,4 +33,4 @@ public class DownloadTracker : INService
_downloadUsersSemaphore.Release();
}
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public static class Helpers
{
@@ -9,4 +10,4 @@ public static class Helpers
Environment.Exit(exitCode);
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot;
#nullable disable
namespace NadekoBot;
public interface IBotCredentials
{
@@ -26,4 +27,4 @@ public class RestartConfig
{
public string Cmd { get; set; }
public string Args { get; set; }
}
}

View File

@@ -1,7 +1,8 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public interface ICloneable<T>
where T : new()
{
public T Clone();
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot;
#nullable disable
namespace NadekoBot;
public interface IEmbedBuilder
{
@@ -19,4 +20,4 @@ public enum EmbedColor
Ok,
Pending,
Error,
}
}

View File

@@ -1,6 +1,7 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public interface INadekoCommandOptions
{
void NormalizeOptions();
}
}

View File

@@ -1,6 +1,7 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public interface IPlaceholderProvider
{
public IEnumerable<(string Name, Func<string> Func)> GetPlaceholders();
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Common.Yml;
#nullable disable
using NadekoBot.Common.Yml;
namespace NadekoBot.Common;
@@ -45,4 +46,4 @@ public class ImageUrls
{
public Uri Bg { get; set; }
}
}
}

View File

@@ -1,4 +1,4 @@
using System.Globalization;
using System.Globalization;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -11,4 +11,4 @@ public class CultureInfoConverter : JsonConverter<CultureInfo>
public override void Write(Utf8JsonWriter writer, CultureInfo value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.Name);
}
}

View File

@@ -1,4 +1,4 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.PixelFormats;
using System.Text.Json;
using System.Text.Json.Serialization;
@@ -11,4 +11,4 @@ public class Rgba32Converter : JsonConverter<Rgba32>
public override void Write(Utf8JsonWriter writer, Rgba32 value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToHex());
}
}

View File

@@ -1,4 +1,5 @@
using System.Runtime.CompilerServices;
#nullable disable
using System.Runtime.CompilerServices;
namespace NadekoBot.Common;
@@ -95,4 +96,4 @@ public readonly struct kwum : IEquatable<kwum>
public override int GetHashCode()
=> _value.GetHashCode();
}
}

View File

@@ -1,4 +1,5 @@
using CommandLine;
#nullable disable
using CommandLine;
namespace NadekoBot.Common;
@@ -14,4 +15,4 @@ public class LbOpts : INadekoCommandOptions
public void NormalizeOptions()
{
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Net;
#nullable disable
using System.Net;
using System.Runtime.CompilerServices;
namespace NadekoBot.Common;
@@ -52,4 +53,4 @@ public class LoginErrorHandler
Log.Fatal(ex, "Fatal error occurred while loading credentials");
}
}
}

View File

@@ -1,4 +1,4 @@
namespace NadekoBot.Common.ModuleBehaviors;
namespace NadekoBot.Common.ModuleBehaviors;
/// <summary>
/// Implemented by modules which block execution before anything is executed
@@ -7,4 +7,4 @@ public interface IEarlyBehavior
{
int Priority { get; }
Task<bool> RunBehavior(IGuild guild, IUserMessage msg);
}
}

View File

@@ -1,4 +1,4 @@
namespace NadekoBot.Common.ModuleBehaviors;
namespace NadekoBot.Common.ModuleBehaviors;
public interface IInputTransformer
{
@@ -7,4 +7,4 @@ public interface IInputTransformer
IMessageChannel channel,
IUser user,
string input);
}
}

View File

@@ -1,8 +1,8 @@
namespace NadekoBot.Common.ModuleBehaviors;
namespace NadekoBot.Common.ModuleBehaviors;
public interface ILateBlocker
{
public int Priority { get; }
Task<bool> TryBlockLate(ICommandContext context, string moduleName, CommandInfo command);
}
}

View File

@@ -1,4 +1,4 @@
namespace NadekoBot.Common.ModuleBehaviors;
namespace NadekoBot.Common.ModuleBehaviors;
/// <summary>
/// Last thing to be executed, won't stop further executions
@@ -6,4 +6,4 @@
public interface ILateExecutor
{
Task LateExecute(IGuild guild, IUserMessage msg);
}
}

View File

@@ -1,4 +1,4 @@
namespace NadekoBot.Common.ModuleBehaviors;
namespace NadekoBot.Common.ModuleBehaviors;
/// <summary>
/// All services which need to execute something after
@@ -10,4 +10,4 @@ public interface IReadyExecutor
/// Executed when bot is ready
/// </summary>
public Task OnReadyAsync();
}
}

View File

@@ -1,4 +1,5 @@
using System.Globalization;
#nullable disable
using System.Globalization;
// ReSharper disable InconsistentNaming
namespace NadekoBot.Modules;
@@ -164,4 +165,4 @@ public abstract class NadekoSubmodule : NadekoModule
public abstract class NadekoSubmodule<TService> : NadekoModule<TService>
{
}
}

View File

@@ -1,4 +1,5 @@
using System.Security.Cryptography;
#nullable disable
using System.Security.Cryptography;
namespace NadekoBot.Common;
@@ -66,4 +67,4 @@ public class NadekoRandom : Random
_rng.GetBytes(bytes);
return BitConverter.ToDouble(bytes, 0);
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
#nullable disable
using System.Diagnostics.CodeAnalysis;
namespace NadekoBot.Common;
@@ -14,4 +15,4 @@ public sealed class NoPublicBotAttribute : PreconditionAttribute
return Task.FromResult(PreconditionResult.FromSuccess());
#endif
}
}
}

View File

@@ -1,3 +1,4 @@
#nullable disable
namespace NadekoBot.Common;
public class OldImageUrls
@@ -43,4 +44,4 @@ public class OldImageUrls
{
public Uri Bg { get; set; }
}
}
}

View File

@@ -1,4 +1,5 @@
using CommandLine;
#nullable disable
using CommandLine;
namespace NadekoBot.Common;
@@ -21,4 +22,4 @@ public static class OptionsParser
options.NormalizeOptions();
return (options, res.Tag == ParserResultType.Parsed);
}
}
}

View File

@@ -1,8 +1,9 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public class OsuMapData
{
public string Title { get; set; }
public string Artist { get; set; }
public string Version { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Common;
@@ -54,4 +55,4 @@ public class OsuUserBests
[JsonProperty("replay_available")]
public string ReplayAvailable { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public static class PlatformHelper
{
@@ -22,4 +23,4 @@ public static class PlatformHelper
return processorCount;
}
}
}
}

View File

@@ -1,7 +1,8 @@
namespace NadekoBot.Common.Pokemon;
#nullable disable
namespace NadekoBot.Common.Pokemon;
public class PokemonNameId
{
public int Id { get; set; }
public string Name { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot.Common.Pokemon;
@@ -37,4 +38,4 @@ public class SearchPokemon
public string Color { get; set; }
public string[] Evos { get; set; }
public string[] EggGroups { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.Pokemon;
#nullable disable
namespace NadekoBot.Common.Pokemon;
public class SearchPokemonAbility
{
@@ -6,4 +7,4 @@ public class SearchPokemonAbility
public string ShortDesc { get; set; }
public string Name { get; set; }
public float Rating { get; set; }
}
}

View File

@@ -1,13 +1,13 @@
namespace NadekoBot.Common;
namespace NadekoBot.Common;
public class EventPubSub : IPubSub
{
private readonly Dictionary<string, Dictionary<Delegate, List<Func<object, ValueTask>>>> _actions = new();
private readonly Dictionary<string, Dictionary<Delegate, List<Func<object?, ValueTask>>>> _actions = new();
private readonly object _locker = new();
public Task Sub<TData>(in TypedKey<TData> key, Func<TData, ValueTask> action)
public Task Sub<TData>(in TypedKey<TData> key, Func<TData?, ValueTask> action)
{
Func<object, ValueTask> localAction = obj => action((TData)obj);
Func<object?, ValueTask> localAction = obj => action((TData?)obj);
lock (_locker)
{
if (!_actions.TryGetValue(key.Key, out var keyActions))
@@ -79,4 +79,4 @@ public class EventPubSub : IPubSub
return Task.CompletedTask;
}
}
}
}

View File

@@ -1,7 +1,7 @@
namespace NadekoBot.Common;
namespace NadekoBot.Common;
public interface IPubSub
{
public Task Pub<TData>(in TypedKey<TData> key, TData data);
public Task Sub<TData>(in TypedKey<TData> key, Func<TData, ValueTask> action);
}
public Task Sub<TData>(in TypedKey<TData> key, Func<TData?, ValueTask> action);
}

View File

@@ -1,7 +1,7 @@
namespace NadekoBot.Common;
namespace NadekoBot.Common;
public interface ISeria
{
byte[] Serialize<T>(T data);
T Deserialize<T>(byte[] data);
}
T? Deserialize<T>(byte[]? data);
}

View File

@@ -1,4 +1,4 @@
using System.Text.Json;
using System.Text.Json;
using NadekoBot.Common.JsonConverters;
namespace NadekoBot.Common;
@@ -13,11 +13,11 @@ public class JsonSeria : ISeria
public byte[] Serialize<T>(T data)
=> JsonSerializer.SerializeToUtf8Bytes(data, _serializerOptions);
public T Deserialize<T>(byte[] data)
public T? Deserialize<T>(byte[]? data)
{
if (data is null)
return default;
return JsonSerializer.Deserialize<T>(data, _serializerOptions);
}
}
}

View File

@@ -1,4 +1,4 @@
using StackExchange.Redis;
using StackExchange.Redis;
namespace NadekoBot.Common;
@@ -22,7 +22,7 @@ public sealed class RedisPubSub : IPubSub
.PublishAsync($"{_creds.RedisKey()}:{key.Key}", serialized, CommandFlags.FireAndForget);
}
public Task Sub<TData>(in TypedKey<TData> key, Func<TData, ValueTask> action)
public Task Sub<TData>(in TypedKey<TData> key, Func<TData?, ValueTask> action)
{
var eventName = key.Key;
@@ -41,4 +41,4 @@ public sealed class RedisPubSub : IPubSub
return _multi.GetSubscriber().SubscribeAsync($"{_creds.RedisKey()}:{eventName}", OnSubscribeHandler);
}
}
}

View File

@@ -1,4 +1,4 @@
namespace NadekoBot.Common;
namespace NadekoBot.Common;
public readonly struct TypedKey<TData>
{
@@ -19,7 +19,7 @@ public readonly struct TypedKey<TData>
public static bool operator !=(in TypedKey<TData> left, in TypedKey<TData> right)
=> !(left == right);
public override bool Equals(object obj)
public override bool Equals(object? obj)
=> obj is TypedKey<TData> o && o == this;
public override int GetHashCode()
@@ -27,4 +27,4 @@ public readonly struct TypedKey<TData>
public override string ToString()
=> Key;
}
}

View File

@@ -22,6 +22,7 @@ public class YamlSeria : IConfigSeria
}
public string Serialize<T>(T obj)
where T: notnull
{
var escapedOutput = _serializer.Serialize(obj);
var output = _codePointRegex.Replace(escapedOutput,
@@ -37,4 +38,4 @@ public class YamlSeria : IConfigSeria
public T Deserialize<T>(string data)
=> _deserializer.Deserialize<T>(data);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Administration.Services;
#nullable disable
using NadekoBot.Modules.Administration.Services;
using System.Text.RegularExpressions;
namespace NadekoBot.Common;
@@ -56,6 +57,7 @@ public class ReplacementBuilder
public ReplacementBuilder WithServer(DiscordSocketClient client, SocketGuild g)
{
_reps.TryAdd("%server%", () => g is null ? "DM" : g.Name);
_reps.TryAdd("%server.id%", () => g is null ? "DM" : g.Id.ToString());
_reps.TryAdd("%server.name%", () => g is null ? "DM" : g.Name);
_reps.TryAdd("%server.members%", () => g is { } sg ? sg.MemberCount.ToString() : "?");
@@ -97,6 +99,7 @@ public class ReplacementBuilder
public ReplacementBuilder WithManyUsers(IEnumerable<IUser> users)
{
_reps.TryAdd("%user%", () => string.Join(" ", users.Select(user => user.Mention)));
_reps.TryAdd("%user.mention%", () => string.Join(" ", users.Select(user => user.Mention)));
_reps.TryAdd("%user.fullname%", () => string.Join(" ", users.Select(user => user.ToString())));
_reps.TryAdd("%user.name%", () => string.Join(" ", users.Select(user => user.Username)));
@@ -171,4 +174,4 @@ public class ReplacementBuilder
return this;
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
#nullable disable
using System.Text.RegularExpressions;
namespace NadekoBot.Common;
@@ -89,4 +90,4 @@ public class Replacer
return newEmbedData;
}
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace NadekoBot.Common;
@@ -11,4 +12,4 @@ public class RequireObjectPropertiesContractResolver : DefaultContractResolver
contract.ItemRequired = Required.DisallowNull;
return contract;
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public struct ShmartNumber : IEquatable<ShmartNumber>
{
@@ -37,4 +38,4 @@ public struct ShmartNumber : IEquatable<ShmartNumber>
public static bool operator !=(ShmartNumber left, ShmartNumber right)
=> !(left == right);
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot;
#nullable disable
namespace NadekoBot;
public sealed record SmartEmbedText : SmartText
{
@@ -115,4 +116,4 @@ public sealed record SmartEmbedText : SmartText
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot;
#nullable disable
namespace NadekoBot;
public sealed record SmartPlainText : SmartText
{
@@ -15,4 +16,4 @@ public sealed record SmartPlainText : SmartText
public override string ToString()
=> Text;
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot;
@@ -55,4 +56,4 @@ public abstract record SmartText
return new SmartPlainText(input);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot;
@@ -8,4 +9,4 @@ public class SmartTextEmbedAuthor
[JsonProperty("icon_url")]
public string IconUrl { get; set; }
public string Url { get; set; }
}
}

View File

@@ -1,8 +1,9 @@
namespace NadekoBot;
#nullable disable
namespace NadekoBot;
public class SmartTextEmbedField
{
public string Name { get; set; }
public string Value { get; set; }
public bool Inline { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Newtonsoft.Json;
#nullable disable
using Newtonsoft.Json;
namespace NadekoBot;
@@ -9,4 +10,4 @@ public class SmartTextEmbedFooter
public string Text { get; set; }
[JsonProperty("icon_url")]
public string IconUrl { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common;
#nullable disable
namespace NadekoBot.Common;
public sealed class ReactionEventWrapper : IDisposable
{
@@ -93,4 +94,4 @@ public sealed class ReactionEventWrapper : IDisposable
disposing = true;
UnsubAll();
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.CustomReactions.Services;
#nullable disable
using NadekoBot.Modules.CustomReactions.Services;
namespace NadekoBot.Common.TypeReaders;
@@ -84,4 +85,4 @@ public class CommandOrCrInfo
this.Name = input;
this.CmdType = type;
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.TypeReaders;
#nullable disable
namespace NadekoBot.Common.TypeReaders;
public sealed class EmoteTypeReader : NadekoTypeReader<Emote>
{
@@ -9,4 +10,4 @@ public sealed class EmoteTypeReader : NadekoTypeReader<Emote>
return Task.FromResult(TypeReaderResult.FromSuccess(emote));
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.Administration.Services;
#nullable disable
using NadekoBot.Modules.Administration.Services;
namespace NadekoBot.Common.TypeReaders;
@@ -47,4 +48,4 @@ public class GuildDateTime
InputTime = inputTime;
InputTimeUtc = TimeZoneInfo.ConvertTime(inputTime, Timezone, TimeZoneInfo.Utc);
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.TypeReaders;
#nullable disable
namespace NadekoBot.Common.TypeReaders;
public sealed class GuildTypeReader : NadekoTypeReader<IGuild>
{
@@ -19,4 +20,4 @@ public sealed class GuildTypeReader : NadekoTypeReader<IGuild>
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "No guild by that name or Id found"));
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.TypeReaders;
#nullable disable
namespace NadekoBot.Common.TypeReaders;
public sealed class KwumTypeReader : NadekoTypeReader<kwum>
{
@@ -15,4 +16,4 @@ public sealed class SmartTextTypeReader : NadekoTypeReader<SmartText>
{
public override Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input)
=> Task.FromResult(TypeReaderResult.FromSuccess(SmartText.CreateFrom(input)));
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.TypeReaders.Models;
#nullable disable
namespace NadekoBot.Common.TypeReaders.Models;
public class PermissionAction
{
@@ -21,4 +22,4 @@ public class PermissionAction
}
public override int GetHashCode() => Value.GetHashCode();
}
}

View File

@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
#nullable disable
using System.Text.RegularExpressions;
namespace NadekoBot.Common.TypeReaders.Models;
@@ -59,4 +60,4 @@ public class StoopidTime
Time = ts,
};
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.TypeReaders;
#nullable disable
namespace NadekoBot.Common.TypeReaders;
public sealed class ModuleTypeReader : NadekoTypeReader<ModuleInfo>
{
@@ -44,4 +45,4 @@ public sealed class ModuleOrCrTypeReader : NadekoTypeReader<ModuleOrCrInfo>
public sealed class ModuleOrCrInfo
{
public string Name { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.TypeReaders;
#nullable disable
namespace NadekoBot.Common.TypeReaders;
[MeansImplicitUse(ImplicitUseTargetFlags.Default | ImplicitUseTargetFlags.WithInheritors )]
public abstract class NadekoTypeReader<T> : TypeReader
@@ -7,4 +8,4 @@ public abstract class NadekoTypeReader<T> : TypeReader
public override Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input, IServiceProvider services)
=> ReadAsync(ctx, input);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Common.TypeReaders.Models;
#nullable disable
using NadekoBot.Common.TypeReaders.Models;
namespace NadekoBot.Common.TypeReaders;
@@ -34,4 +35,4 @@ public sealed class PermissionActionTypeReader : NadekoTypeReader<PermissionActi
return Task.FromResult(TypeReaderResult.FromError(CommandError.ParseFailed, "Did not receive a valid boolean value"));
}
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.TypeReaders;
#nullable disable
namespace NadekoBot.Common.TypeReaders;
using Color = SixLabors.ImageSharp.Color;
public sealed class Rgba32TypeReader : NadekoTypeReader<Color>
@@ -17,4 +18,4 @@ public sealed class Rgba32TypeReader : NadekoTypeReader<Color>
return TypeReaderResult.FromError(CommandError.ParseFailed, "Parameter is not a valid color hex.");
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Text.RegularExpressions;
#nullable disable
using System.Text.RegularExpressions;
using NadekoBot.Db;
using NadekoBot.Modules.Gambling.Services;
@@ -96,4 +97,4 @@ public sealed class ShmartNumberTypeReader : NadekoTypeReader<ShmartNumber>
return false;
}
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Common.TypeReaders.Models;
#nullable disable
using NadekoBot.Common.TypeReaders.Models;
namespace NadekoBot.Common.TypeReaders;
@@ -18,4 +19,4 @@ public sealed class StoopidTimeTypeReader : NadekoTypeReader<StoopidTime>
return Task.FromResult(TypeReaderResult.FromError(CommandError.Exception, ex.Message));
}
}
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.Yml;
#nullable disable
namespace NadekoBot.Common.Yml;
public class CommentAttribute : Attribute
{
@@ -6,4 +7,4 @@ public class CommentAttribute : Attribute
public CommentAttribute(string comment)
=> Comment = comment;
}
}

View File

@@ -1,4 +1,5 @@
using YamlDotNet.Core;
#nullable disable
using YamlDotNet.Core;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.TypeInspectors;
@@ -61,4 +62,4 @@ public class CommentGatheringTypeInspector : TypeInspectorSkeleton
: baseDescriptor.Read(target);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using YamlDotNet.Core;
#nullable disable
using YamlDotNet.Core;
using YamlDotNet.Serialization;
namespace NadekoBot.Common.Yml;
@@ -26,4 +27,4 @@ public sealed class CommentsObjectDescriptor : IObjectDescriptor
public ScalarStyle ScalarStyle
=> innerDescriptor.ScalarStyle;
}
}

View File

@@ -1,4 +1,5 @@
using YamlDotNet.Core;
#nullable disable
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.ObjectGraphVisitors;
@@ -22,4 +23,4 @@ public class CommentsObjectGraphVisitor : ChainedObjectGraphVisitor
return base.EnterMapping(key, value, context);
}
}
}

View File

@@ -1,4 +1,5 @@
using YamlDotNet.Core;
#nullable disable
using YamlDotNet.Core;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.EventEmitters;
@@ -26,4 +27,4 @@ public class MultilineScalarFlowStyleEmitter : ChainedEventEmitter
nextEmitter.Emit(eventInfo, emitter);
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Globalization;
#nullable disable
using System.Globalization;
using SixLabors.ImageSharp.PixelFormats;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
@@ -43,4 +44,4 @@ public class CultureInfoConverter : IYamlTypeConverter
var ci = (CultureInfo)value;
emitter.Emit(new Scalar(ci.Name));
}
}
}

View File

@@ -1,4 +1,5 @@
using YamlDotNet.Core;
#nullable disable
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Serialization;
@@ -21,4 +22,4 @@ public class UriConverter : IYamlTypeConverter
var uri = (Uri)value;
emitter.Emit(new Scalar(uri.ToString()));
}
}
}

View File

@@ -1,4 +1,5 @@
using YamlDotNet.Serialization;
#nullable disable
using YamlDotNet.Serialization;
namespace NadekoBot.Common.Yml;
@@ -23,4 +24,4 @@ public class Yaml
.WithTypeConverter(new UriConverter())
.IgnoreUnmatchedProperties()
.Build();
}
}

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.Yml;
#nullable disable
namespace NadekoBot.Common.Yml;
public class YamlHelper
{
@@ -52,4 +53,4 @@ public class YamlHelper
return c - 'a' + 10;
}
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Db.Models;
namespace NadekoBot.Db;
@@ -33,4 +34,4 @@ public static class ClubExtensions
public static List<ClubInfo> GetClubLeaderboardPage(this DbSet<ClubInfo> clubs, int page)
=> clubs.AsNoTracking().OrderByDescending(x => x.Xp).Skip(page * 9).Take(9).ToList();
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db;
@@ -13,4 +14,4 @@ public static class CurrencyTransactionExtensions
.Skip(15 * page)
.Take(15)
.ToList();
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using LinqToDB;
using NadekoBot.Services.Database.Models;
@@ -14,4 +15,4 @@ public static class CustomReactionsExtensions
public static CustomReaction GetByGuildIdAndInput(this DbSet<CustomReaction> crs, ulong? guildId, string input)
=> crs.FirstOrDefault(x => x.GuildId == guildId && x.Trigger.ToUpper() == input);
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db;
@@ -8,4 +9,4 @@ public static class DbExtensions
public static T GetById<T>(this DbSet<T> set, int id)
where T : DbEntity
=> set.FirstOrDefault(x => x.Id == id);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Db.Models;
#nullable disable
using NadekoBot.Db.Models;
using Microsoft.EntityFrameworkCore;
using LinqToDB;
using LinqToDB.EntityFrameworkCore;
@@ -185,4 +186,4 @@ VALUES ({userId}, {name}, {discrim}, {avatarId}, {amount}, 0);
.OrderByDescending(x => x.CurrencyAmount)
.Take(users.Count() / 100 == 0 ? 1 : users.Count() / 100)
.Sum(x => x.CurrencyAmount);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Services.Database.Models;
#nullable disable
using NadekoBot.Services.Database.Models;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database;
using NadekoBot.Db.Models;
@@ -201,4 +202,4 @@ public static class GuildConfigExtensions
.SelectMany(x => x.GenerateCurrencyChannelIds)
.Select(x => new GeneratingChannel() { ChannelId = x.ChannelId, GuildId = x.GuildConfig.GuildId })
.ToArray();
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db;
@@ -20,4 +21,4 @@ public static class MusicPlayerSettingsExtensions
return toReturn;
}
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db;
@@ -20,4 +21,4 @@ public static class MusicPlaylistExtensions
public static MusicPlaylist GetWithSongs(this DbSet<MusicPlaylist> playlists, int id)
=> playlists.Include(mpl => mpl.Songs)
.FirstOrDefault(mpl => mpl.Id == id);
}
}

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
#nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database;
using NadekoBot.Services.Database.Models;
@@ -34,4 +35,4 @@ public static class PollExtensions
ctx.Poll.Remove(p);
}
}
}

View File

@@ -1,3 +1,4 @@
#nullable disable
using NadekoBot.Services.Database.Models;
using Microsoft.EntityFrameworkCore;
@@ -60,4 +61,4 @@ public static class QuoteExtensions
=> quotes.RemoveRange(quotes.AsQueryable()
.Where(x => x.GuildId == guildId && x.Keyword.ToUpper() == keyword)
);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Services.Database.Models;
#nullable disable
using NadekoBot.Services.Database.Models;
using Microsoft.EntityFrameworkCore;
namespace NadekoBot.Db;
@@ -25,4 +26,4 @@ public static class ReminderExtensions
.OrderBy(x => x.DateAdded)
.Skip(page * 10)
.Take(10);
}
}

View File

@@ -1,4 +1,5 @@
using NadekoBot.Services.Database.Models;
#nullable disable
using NadekoBot.Services.Database.Models;
using Microsoft.EntityFrameworkCore;
namespace NadekoBot.Db;
@@ -20,4 +21,4 @@ public static class SelfAssignableRolesExtensions
=> roles.AsQueryable()
.Where(s => s.GuildId == guildId)
.ToArray();
}
}

Some files were not shown because too many files have changed in this diff Show More