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 root = true
# Remove the line below if you want to inherit .editorconfig settings from higher directories # Remove the line below if you want to inherit .editorconfig settings from higher directories
[obj/**]
generated_code = true
# C# files # C# files
[*.cs] [*.cs]
#### Core EditorConfig Options #### #### Core EditorConfig Options ####
# Indentation and spacing # 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.non_field_members.required_modifiers =
dotnet_naming_symbols.private_readonly_field.applicable_kinds = field 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_readonly_field.required_modifiers = readonly
dotnet_naming_symbols.private_field.applicable_kinds = field 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_after_declaration_lpar = true
resharper_csharp_wrap_before_invocation_rpar = true resharper_csharp_wrap_before_invocation_rpar = true
resharper_csharp_wrap_parameters_style = chop_if_long 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_keep_existing_linebreaks = false
resharper_max_formal_parameters_on_line = 3 resharper_max_formal_parameters_on_line = 3
resharper_wrap_chained_binary_expressions = chop_if_long 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 NadekoBot.Services.Database.Models;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics; using System.Diagnostics;
@@ -54,6 +55,7 @@ public sealed class Bot
AlwaysDownloadUsers = false, AlwaysDownloadUsers = false,
AlwaysResolveStickers = false, AlwaysResolveStickers = false,
AlwaysDownloadDefaultStickers = false, AlwaysDownloadDefaultStickers = false,
GatewayIntents = GatewayIntents.All,
}); });
_commandService = new(new() _commandService = new(new()
@@ -354,4 +356,4 @@ public sealed class Bot
await RunAsync().ConfigureAwait(false); await RunAsync().ConfigureAwait(false);
await Task.Delay(-1).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 public enum AddRemove
{ {
@@ -6,4 +7,4 @@ public enum AddRemove
Remove = int.MinValue + 1, Remove = int.MinValue + 1,
Rem = int.MinValue + 1, Rem = int.MinValue + 1,
Rm = 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; namespace NadekoBot.Common;
@@ -16,4 +17,4 @@ public class AsyncLazy<T> : Lazy<Task<T>>
public TaskAwaiter<T> GetAwaiter() public TaskAwaiter<T> GetAwaiter()
=> Value.GetAwaiter(); => Value.GetAwaiter();
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace NadekoBot.Common.Attributes; namespace NadekoBot.Common.Attributes;
@@ -33,4 +33,4 @@ public sealed class RatelimitAttribute : PreconditionAttribute
return Task.FromResult(PreconditionResult.FromError(msgContent)); 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; using NadekoBot.Modules.Administration.Services;
namespace Discord; namespace Discord;
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] [AttributeUsage(AttributeTargets.Method)]
public class UserPermAttribute : RequireUserPermissionAttribute public class UserPermAttribute : RequireUserPermissionAttribute
{ {
public override Task<PreconditionResult> CheckPermissionsAsync( public override Task<PreconditionResult> CheckPermissionsAsync(
@@ -27,4 +27,4 @@ public class UserPermAttribute : RequireUserPermissionAttribute
: base(permission) : base(permission)
{ {
} }
} }

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
using System.Collections; #nullable disable
using System.Collections;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
namespace NadekoBot.Common.Collections; 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 class CommandData
{ {
public string Cmd { get; set; } public string Cmd { get; set; }
public string Desc { get; set; } public string Desc { get; set; }
public string[] Usage { get; set; } public string[] Usage { get; set; }
} }

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
namespace NadekoBot; #nullable disable
namespace NadekoBot;
public interface IBotCredentials public interface IBotCredentials
{ {
@@ -26,4 +27,4 @@ public class RestartConfig
{ {
public string Cmd { get; set; } public string Cmd { get; set; }
public string Args { 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> public interface ICloneable<T>
where T : new() where T : new()
{ {
public T Clone(); public T Clone();
} }

View File

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

View File

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

View File

@@ -1,6 +1,7 @@
namespace NadekoBot.Common; #nullable disable
namespace NadekoBot.Common;
public interface IPlaceholderProvider public interface IPlaceholderProvider
{ {
public IEnumerable<(string Name, Func<string> Func)> GetPlaceholders(); 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; namespace NadekoBot.Common;
@@ -45,4 +46,4 @@ public class ImageUrls
{ {
public Uri Bg { get; set; } 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;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -11,4 +11,4 @@ public class CultureInfoConverter : JsonConverter<CultureInfo>
public override void Write(Utf8JsonWriter writer, CultureInfo value, JsonSerializerOptions options) public override void Write(Utf8JsonWriter writer, CultureInfo value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.Name); => 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;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@@ -11,4 +11,4 @@ public class Rgba32Converter : JsonConverter<Rgba32>
public override void Write(Utf8JsonWriter writer, Rgba32 value, JsonSerializerOptions options) public override void Write(Utf8JsonWriter writer, Rgba32 value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToHex()); => writer.WriteStringValue(value.ToHex());
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
using System.Globalization; #nullable disable
using System.Globalization;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
namespace NadekoBot.Modules; namespace NadekoBot.Modules;
@@ -164,4 +165,4 @@ public abstract class NadekoSubmodule : NadekoModule
public abstract class NadekoSubmodule<TService> : NadekoModule<TService> 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; namespace NadekoBot.Common;
@@ -66,4 +67,4 @@ public class NadekoRandom : Random
_rng.GetBytes(bytes); _rng.GetBytes(bytes);
return BitConverter.ToDouble(bytes, 0); return BitConverter.ToDouble(bytes, 0);
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,8 @@
namespace NadekoBot.Common.Pokemon; #nullable disable
namespace NadekoBot.Common.Pokemon;
public class PokemonNameId public class PokemonNameId
{ {
public int Id { get; set; } public int Id { get; set; }
public string Name { 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; namespace NadekoBot.Common.Pokemon;
@@ -37,4 +38,4 @@ public class SearchPokemon
public string Color { get; set; } public string Color { get; set; }
public string[] Evos { get; set; } public string[] Evos { get; set; }
public string[] EggGroups { 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 public class SearchPokemonAbility
{ {
@@ -6,4 +7,4 @@ public class SearchPokemonAbility
public string ShortDesc { get; set; } public string ShortDesc { get; set; }
public string Name { get; set; } public string Name { get; set; }
public float Rating { get; set; } public float Rating { get; set; }
} }

View File

@@ -1,13 +1,13 @@
namespace NadekoBot.Common; namespace NadekoBot.Common;
public class EventPubSub : IPubSub 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(); 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) lock (_locker)
{ {
if (!_actions.TryGetValue(key.Key, out var keyActions)) if (!_actions.TryGetValue(key.Key, out var keyActions))
@@ -79,4 +79,4 @@ public class EventPubSub : IPubSub
return Task.CompletedTask; return Task.CompletedTask;
} }
} }
} }

View File

@@ -1,7 +1,7 @@
namespace NadekoBot.Common; namespace NadekoBot.Common;
public interface IPubSub public interface IPubSub
{ {
public Task Pub<TData>(in TypedKey<TData> key, TData data); 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 public interface ISeria
{ {
byte[] Serialize<T>(T data); 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; using NadekoBot.Common.JsonConverters;
namespace NadekoBot.Common; namespace NadekoBot.Common;
@@ -13,11 +13,11 @@ public class JsonSeria : ISeria
public byte[] Serialize<T>(T data) public byte[] Serialize<T>(T data)
=> JsonSerializer.SerializeToUtf8Bytes(data, _serializerOptions); => JsonSerializer.SerializeToUtf8Bytes(data, _serializerOptions);
public T Deserialize<T>(byte[] data) public T? Deserialize<T>(byte[]? data)
{ {
if (data is null) if (data is null)
return default; return default;
return JsonSerializer.Deserialize<T>(data, _serializerOptions); return JsonSerializer.Deserialize<T>(data, _serializerOptions);
} }
} }

View File

@@ -1,4 +1,4 @@
using StackExchange.Redis; using StackExchange.Redis;
namespace NadekoBot.Common; namespace NadekoBot.Common;
@@ -22,7 +22,7 @@ public sealed class RedisPubSub : IPubSub
.PublishAsync($"{_creds.RedisKey()}:{key.Key}", serialized, CommandFlags.FireAndForget); .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; var eventName = key.Key;
@@ -41,4 +41,4 @@ public sealed class RedisPubSub : IPubSub
return _multi.GetSubscriber().SubscribeAsync($"{_creds.RedisKey()}:{eventName}", OnSubscribeHandler); 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> 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) public static bool operator !=(in TypedKey<TData> left, in TypedKey<TData> right)
=> !(left == right); => !(left == right);
public override bool Equals(object obj) public override bool Equals(object? obj)
=> obj is TypedKey<TData> o && o == this; => obj is TypedKey<TData> o && o == this;
public override int GetHashCode() public override int GetHashCode()
@@ -27,4 +27,4 @@ public readonly struct TypedKey<TData>
public override string ToString() public override string ToString()
=> Key; => Key;
} }

View File

@@ -22,6 +22,7 @@ public class YamlSeria : IConfigSeria
} }
public string Serialize<T>(T obj) public string Serialize<T>(T obj)
where T: notnull
{ {
var escapedOutput = _serializer.Serialize(obj); var escapedOutput = _serializer.Serialize(obj);
var output = _codePointRegex.Replace(escapedOutput, var output = _codePointRegex.Replace(escapedOutput,
@@ -37,4 +38,4 @@ public class YamlSeria : IConfigSeria
public T Deserialize<T>(string data) public T Deserialize<T>(string data)
=> _deserializer.Deserialize<T>(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; using System.Text.RegularExpressions;
namespace NadekoBot.Common; namespace NadekoBot.Common;
@@ -56,6 +57,7 @@ public class ReplacementBuilder
public ReplacementBuilder WithServer(DiscordSocketClient client, SocketGuild g) 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.id%", () => g is null ? "DM" : g.Id.ToString());
_reps.TryAdd("%server.name%", () => g is null ? "DM" : g.Name); _reps.TryAdd("%server.name%", () => g is null ? "DM" : g.Name);
_reps.TryAdd("%server.members%", () => g is { } sg ? sg.MemberCount.ToString() : "?"); _reps.TryAdd("%server.members%", () => g is { } sg ? sg.MemberCount.ToString() : "?");
@@ -97,6 +99,7 @@ public class ReplacementBuilder
public ReplacementBuilder WithManyUsers(IEnumerable<IUser> users) 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.mention%", () => string.Join(" ", users.Select(user => user.Mention)));
_reps.TryAdd("%user.fullname%", () => string.Join(" ", users.Select(user => user.ToString()))); _reps.TryAdd("%user.fullname%", () => string.Join(" ", users.Select(user => user.ToString())));
_reps.TryAdd("%user.name%", () => string.Join(" ", users.Select(user => user.Username))); _reps.TryAdd("%user.name%", () => string.Join(" ", users.Select(user => user.Username)));
@@ -171,4 +174,4 @@ public class ReplacementBuilder
return this; return this;
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
using NadekoBot.Modules.CustomReactions.Services; #nullable disable
using NadekoBot.Modules.CustomReactions.Services;
namespace NadekoBot.Common.TypeReaders; namespace NadekoBot.Common.TypeReaders;
@@ -84,4 +85,4 @@ public class CommandOrCrInfo
this.Name = input; this.Name = input;
this.CmdType = type; 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> public sealed class EmoteTypeReader : NadekoTypeReader<Emote>
{ {
@@ -9,4 +10,4 @@ public sealed class EmoteTypeReader : NadekoTypeReader<Emote>
return Task.FromResult(TypeReaderResult.FromSuccess(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; namespace NadekoBot.Common.TypeReaders;
@@ -47,4 +48,4 @@ public class GuildDateTime
InputTime = inputTime; InputTime = inputTime;
InputTimeUtc = TimeZoneInfo.ConvertTime(inputTime, Timezone, TimeZoneInfo.Utc); 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> 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")); 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> 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) public override Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input)
=> Task.FromResult(TypeReaderResult.FromSuccess(SmartText.CreateFrom(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 public class PermissionAction
{ {
@@ -21,4 +22,4 @@ public class PermissionAction
} }
public override int GetHashCode() => Value.GetHashCode(); 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; namespace NadekoBot.Common.TypeReaders.Models;
@@ -59,4 +60,4 @@ public class StoopidTime
Time = ts, Time = ts,
}; };
} }
} }

View File

@@ -1,4 +1,5 @@
namespace NadekoBot.Common.TypeReaders; #nullable disable
namespace NadekoBot.Common.TypeReaders;
public sealed class ModuleTypeReader : NadekoTypeReader<ModuleInfo> public sealed class ModuleTypeReader : NadekoTypeReader<ModuleInfo>
{ {
@@ -44,4 +45,4 @@ public sealed class ModuleOrCrTypeReader : NadekoTypeReader<ModuleOrCrInfo>
public sealed class ModuleOrCrInfo public sealed class ModuleOrCrInfo
{ {
public string Name { get; set; } 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 )] [MeansImplicitUse(ImplicitUseTargetFlags.Default | ImplicitUseTargetFlags.WithInheritors )]
public abstract class NadekoTypeReader<T> : TypeReader 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) public override Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input, IServiceProvider services)
=> ReadAsync(ctx, input); => 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; 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")); 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; using Color = SixLabors.ImageSharp.Color;
public sealed class Rgba32TypeReader : NadekoTypeReader<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."); 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.Db;
using NadekoBot.Modules.Gambling.Services; using NadekoBot.Modules.Gambling.Services;
@@ -96,4 +97,4 @@ public sealed class ShmartNumberTypeReader : NadekoTypeReader<ShmartNumber>
return false; return false;
} }
} }

View File

@@ -1,4 +1,5 @@
using NadekoBot.Common.TypeReaders.Models; #nullable disable
using NadekoBot.Common.TypeReaders.Models;
namespace NadekoBot.Common.TypeReaders; namespace NadekoBot.Common.TypeReaders;
@@ -18,4 +19,4 @@ public sealed class StoopidTimeTypeReader : NadekoTypeReader<StoopidTime>
return Task.FromResult(TypeReaderResult.FromError(CommandError.Exception, ex.Message)); 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 public class CommentAttribute : Attribute
{ {
@@ -6,4 +7,4 @@ public class CommentAttribute : Attribute
public CommentAttribute(string comment) public CommentAttribute(string comment)
=> Comment = comment; => Comment = comment;
} }

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
using YamlDotNet.Core; #nullable disable
using YamlDotNet.Core;
using YamlDotNet.Core.Events; using YamlDotNet.Core.Events;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.ObjectGraphVisitors;
@@ -22,4 +23,4 @@ public class CommentsObjectGraphVisitor : ChainedObjectGraphVisitor
return base.EnterMapping(key, value, context); 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;
using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.EventEmitters;
@@ -26,4 +27,4 @@ public class MultilineScalarFlowStyleEmitter : ChainedEventEmitter
nextEmitter.Emit(eventInfo, emitter); nextEmitter.Emit(eventInfo, emitter);
} }
} }

View File

@@ -1,4 +1,5 @@
using System.Globalization; #nullable disable
using System.Globalization;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using YamlDotNet.Core; using YamlDotNet.Core;
using YamlDotNet.Core.Events; using YamlDotNet.Core.Events;
@@ -43,4 +44,4 @@ public class CultureInfoConverter : IYamlTypeConverter
var ci = (CultureInfo)value; var ci = (CultureInfo)value;
emitter.Emit(new Scalar(ci.Name)); 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.Core.Events;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
@@ -21,4 +22,4 @@ public class UriConverter : IYamlTypeConverter
var uri = (Uri)value; var uri = (Uri)value;
emitter.Emit(new Scalar(uri.ToString())); emitter.Emit(new Scalar(uri.ToString()));
} }
} }

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore; #nullable disable
using Microsoft.EntityFrameworkCore;
using LinqToDB; using LinqToDB;
using NadekoBot.Services.Database.Models; 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) public static CustomReaction GetByGuildIdAndInput(this DbSet<CustomReaction> crs, ulong? guildId, string input)
=> crs.FirstOrDefault(x => x.GuildId == guildId && x.Trigger.ToUpper() == 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; using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db; namespace NadekoBot.Db;
@@ -8,4 +9,4 @@ public static class DbExtensions
public static T GetById<T>(this DbSet<T> set, int id) public static T GetById<T>(this DbSet<T> set, int id)
where T : DbEntity where T : DbEntity
=> set.FirstOrDefault(x => x.Id == id); => 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 Microsoft.EntityFrameworkCore;
using LinqToDB; using LinqToDB;
using LinqToDB.EntityFrameworkCore; using LinqToDB.EntityFrameworkCore;
@@ -185,4 +186,4 @@ VALUES ({userId}, {name}, {discrim}, {avatarId}, {amount}, 0);
.OrderByDescending(x => x.CurrencyAmount) .OrderByDescending(x => x.CurrencyAmount)
.Take(users.Count() / 100 == 0 ? 1 : users.Count() / 100) .Take(users.Count() / 100 == 0 ? 1 : users.Count() / 100)
.Sum(x => x.CurrencyAmount); .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 Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database; using NadekoBot.Services.Database;
using NadekoBot.Db.Models; using NadekoBot.Db.Models;
@@ -201,4 +202,4 @@ public static class GuildConfigExtensions
.SelectMany(x => x.GenerateCurrencyChannelIds) .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(); .ToArray();
} }

View File

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

View File

@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore; #nullable disable
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db; namespace NadekoBot.Db;
@@ -20,4 +21,4 @@ public static class MusicPlaylistExtensions
public static MusicPlaylist GetWithSongs(this DbSet<MusicPlaylist> playlists, int id) public static MusicPlaylist GetWithSongs(this DbSet<MusicPlaylist> playlists, int id)
=> playlists.Include(mpl => mpl.Songs) => playlists.Include(mpl => mpl.Songs)
.FirstOrDefault(mpl => mpl.Id == id); .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;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
@@ -34,4 +35,4 @@ public static class PollExtensions
ctx.Poll.Remove(p); ctx.Poll.Remove(p);
} }
} }

View File

@@ -1,3 +1,4 @@
#nullable disable
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -60,4 +61,4 @@ public static class QuoteExtensions
=> quotes.RemoveRange(quotes.AsQueryable() => quotes.RemoveRange(quotes.AsQueryable()
.Where(x => x.GuildId == guildId && x.Keyword.ToUpper() == keyword) .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; using Microsoft.EntityFrameworkCore;
namespace NadekoBot.Db; namespace NadekoBot.Db;
@@ -25,4 +26,4 @@ public static class ReminderExtensions
.OrderBy(x => x.DateAdded) .OrderBy(x => x.DateAdded)
.Skip(page * 10) .Skip(page * 10)
.Take(10); .Take(10);
} }

View File

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

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