Global usings and file scoped namespaces

This commit is contained in:
Kwoth
2021-12-19 05:14:11 +01:00
parent bc31dae965
commit ee33313519
548 changed files with 47528 additions and 49115 deletions

View File

@@ -3,6 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<LangVersion>10.0</LangVersion> <LangVersion>10.0</LangVersion>
<EnablePreviewFeatures>True</EnablePreviewFeatures>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>

View File

@@ -6,11 +6,8 @@ using NadekoBot.Common;
using NadekoBot.Services; using NadekoBot.Services;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using System;
using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -19,11 +16,9 @@ using NadekoBot.Common.ModuleBehaviors;
using NadekoBot.Common.Configs; using NadekoBot.Common.Configs;
using NadekoBot.Db; using NadekoBot.Db;
using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.Administration.Services;
using NadekoBot.Modules.Searches;
using Serilog;
namespace NadekoBot namespace NadekoBot;
{
public sealed class Bot public sealed class Bot
{ {
private readonly IBotCredentials _creds; private readonly IBotCredentials _creds;
@@ -362,4 +357,3 @@ namespace NadekoBot
await Task.Delay(-1).ConfigureAwait(false); await Task.Delay(-1).ConfigureAwait(false);
} }
} }
}

View File

@@ -1,9 +1,8 @@
using System; using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public class AsyncLazy<T> : Lazy<Task<T>> public class AsyncLazy<T> : Lazy<Task<T>>
{ {
public AsyncLazy(Func<T> valueFactory) : public AsyncLazy(Func<T> valueFactory) :
@@ -16,5 +15,3 @@ namespace NadekoBot.Common
public TaskAwaiter<T> GetAwaiter() { return Value.GetAwaiter(); } public TaskAwaiter<T> GetAwaiter() { return Value.GetAwaiter(); }
} }
}

View File

@@ -1,12 +1,8 @@
using System; using System.Runtime.CompilerServices;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Services;
namespace NadekoBot.Common.Attributes namespace NadekoBot.Common.Attributes;
{
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class AliasesAttribute : AliasAttribute public sealed class AliasesAttribute : AliasAttribute
{ {
@@ -15,4 +11,3 @@ namespace NadekoBot.Common.Attributes
{ {
} }
} }
}

View File

@@ -1,7 +1,7 @@
using Discord.Commands; using Discord.Commands;
namespace Discord namespace Discord;
{
public class BotPermAttribute : RequireBotPermissionAttribute public class BotPermAttribute : RequireBotPermissionAttribute
{ {
public BotPermAttribute(GuildPerm permission) : base((GuildPermission)permission) public BotPermAttribute(GuildPerm permission) : base((GuildPermission)permission)
@@ -12,4 +12,3 @@ namespace Discord
{ {
} }
} }
}

View File

@@ -1,10 +1,7 @@
using System; using System.IO;
using System.Collections.Generic;
using System.IO; namespace NadekoBot.Common.Attributes;
using System.Linq;
namespace NadekoBot.Common.Attributes
{
public static class CommandNameLoadHelper public static class CommandNameLoadHelper
{ {
@@ -33,4 +30,3 @@ namespace NadekoBot.Common.Attributes
return toReturn; return toReturn;
} }
} }
}

View File

@@ -1,10 +1,7 @@
using System; using Discord.Commands;
using System.Runtime.CompilerServices;
using Discord.Commands; namespace NadekoBot.Common.Attributes;
using NadekoBot.Services;
namespace NadekoBot.Common.Attributes
{
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class DescriptionAttribute : SummaryAttribute public sealed class DescriptionAttribute : SummaryAttribute
{ {
@@ -13,4 +10,3 @@ namespace NadekoBot.Common.Attributes
{ {
} }
} }
}

View File

@@ -1,9 +1,8 @@
namespace Discord.Commands namespace Discord.Commands;
{
public class LeftoverAttribute : RemainderAttribute public class LeftoverAttribute : RemainderAttribute
{ {
public LeftoverAttribute() public LeftoverAttribute()
{ {
} }
} }
}

View File

@@ -1,10 +1,8 @@
using System; using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Services;
namespace NadekoBot.Common.Attributes namespace NadekoBot.Common.Attributes;
{
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class NadekoCommandAttribute : CommandAttribute public sealed class NadekoCommandAttribute : CommandAttribute
{ {
@@ -16,4 +14,3 @@ namespace NadekoBot.Common.Attributes
public string MethodName { get; } public string MethodName { get; }
} }
}

View File

@@ -1,8 +1,7 @@
using System; using Discord.Commands;
using Discord.Commands;
namespace NadekoBot.Common.Attributes;
namespace NadekoBot.Common.Attributes
{
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]
sealed class NadekoModuleAttribute : GroupAttribute sealed class NadekoModuleAttribute : GroupAttribute
{ {
@@ -10,5 +9,3 @@ namespace NadekoBot.Common.Attributes
{ {
} }
} }
}

View File

@@ -1,7 +1,5 @@
using System; namespace NadekoBot.Common.Attributes;
namespace NadekoBot.Common.Attributes
{
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class NadekoOptionsAttribute : Attribute public sealed class NadekoOptionsAttribute : Attribute
{ {
@@ -12,4 +10,3 @@ namespace NadekoBot.Common.Attributes
this.OptionType = t; this.OptionType = t;
} }
} }
}

View File

@@ -1,12 +1,11 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Services; using NadekoBot.Services;
namespace NadekoBot.Common.Attributes namespace NadekoBot.Common.Attributes;
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public sealed class OwnerOnlyAttribute : PreconditionAttribute public sealed class OwnerOnlyAttribute : PreconditionAttribute
{ {
@@ -17,4 +16,3 @@ namespace NadekoBot.Common.Attributes
return Task.FromResult((creds.IsOwner(context.User) || context.Client.CurrentUser.Id == context.User.Id ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("Not owner"))); return Task.FromResult((creds.IsOwner(context.User) || context.Client.CurrentUser.Id == context.User.Id ? PreconditionResult.FromSuccess() : PreconditionResult.FromError("Not owner")));
} }
} }
}

View File

@@ -1,11 +1,10 @@
using Discord.Commands; using Discord.Commands;
using NadekoBot.Services; using NadekoBot.Services;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace NadekoBot.Common.Attributes namespace NadekoBot.Common.Attributes;
{
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class RatelimitAttribute : PreconditionAttribute public sealed class RatelimitAttribute : PreconditionAttribute
{ {
@@ -35,4 +34,3 @@ namespace NadekoBot.Common.Attributes
return Task.FromResult(PreconditionResult.FromError(msgContent)); return Task.FromResult(PreconditionResult.FromError(msgContent));
} }
} }
}

View File

@@ -1,11 +1,7 @@
using System; using Discord.Commands;
using System.Runtime.CompilerServices;
using Discord.Commands; namespace NadekoBot.Common.Attributes;
using NadekoBot.Services;
using Newtonsoft.Json;
namespace NadekoBot.Common.Attributes
{
[AttributeUsage(AttributeTargets.Method)] [AttributeUsage(AttributeTargets.Method)]
public sealed class UsageAttribute : RemarksAttribute public sealed class UsageAttribute : RemarksAttribute
{ {
@@ -18,4 +14,3 @@ namespace NadekoBot.Common.Attributes
{ {
} }
} }
}

View File

@@ -1,11 +1,10 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
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, AllowMultiple = false)]
public class UserPermAttribute : PreconditionAttribute public class UserPermAttribute : PreconditionAttribute
{ {
@@ -30,4 +29,3 @@ namespace Discord
return UserPermissionAttribute.CheckPermissionsAsync(context, command, services); return UserPermissionAttribute.CheckPermissionsAsync(context, command, services);
} }
} }
}

View File

@@ -1,7 +1,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public class CmdStrings public class CmdStrings
{ {
public string[] Usages { get; } public string[] Usages { get; }
@@ -17,4 +17,3 @@ namespace NadekoBot.Common
Description = description; Description = description;
} }
} }
}

View File

@@ -1,15 +1,12 @@
// License MIT // License MIT
// Source: https://github.com/i3arnon/ConcurrentHashSet // Source: https://github.com/i3arnon/ConcurrentHashSet
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Threading; using System.Threading;
namespace NadekoBot.Common.Collections namespace NadekoBot.Common.Collections;
{
/// <summary> /// <summary>
/// Represents a thread-safe hash-based unique collection. /// Represents a thread-safe hash-based unique collection.
/// </summary> /// </summary>
@@ -769,4 +766,3 @@ namespace NadekoBot.Common.Collections
} }
} }
} }
}

View File

@@ -1,9 +1,7 @@
using System; using System.Collections;
using System.Collections;
using System.Collections.Generic; namespace NadekoBot.Common.Collections;
namespace NadekoBot.Common.Collections
{
public static class DisposableReadOnlyListExtensions public static class DisposableReadOnlyListExtensions
{ {
public static IDisposableReadOnlyList<T> AsDisposable<T>(this IReadOnlyList<T> arr) where T : IDisposable public static IDisposableReadOnlyList<T> AsDisposable<T>(this IReadOnlyList<T> arr) where T : IDisposable
@@ -74,4 +72,3 @@ namespace NadekoBot.Common.Collections
} }
} }
} }
}

View File

@@ -1,10 +1,8 @@
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Linq;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
namespace NadekoBot.Common.Collections namespace NadekoBot.Common.Collections;
{
public class IndexedCollection<T> : IList<T> where T : class, IIndexed public class IndexedCollection<T> : IList<T> where T : class, IIndexed
{ {
public List<T> Source { get; } public List<T> Source { get; }
@@ -138,4 +136,3 @@ namespace NadekoBot.Common.Collections
} }
} }
} }
}

View File

@@ -1,9 +1,8 @@
namespace NadekoBot.Common 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,13 +1,12 @@
using System.Collections.Generic; using System.Globalization;
using System.Globalization;
using Cloneable; using Cloneable;
using NadekoBot.Common.Yml; using NadekoBot.Common.Yml;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using YamlDotNet.Core; using YamlDotNet.Core;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
namespace NadekoBot.Common.Configs namespace NadekoBot.Common.Configs;
{
[Cloneable] [Cloneable]
public sealed partial class BotConfig : ICloneable<BotConfig> public sealed partial class BotConfig : ICloneable<BotConfig>
{ {
@@ -181,4 +180,3 @@ See RotatingStatuses submodule in Administration.")]
Simple = 1, Simple = 1,
None = 2, None = 2,
} }
}

View File

@@ -1,5 +1,5 @@
namespace NadekoBot.Common.Configs namespace NadekoBot.Common.Configs;
{
/// <summary> /// <summary>
/// Base interface for available config serializers /// Base interface for available config serializers
/// </summary> /// </summary>
@@ -15,4 +15,3 @@
/// </summary> /// </summary>
public T Deserialize<T>(string data); public T Deserialize<T>(string data);
} }
}

View File

@@ -1,9 +1,7 @@
using System.Collections.Generic; using NadekoBot.Common.Yml;
using NadekoBot.Common.Yml;
using YamlDotNet.Serialization; namespace NadekoBot.Common;
namespace NadekoBot.Common
{
public sealed class Creds : IBotCredentials public sealed class Creds : IBotCredentials
{ {
public Creds() public Creds()
@@ -216,4 +214,3 @@ This should be equivalent to the DiscordsKey in your NadekoBot.Votes api appsett
} }
} }
} }
}

View File

@@ -1,12 +1,11 @@
using NadekoBot.Services; using NadekoBot.Services;
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord; using Discord;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public class DownloadTracker : INService public class DownloadTracker : INService
{ {
private ConcurrentDictionary<ulong, DateTime> LastDownloads { get; } = new ConcurrentDictionary<ulong, DateTime>(); private ConcurrentDictionary<ulong, DateTime> LastDownloads { get; } = new ConcurrentDictionary<ulong, DateTime>();
@@ -40,4 +39,3 @@ namespace NadekoBot.Common
} }
} }
} }
}

View File

@@ -1,11 +1,9 @@
using Discord; using Discord;
using NadekoBot.Common;
namespace NadekoBot.Extensions namespace NadekoBot.Extensions;
{
public static class BotCredentialsExtensions public static class BotCredentialsExtensions
{ {
public static bool IsOwner(this IBotCredentials creds, IUser user) public static bool IsOwner(this IBotCredentials creds, IUser user)
=> creds.OwnerIds.Contains(user.Id); => creds.OwnerIds.Contains(user.Id);
} }
}

View File

@@ -1,17 +1,14 @@
using System; using System.Reflection;
using System.Linq;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using NadekoBot.Common; using NadekoBot.Common;
using NadekoBot.Modules.Music; using NadekoBot.Modules.Music;
using NadekoBot.Services; using NadekoBot.Services;
using NadekoBot.Modules.Administration.Services;
using NadekoBot.Modules.Music.Resolvers; using NadekoBot.Modules.Music.Resolvers;
using NadekoBot.Modules.Music.Services; using NadekoBot.Modules.Music.Services;
using StackExchange.Redis; using StackExchange.Redis;
namespace NadekoBot.Extensions namespace NadekoBot.Extensions;
{
public static class ServiceCollectionExtensions public static class ServiceCollectionExtensions
{ {
public static IServiceCollection AddBotStringsServices(this IServiceCollection services, int totalShards) public static IServiceCollection AddBotStringsServices(this IServiceCollection services, int totalShards)
@@ -78,4 +75,3 @@ namespace NadekoBot.Extensions
return services; return services;
} }
} }
}

View File

@@ -1,10 +1,6 @@
using System; namespace Discord;
namespace Discord
{
// just a copy paste from discord.net in order to rename it, for compatibility iwth v3 which is gonna use custom lib // just a copy paste from discord.net in order to rename it, for compatibility iwth v3 which is gonna use custom lib
// Summary: // Summary:
// Defines the available permissions for a channel. // Defines the available permissions for a channel.
[Flags] [Flags]
@@ -252,4 +248,3 @@ namespace Discord
// Allows management and editing of webhooks. // Allows management and editing of webhooks.
ManageWebhooks = 536870912 ManageWebhooks = 536870912
} }
}

View File

@@ -1,7 +1,5 @@
using System; namespace NadekoBot.Common;
namespace NadekoBot.Common
{
public static class Helpers public static class Helpers
{ {
public static void ReadErrorAndExit(int exitCode) public static void ReadErrorAndExit(int exitCode)
@@ -12,4 +10,3 @@ namespace NadekoBot.Common
Environment.Exit(exitCode); Environment.Exit(exitCode);
} }
} }
}

View File

@@ -1,11 +1,7 @@
using System.Collections.Generic; using NadekoBot.Common;
using Discord;
using System.Collections.Immutable; namespace NadekoBot;
using System.Linq;
using NadekoBot.Common;
namespace NadekoBot
{
public interface IBotCredentials public interface IBotCredentials
{ {
string Token { get; } string Token { get; }
@@ -33,4 +29,3 @@ namespace NadekoBot
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,6 @@
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public interface ICloneable<T> where T : new() public interface ICloneable<T> where T : new()
{ {
public T Clone(); public T Clone();
} }
}

View File

@@ -1,7 +1,7 @@
using Discord; using Discord;
namespace NadekoBot namespace NadekoBot;
{
public interface IEmbedBuilder public interface IEmbedBuilder
{ {
IEmbedBuilder WithDescription(string desc); IEmbedBuilder WithDescription(string desc);
@@ -22,4 +22,3 @@ namespace NadekoBot
Pending, Pending,
Error, Error,
} }
}

View File

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

View File

@@ -1,10 +1,6 @@
using System; namespace NadekoBot.Common;
using System.Collections.Generic;
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,8 +1,7 @@
using System; using NadekoBot.Common.Yml;
using NadekoBot.Common.Yml;
namespace NadekoBot.Common;
namespace NadekoBot.Common
{
public class ImageUrls public class ImageUrls
{ {
[Comment("DO NOT CHANGE")] [Comment("DO NOT CHANGE")]
@@ -47,4 +46,3 @@ namespace NadekoBot.Common
public Uri Bg { get; set; } public Uri Bg { get; set; }
} }
} }
}

View File

@@ -1,11 +1,10 @@
using System; using System.Globalization;
using System.Globalization;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
namespace NadekoBot.Common.JsonConverters namespace NadekoBot.Common.JsonConverters;
{
public class Rgba32Converter : JsonConverter<Rgba32> public class Rgba32Converter : JsonConverter<Rgba32>
{ {
public override Rgba32 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) public override Rgba32 Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
@@ -31,4 +30,3 @@ namespace NadekoBot.Common.JsonConverters
writer.WriteStringValue(value.Name); writer.WriteStringValue(value.Name);
} }
} }
}

View File

@@ -1,8 +1,7 @@
using System; using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
namespace NadekoBot.Common;
namespace NadekoBot.Common
{
// needs proper invalid input check (character array input out of range) // needs proper invalid input check (character array input out of range)
// needs negative number support // needs negative number support
public readonly struct kwum : IEquatable<kwum> public readonly struct kwum : IEquatable<kwum>
@@ -95,4 +94,3 @@ namespace NadekoBot.Common
return _value.GetHashCode(); return _value.GetHashCode();
} }
} }
}

View File

@@ -1,7 +1,7 @@
using CommandLine; using CommandLine;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public class LbOpts : INadekoCommandOptions public class LbOpts : INadekoCommandOptions
{ {
[Option('c', "clean", Default = false, HelpText = "Only show users who are on the server.")] [Option('c', "clean", Default = false, HelpText = "Only show users who are on the server.")]
@@ -11,4 +11,3 @@ namespace NadekoBot.Common
} }
} }
}

View File

@@ -1,11 +1,9 @@
using System; using System.Net;
using System.Net;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using Discord.Net; using Discord.Net;
using Serilog;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public class LoginErrorHandler public class LoginErrorHandler
{ {
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -54,4 +52,3 @@ namespace NadekoBot.Common
Log.Fatal(ex.ToString()); Log.Fatal(ex.ToString());
} }
} }
}

View File

@@ -1,8 +1,8 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord; using Discord;
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
/// </summary> /// </summary>
@@ -11,4 +11,3 @@ namespace NadekoBot.Common.ModuleBehaviors
int Priority { get; } int Priority { get; }
Task<bool> RunBehavior(IGuild guild, IUserMessage msg); Task<bool> RunBehavior(IGuild guild, IUserMessage msg);
} }
}

View File

@@ -1,10 +1,9 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord; using Discord;
namespace NadekoBot.Common.ModuleBehaviors namespace NadekoBot.Common.ModuleBehaviors;
{
public interface IInputTransformer public interface IInputTransformer
{ {
Task<string> TransformInput(IGuild guild, IMessageChannel channel, IUser user, string input); Task<string> TransformInput(IGuild guild, IMessageChannel channel, IUser user, string input);
} }
}

View File

@@ -1,13 +1,11 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using Discord.WebSocket;
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,8 +1,8 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord; using Discord;
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
/// </summary> /// </summary>
@@ -10,4 +10,3 @@ namespace NadekoBot.Common.ModuleBehaviors
{ {
Task LateExecute(IGuild guild, IUserMessage msg); Task LateExecute(IGuild guild, IUserMessage msg);
} }
}

View File

@@ -2,8 +2,8 @@
using Discord.WebSocket; using Discord.WebSocket;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NadekoBot.Common.ModuleBehaviors namespace NadekoBot.Common.ModuleBehaviors;
{
public struct ModuleBehaviorResult public struct ModuleBehaviorResult
{ {
public bool Blocked { get; set; } public bool Blocked { get; set; }
@@ -31,4 +31,3 @@ namespace NadekoBot.Common.ModuleBehaviors
int Priority { get; } int Priority { get; }
Task<ModuleBehaviorResult> ApplyBehavior(DiscordSocketClient client, IGuild guild, IUserMessage msg); Task<ModuleBehaviorResult> ApplyBehavior(DiscordSocketClient client, IGuild guild, IUserMessage msg);
} }
}

View File

@@ -1,7 +1,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
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
/// the bot is ready should implement this interface /// the bot is ready should implement this interface
@@ -13,4 +13,3 @@ namespace NadekoBot.Common.ModuleBehaviors
/// </summary> /// </summary>
public Task OnReadyAsync(); public Task OnReadyAsync();
} }
}

View File

@@ -6,8 +6,8 @@ using NadekoBot.Extensions;
using System.Globalization; using System.Globalization;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NadekoBot.Modules namespace NadekoBot.Modules;
{
public abstract class NadekoModule : ModuleBase public abstract class NadekoModule : ModuleBase
{ {
protected CultureInfo _cultureInfo { get; set; } protected CultureInfo _cultureInfo { get; set; }
@@ -154,4 +154,3 @@ namespace NadekoBot.Modules
{ {
} }
} }
}

View File

@@ -1,7 +1,6 @@
namespace NadekoBot.Modules namespace NadekoBot.Modules;
{
public static class NadekoModuleExtensions public static class NadekoModuleExtensions
{ {
} }
}

View File

@@ -1,8 +1,7 @@
using System; using System.Security.Cryptography;
using System.Security.Cryptography;
namespace NadekoBot.Common;
namespace NadekoBot.Common
{
public class NadekoRandom : Random public class NadekoRandom : Random
{ {
readonly RandomNumberGenerator _rng; readonly RandomNumberGenerator _rng;
@@ -71,4 +70,3 @@ namespace NadekoBot.Common
return BitConverter.ToDouble(bytes, 0); return BitConverter.ToDouble(bytes, 0);
} }
} }
}

View File

@@ -1,9 +1,8 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
public sealed class NoPublicBotAttribute : PreconditionAttribute public sealed class NoPublicBotAttribute : PreconditionAttribute
{ {
@@ -16,4 +15,3 @@ namespace NadekoBot.Common
#endif #endif
} }
} }
}

View File

@@ -1,7 +1,5 @@
using System; namespace NadekoBot.Common;
namespace NadekoBot.Common
{
public class OldImageUrls public class OldImageUrls
{ {
public int Version { get; set; } = 2; public int Version { get; set; } = 2;
@@ -46,4 +44,3 @@ namespace NadekoBot.Common
public Uri Bg { get; set; } public Uri Bg { get; set; }
} }
} }
}

View File

@@ -1,7 +1,7 @@
using CommandLine; using CommandLine;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public static class OptionsParser public static class OptionsParser
{ {
public static T ParseFrom<T>(string[] args) where T : INadekoCommandOptions, new() public static T ParseFrom<T>(string[] args) where T : INadekoCommandOptions, new()
@@ -21,4 +21,3 @@ namespace NadekoBot.Common
} }
} }
} }
}

View File

@@ -1,9 +1,8 @@
namespace NadekoBot.Common 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,7 +1,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public class OsuUserBests public class OsuUserBests
{ {
[JsonProperty("beatmap_id")] public string BeatmapId { get; set; } [JsonProperty("beatmap_id")] public string BeatmapId { get; set; }
@@ -38,4 +38,3 @@ namespace NadekoBot.Common
[JsonProperty("replay_available")] public string ReplayAvailable { get; set; } [JsonProperty("replay_available")] public string ReplayAvailable { get; set; }
} }
}

View File

@@ -1,7 +1,5 @@
using System; namespace NadekoBot.Common;
namespace NadekoBot.Common
{
public static class PlatformHelper public static class PlatformHelper
{ {
private const int ProcessorCountRefreshIntervalMs = 30000; private const int ProcessorCountRefreshIntervalMs = 30000;
@@ -22,4 +20,3 @@ namespace NadekoBot.Common
} }
} }
} }
}

View File

@@ -1,8 +1,7 @@
namespace NadekoBot.Common.Pokemon 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,8 +1,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Collections.Generic;
namespace NadekoBot.Common.Pokemon namespace NadekoBot.Common.Pokemon;
{
public class SearchPokemon public class SearchPokemon
{ {
public class GenderRatioClass public class GenderRatioClass
@@ -37,4 +36,3 @@ namespace NadekoBot.Common.Pokemon
public string[] Evos { get; set; } public string[] Evos { get; set; }
public string[] EggGroups { get; set; } public string[] EggGroups { get; set; }
} }
}

View File

@@ -1,5 +1,5 @@
namespace NadekoBot.Common.Pokemon namespace NadekoBot.Common.Pokemon;
{
public class SearchPokemonAbility public class SearchPokemonAbility
{ {
public string Desc { get; set; } public string Desc { get; set; }
@@ -7,4 +7,3 @@
public string Name { get; set; } public string Name { get; set; }
public float Rating { get; set; } public float Rating { get; set; }
} }
}

View File

@@ -1,10 +1,7 @@
using System; using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq; namespace NadekoBot.Common;
using System.Threading.Tasks;
namespace NadekoBot.Common
{
public class EventPubSub : IPubSub public class EventPubSub : IPubSub
{ {
private readonly Dictionary<string, Dictionary<Delegate, List<Func<object, ValueTask>>>> _actions private readonly Dictionary<string, Dictionary<Delegate, List<Func<object, ValueTask>>>> _actions
@@ -91,5 +88,3 @@ namespace NadekoBot.Common
} }
} }
} }
}

View File

@@ -1,11 +1,9 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
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,8 +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,8 +1,8 @@
using System.Text.Json; using System.Text.Json;
using NadekoBot.Common.JsonConverters; using NadekoBot.Common.JsonConverters;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public class JsonSeria : ISeria public class JsonSeria : ISeria
{ {
private JsonSerializerOptions serializerOptions = new JsonSerializerOptions() private JsonSerializerOptions serializerOptions = new JsonSerializerOptions()
@@ -25,4 +25,3 @@ namespace NadekoBot.Common
return JsonSerializer.Deserialize<T>(data, serializerOptions); return JsonSerializer.Deserialize<T>(data, serializerOptions);
} }
} }
}

View File

@@ -1,12 +1,9 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
using NadekoBot.Services;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using Serilog;
using StackExchange.Redis; using StackExchange.Redis;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public sealed class RedisPubSub : IPubSub public sealed class RedisPubSub : IPubSub
{ {
private readonly ConnectionMultiplexer _multi; private readonly ConnectionMultiplexer _multi;
@@ -43,4 +40,3 @@ namespace NadekoBot.Common
}); });
} }
} }
}

View File

@@ -1,5 +1,5 @@
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public readonly struct TypedKey<TData> public readonly struct TypedKey<TData>
{ {
public readonly string Key; public readonly string Key;
@@ -26,4 +26,3 @@
public override string ToString() => Key; public override string ToString() => Key;
} }
}

View File

@@ -3,8 +3,8 @@ using NadekoBot.Common.Yml;
using NadekoBot.Common.Configs; using NadekoBot.Common.Configs;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public class YamlSeria : IConfigSeria public class YamlSeria : IConfigSeria
{ {
private readonly ISerializer _serializer; private readonly ISerializer _serializer;
@@ -35,4 +35,3 @@ namespace NadekoBot.Common
public T Deserialize<T>(string data) public T Deserialize<T>(string data)
=> _deserializer.Deserialize<T>(data); => _deserializer.Deserialize<T>(data);
} }
}

View File

@@ -3,16 +3,11 @@ using Discord.Commands;
using Discord.WebSocket; using Discord.WebSocket;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.Administration.Services;
using NadekoBot.Modules.Music.Services;
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using NadekoBot.Common;
namespace NadekoBot.Common.Replacements namespace NadekoBot.Common.Replacements;
{
public class ReplacementBuilder public class ReplacementBuilder
{ {
private static readonly Regex rngRegex = new Regex("%rng(?:(?<from>(?:-)?\\d+)-(?<to>(?:-)?\\d+))?%", RegexOptions.Compiled); private static readonly Regex rngRegex = new Regex("%rng(?:(?<from>(?:-)?\\d+)-(?<to>(?:-)?\\d+))?%", RegexOptions.Compiled);
@@ -234,4 +229,3 @@ namespace NadekoBot.Common.Replacements
return this; return this;
} }
} }
}

View File

@@ -1,9 +1,7 @@
using System; using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Text.RegularExpressions; namespace NadekoBot.Common.Replacements;
namespace NadekoBot.Common.Replacements
{
public class Replacer public class Replacer
{ {
private readonly IEnumerable<(string Key, Func<string> Text)> _replacements; private readonly IEnumerable<(string Key, Func<string> Text)> _replacements;
@@ -88,4 +86,3 @@ namespace NadekoBot.Common.Replacements
return newEmbedData; return newEmbedData;
} }
} }
}

View File

@@ -1,9 +1,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using System;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public class RequireObjectPropertiesContractResolver : DefaultContractResolver public class RequireObjectPropertiesContractResolver : DefaultContractResolver
{ {
protected override JsonObjectContract CreateObjectContract(Type objectType) protected override JsonObjectContract CreateObjectContract(Type objectType)
@@ -13,4 +12,3 @@ namespace NadekoBot.Common
return contract; return contract;
} }
} }
}

View File

@@ -1,7 +1,5 @@
using System; namespace NadekoBot.Common;
namespace NadekoBot.Common
{
public struct ShmartNumber : IEquatable<ShmartNumber> public struct ShmartNumber : IEquatable<ShmartNumber>
{ {
public long Value { get; } public long Value { get; }
@@ -60,4 +58,3 @@ namespace NadekoBot.Common
return !(left == right); return !(left == right);
} }
} }
}

View File

@@ -1,11 +1,8 @@
using System; using Discord;
using System.Linq;
using Discord;
using NadekoBot.Extensions; using NadekoBot.Extensions;
using NadekoBot.Services;
namespace NadekoBot namespace NadekoBot;
{
public sealed record SmartEmbedText : SmartText public sealed record SmartEmbedText : SmartText
{ {
public string PlainText { get; set; } public string PlainText { get; set; }
@@ -135,4 +132,3 @@ namespace NadekoBot
} }
} }
} }
}

View File

@@ -1,5 +1,5 @@
namespace NadekoBot namespace NadekoBot;
{
public sealed record SmartPlainText : SmartText public sealed record SmartPlainText : SmartText
{ {
public string Text { get; init; } public string Text { get; init; }
@@ -20,4 +20,3 @@
return Text; return Text;
} }
} }
}

View File

@@ -1,8 +1,7 @@
using System; using Newtonsoft.Json;
using Newtonsoft.Json;
namespace NadekoBot;
namespace NadekoBot
{
public abstract record SmartText public abstract record SmartText
{ {
public bool IsEmbed => this is SmartEmbedText; public bool IsEmbed => this is SmartEmbedText;
@@ -50,4 +49,3 @@ namespace NadekoBot
} }
} }
} }
}

View File

@@ -1,7 +1,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NadekoBot namespace NadekoBot;
{
public class SmartTextEmbedAuthor public class SmartTextEmbedAuthor
{ {
public string Name { get; set; } public string Name { get; set; }
@@ -10,4 +10,3 @@ namespace NadekoBot
private string Icon_Url { set => IconUrl = value; } private string Icon_Url { set => IconUrl = value; }
public string Url { get; set; } public string Url { get; set; }
} }
}

View File

@@ -1,9 +1,8 @@
namespace NadekoBot 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,7 +1,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NadekoBot namespace NadekoBot;
{
public class SmartTextEmbedFooter public class SmartTextEmbedFooter
{ {
public string Text { get; set; } public string Text { get; set; }
@@ -9,4 +9,3 @@ namespace NadekoBot
[JsonProperty("icon_url")] [JsonProperty("icon_url")]
private string Icon_Url { set => IconUrl = value; } private string Icon_Url { set => IconUrl = value; }
} }
}

View File

@@ -1,10 +1,9 @@
using Discord; using Discord;
using Discord.WebSocket; using Discord.WebSocket;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NadekoBot.Common namespace NadekoBot.Common;
{
public sealed class ReactionEventWrapper : IDisposable public sealed class ReactionEventWrapper : IDisposable
{ {
public IUserMessage Message { get; } public IUserMessage Message { get; }
@@ -88,4 +87,3 @@ namespace NadekoBot.Common
UnsubAll(); UnsubAll();
} }
} }
}

View File

@@ -1,9 +1,8 @@
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public enum AddRemove public enum AddRemove
{ {
Add = int.MinValue, Add = int.MinValue,
Rem = int.MinValue + 1, Rem = int.MinValue + 1,
Rm = int.MinValue + 1, Rm = int.MinValue + 1,
} }
}

View File

@@ -1,12 +1,10 @@
using System; using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Services; using NadekoBot.Services;
using NadekoBot.Modules.CustomReactions.Services; using NadekoBot.Modules.CustomReactions.Services;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public sealed class CommandTypeReader : NadekoTypeReader<CommandInfo> public sealed class CommandTypeReader : NadekoTypeReader<CommandInfo>
{ {
private readonly CommandHandler _handler; private readonly CommandHandler _handler;
@@ -87,4 +85,3 @@ namespace NadekoBot.Common.TypeReaders
this.CmdType = type; this.CmdType = type;
} }
} }
}

View File

@@ -2,8 +2,8 @@
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public sealed class EmoteTypeReader : NadekoTypeReader<Emote> public sealed class EmoteTypeReader : NadekoTypeReader<Emote>
{ {
public override Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input) public override Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input)
@@ -14,4 +14,3 @@ namespace NadekoBot.Common.TypeReaders
return Task.FromResult(TypeReaderResult.FromSuccess(emote)); return Task.FromResult(TypeReaderResult.FromSuccess(emote));
} }
} }
}

View File

@@ -1,10 +1,9 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Modules.Administration.Services; using NadekoBot.Modules.Administration.Services;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public sealed class GuildDateTimeTypeReader : NadekoTypeReader<GuildDateTime> public sealed class GuildDateTimeTypeReader : NadekoTypeReader<GuildDateTime>
{ {
private readonly GuildTimezoneService _gts; private readonly GuildTimezoneService _gts;
@@ -50,4 +49,3 @@ namespace NadekoBot.Common.TypeReaders
InputTimeUtc = TimeZoneInfo.ConvertTime(inputTime, Timezone, TimeZoneInfo.Utc); InputTimeUtc = TimeZoneInfo.ConvertTime(inputTime, Timezone, TimeZoneInfo.Utc);
} }
} }
}

View File

@@ -1,11 +1,10 @@
using System.Linq; using System.Threading.Tasks;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using Discord.WebSocket; using Discord.WebSocket;
using Discord; using Discord;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public sealed class GuildTypeReader : NadekoTypeReader<IGuild> public sealed class GuildTypeReader : NadekoTypeReader<IGuild>
{ {
private readonly DiscordSocketClient _client; private readonly DiscordSocketClient _client;
@@ -28,4 +27,3 @@ namespace NadekoBot.Common.TypeReaders
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,8 +1,8 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public sealed class KwumTypeReader : NadekoTypeReader<kwum> public sealed class KwumTypeReader : NadekoTypeReader<kwum>
{ {
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input) public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input)
@@ -21,4 +21,3 @@ namespace NadekoBot.Common.TypeReaders
return Task.FromResult(TypeReaderResult.FromSuccess(SmartText.CreateFrom(input))); return Task.FromResult(TypeReaderResult.FromSuccess(SmartText.CreateFrom(input)));
} }
} }
}

View File

@@ -1,5 +1,5 @@
namespace NadekoBot.Common.TypeReaders.Models namespace NadekoBot.Common.TypeReaders.Models;
{
public class PermissionAction public class PermissionAction
{ {
public static PermissionAction Enable => new PermissionAction(true); public static PermissionAction Enable => new PermissionAction(true);
@@ -24,4 +24,3 @@
public override int GetHashCode() => Value.GetHashCode(); public override int GetHashCode() => Value.GetHashCode();
} }
}

View File

@@ -1,9 +1,7 @@
using System; using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Text.RegularExpressions; namespace NadekoBot.Common.TypeReaders.Models;
namespace NadekoBot.Common.TypeReaders.Models
{
public class StoopidTime public class StoopidTime
{ {
public string Input { get; set; } public string Input { get; set; }
@@ -62,4 +60,3 @@ namespace NadekoBot.Common.TypeReaders.Models
}; };
} }
} }
}

View File

@@ -1,10 +1,9 @@
using System.Linq; using System.Threading.Tasks;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using NadekoBot.Extensions; using NadekoBot.Extensions;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public sealed class ModuleTypeReader : NadekoTypeReader<ModuleInfo> public sealed class ModuleTypeReader : NadekoTypeReader<ModuleInfo>
{ {
private readonly CommandService _cmds; private readonly CommandService _cmds;
@@ -52,4 +51,3 @@ namespace NadekoBot.Common.TypeReaders
{ {
public string Name { get; set; } public string Name { get; set; }
} }
}

View File

@@ -1,9 +1,8 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public abstract class NadekoTypeReader<T> : TypeReader public abstract class NadekoTypeReader<T> : TypeReader
{ {
public abstract Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input); public abstract Task<TypeReaderResult> ReadAsync(ICommandContext ctx, string input);
@@ -11,4 +10,3 @@ namespace NadekoBot.Common.TypeReaders
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

@@ -2,8 +2,8 @@
using Discord.Commands; using Discord.Commands;
using NadekoBot.Common.TypeReaders.Models; using NadekoBot.Common.TypeReaders.Models;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
/// <summary> /// <summary>
/// Used instead of bool for more flexible keywords for true/false only in the permission module /// Used instead of bool for more flexible keywords for true/false only in the permission module
/// </summary> /// </summary>
@@ -37,4 +37,3 @@ namespace NadekoBot.Common.TypeReaders
} }
} }
} }
}

View File

@@ -1,10 +1,9 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using SixLabors.ImageSharp; using SixLabors.ImageSharp;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public sealed class Rgba32TypeReader : NadekoTypeReader<Color> public sealed class Rgba32TypeReader : NadekoTypeReader<Color>
{ {
public override async Task<TypeReaderResult> ReadAsync(ICommandContext context, string input) public override async Task<TypeReaderResult> ReadAsync(ICommandContext context, string input)
@@ -22,4 +21,3 @@ namespace NadekoBot.Common.TypeReaders
} }
} }
} }
}

View File

@@ -1,13 +1,12 @@
using Discord.Commands; using Discord.Commands;
using System;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using NadekoBot.Db; using NadekoBot.Db;
using NadekoBot.Modules.Gambling.Services; using NadekoBot.Modules.Gambling.Services;
using NadekoBot.Services; using NadekoBot.Services;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public sealed class ShmartNumberTypeReader : NadekoTypeReader<ShmartNumber> public sealed class ShmartNumberTypeReader : NadekoTypeReader<ShmartNumber>
{ {
private readonly DbService _db; private readonly DbService _db;
@@ -104,4 +103,3 @@ namespace NadekoBot.Common.TypeReaders
return false; return false;
} }
} }
}

View File

@@ -1,10 +1,9 @@
using Discord.Commands; using Discord.Commands;
using NadekoBot.Common.TypeReaders.Models; using NadekoBot.Common.TypeReaders.Models;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace NadekoBot.Common.TypeReaders namespace NadekoBot.Common.TypeReaders;
{
public sealed class StoopidTimeTypeReader : NadekoTypeReader<StoopidTime> public sealed class StoopidTimeTypeReader : NadekoTypeReader<StoopidTime>
{ {
public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input) public override Task<TypeReaderResult> ReadAsync(ICommandContext context, string input)
@@ -22,4 +21,3 @@ namespace NadekoBot.Common.TypeReaders
} }
} }
} }
}

View File

@@ -1,7 +1,5 @@
using System; namespace NadekoBot.Common.Yml;
namespace NadekoBot.Common.Yml
{
public class CommentAttribute : Attribute public class CommentAttribute : Attribute
{ {
public string Comment { get; } public string Comment { get; }
@@ -11,4 +9,3 @@ namespace NadekoBot.Common.Yml
Comment = comment; Comment = comment;
} }
} }
}

View File

@@ -1,12 +1,9 @@
using System; using YamlDotNet.Core;
using System.Collections.Generic;
using System.Linq;
using YamlDotNet.Core;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeInspectors;
namespace NadekoBot.Common.Yml namespace NadekoBot.Common.Yml;
{
public class CommentGatheringTypeInspector : TypeInspectorSkeleton public class CommentGatheringTypeInspector : TypeInspectorSkeleton
{ {
private readonly ITypeInspector innerTypeDescriptor; private readonly ITypeInspector innerTypeDescriptor;
@@ -70,4 +67,3 @@ namespace NadekoBot.Common.Yml
} }
} }
} }
}

View File

@@ -1,9 +1,8 @@
using System; using YamlDotNet.Core;
using YamlDotNet.Core;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
namespace NadekoBot.Common.Yml namespace NadekoBot.Common.Yml;
{
public sealed class CommentsObjectDescriptor : IObjectDescriptor public sealed class CommentsObjectDescriptor : IObjectDescriptor
{ {
private readonly IObjectDescriptor innerDescriptor; private readonly IObjectDescriptor innerDescriptor;
@@ -21,4 +20,3 @@ namespace NadekoBot.Common.Yml
public Type StaticType { get { return innerDescriptor.StaticType; } } public Type StaticType { get { return innerDescriptor.StaticType; } }
public ScalarStyle ScalarStyle { get { return innerDescriptor.ScalarStyle; } } public ScalarStyle ScalarStyle { get { return innerDescriptor.ScalarStyle; } }
} }
}

View File

@@ -3,8 +3,8 @@ using YamlDotNet.Core.Events;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.ObjectGraphVisitors;
namespace NadekoBot.Common.Yml namespace NadekoBot.Common.Yml;
{
public class CommentsObjectGraphVisitor : ChainedObjectGraphVisitor public class CommentsObjectGraphVisitor : ChainedObjectGraphVisitor
{ {
public CommentsObjectGraphVisitor(IObjectGraphVisitor<IEmitter> nextVisitor) public CommentsObjectGraphVisitor(IObjectGraphVisitor<IEmitter> nextVisitor)
@@ -23,4 +23,3 @@ namespace NadekoBot.Common.Yml
return base.EnterMapping(key, value, context); return base.EnterMapping(key, value, context);
} }
} }
}

View File

@@ -2,8 +2,8 @@
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.EventEmitters;
namespace NadekoBot.Common.Yml namespace NadekoBot.Common.Yml;
{
public class MultilineScalarFlowStyleEmitter : ChainedEventEmitter public class MultilineScalarFlowStyleEmitter : ChainedEventEmitter
{ {
public MultilineScalarFlowStyleEmitter(IEventEmitter nextEmitter) public MultilineScalarFlowStyleEmitter(IEventEmitter nextEmitter)
@@ -29,4 +29,3 @@ namespace NadekoBot.Common.Yml
nextEmitter.Emit(eventInfo, emitter); nextEmitter.Emit(eventInfo, emitter);
} }
} }
}

View File

@@ -1,12 +1,11 @@
using System; using System.Globalization;
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;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
namespace NadekoBot.Common.Yml namespace NadekoBot.Common.Yml;
{
public class Rgba32Converter : IYamlTypeConverter public class Rgba32Converter : IYamlTypeConverter
{ {
public bool Accepts(Type type) public bool Accepts(Type type)
@@ -49,4 +48,3 @@ namespace NadekoBot.Common.Yml
emitter.Emit(new Scalar(ci.Name)); emitter.Emit(new Scalar(ci.Name));
} }
} }
}

View File

@@ -1,10 +1,9 @@
using System; using YamlDotNet.Core;
using YamlDotNet.Core;
using YamlDotNet.Core.Events; using YamlDotNet.Core.Events;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
namespace NadekoBot.Common.Yml namespace NadekoBot.Common.Yml;
{
public class UriConverter : IYamlTypeConverter public class UriConverter : IYamlTypeConverter
{ {
public bool Accepts(Type type) public bool Accepts(Type type)
@@ -25,4 +24,3 @@ namespace NadekoBot.Common.Yml
emitter.Emit(new Scalar(uri.ToString())); emitter.Emit(new Scalar(uri.ToString()));
} }
} }
}

View File

@@ -1,7 +1,7 @@
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
namespace NadekoBot.Common.Yml namespace NadekoBot.Common.Yml;
{
public class Yaml public class Yaml
{ {
public static ISerializer Serializer => new SerializerBuilder() public static ISerializer Serializer => new SerializerBuilder()
@@ -23,4 +23,3 @@ namespace NadekoBot.Common.Yml
.IgnoreUnmatchedProperties() .IgnoreUnmatchedProperties()
.Build(); .Build();
} }
}

View File

@@ -1,5 +1,5 @@
namespace NadekoBot.Common.Yml namespace NadekoBot.Common.Yml;
{
public class YamlHelper public class YamlHelper
{ {
// https://github.com/aaubry/YamlDotNet/blob/0f4cc205e8b2dd8ef6589d96de32bf608a687c6f/YamlDotNet/Core/Scanner.cs#L1687 // https://github.com/aaubry/YamlDotNet/blob/0f4cc205e8b2dd8ef6589d96de32bf608a687c6f/YamlDotNet/Core/Scanner.cs#L1687
@@ -55,4 +55,3 @@
return c - 'a' + 10; return c - 'a' + 10;
} }
} }
}

View File

@@ -1,10 +1,8 @@
using System.Linq; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using NadekoBot.Db.Models; using NadekoBot.Db.Models;
namespace NadekoBot.Db namespace NadekoBot.Db;
{
public static class ClubExtensions public static class ClubExtensions
{ {
private static IQueryable<ClubInfo> Include(this DbSet<ClubInfo> clubs) private static IQueryable<ClubInfo> Include(this DbSet<ClubInfo> clubs)
@@ -45,4 +43,3 @@ namespace NadekoBot.Db
.ToList(); .ToList();
} }
} }
}

View File

@@ -1,10 +1,8 @@
using System.Collections.Generic; using Microsoft.EntityFrameworkCore;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db namespace NadekoBot.Db;
{
public static class CurrencyTransactionExtensions public static class CurrencyTransactionExtensions
{ {
public static List<CurrencyTransaction> GetPageFor(this DbSet<CurrencyTransaction> set, ulong userId, int page) public static List<CurrencyTransaction> GetPageFor(this DbSet<CurrencyTransaction> set, ulong userId, int page)
@@ -18,4 +16,3 @@ namespace NadekoBot.Db
.ToList(); .ToList();
} }
} }
}

View File

@@ -1,11 +1,9 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Linq;
using LinqToDB; using LinqToDB;
using NadekoBot.Services.Database.Models; using NadekoBot.Services.Database.Models;
namespace NadekoBot.Db namespace NadekoBot.Db;
{
public static class CustomReactionsExtensions public static class CustomReactionsExtensions
{ {
public static int ClearFromGuild(this DbSet<CustomReaction> crs, ulong guildId) public static int ClearFromGuild(this DbSet<CustomReaction> crs, ulong guildId)
@@ -27,4 +25,3 @@ namespace NadekoBot.Db
return crs.FirstOrDefault(x => x.GuildId == guildId && x.Trigger.ToUpper() == input); return crs.FirstOrDefault(x => x.GuildId == guildId && x.Trigger.ToUpper() == input);
} }
} }
}

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