mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18:27 -04:00
More restructuring
This commit is contained in:
5
Nadeko.Bot.Modules.Searches/Class1.cs
Normal file
5
Nadeko.Bot.Modules.Searches/Class1.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Nadeko.Bot.Modules.Searches;
|
||||||
|
|
||||||
|
public class Class1
|
||||||
|
{
|
||||||
|
}
|
@@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
@@ -43,6 +43,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Common", "src\Na
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Modules.Gambling", "src\Nadeko.Bot.Modules.Gambling\Nadeko.Bot.Modules.Gambling.csproj", "{5F4F36A5-5874-4461-BB34-EE107E4B7F15}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Modules.Gambling", "src\Nadeko.Bot.Modules.Gambling\Nadeko.Bot.Modules.Gambling.csproj", "{5F4F36A5-5874-4461-BB34-EE107E4B7F15}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Modules.Searches", "src\Nadeko.Bot.Modules.Searches\Nadeko.Bot.Modules.Searches.csproj", "{65E2A9D2-2239-41B0-AC46-48ACDDF6B121}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Modules.Music", "src\Nadeko.Bot.Modules.Music\Nadeko.Bot.Modules.Music.csproj", "{95271823-A8FC-4BEF-BB1E-FAE699722922}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Modules.Xp", "src\Nadeko.Bot.Modules.Xp\Nadeko.Bot.Modules.Xp.csproj", "{8B4CCF50-E109-4206-9FEB-93F199C42B8A}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Modules.Utility", "src\Nadeko.Bot.Modules.Utility\Nadeko.Bot.Modules.Utility.csproj", "{1E338315-4BA9-4091-A06E-DE80399A1CF9}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Modules.Permisssions", "src\Nadeko.Bot.Modules.Permisssions\Nadeko.Bot.Modules.Permisssions.csproj", "{A5B51533-33B6-43AF-9D2D-410613078E96}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Modules.Administration", "src\Nadeko.Bot.Modules.Administration\Nadeko.Bot.Modules.Administration.csproj", "{08C31FF8-AC47-498D-ACD9-612FA8001F1F}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nadeko.Bot.Modules.Help", "src\Nadeko.Bot.Modules.Help\Nadeko.Bot.Modules.Help.csproj", "{C6359697-25F1-4049-8D73-AC48043CA192}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -128,6 +142,48 @@ Global
|
|||||||
{5F4F36A5-5874-4461-BB34-EE107E4B7F15}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
{5F4F36A5-5874-4461-BB34-EE107E4B7F15}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{5F4F36A5-5874-4461-BB34-EE107E4B7F15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5F4F36A5-5874-4461-BB34-EE107E4B7F15}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{5F4F36A5-5874-4461-BB34-EE107E4B7F15}.Release|Any CPU.Build.0 = Release|Any CPU
|
{5F4F36A5-5874-4461-BB34-EE107E4B7F15}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{65E2A9D2-2239-41B0-AC46-48ACDDF6B121}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{65E2A9D2-2239-41B0-AC46-48ACDDF6B121}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{65E2A9D2-2239-41B0-AC46-48ACDDF6B121}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{65E2A9D2-2239-41B0-AC46-48ACDDF6B121}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{65E2A9D2-2239-41B0-AC46-48ACDDF6B121}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{65E2A9D2-2239-41B0-AC46-48ACDDF6B121}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{95271823-A8FC-4BEF-BB1E-FAE699722922}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{95271823-A8FC-4BEF-BB1E-FAE699722922}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{95271823-A8FC-4BEF-BB1E-FAE699722922}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{95271823-A8FC-4BEF-BB1E-FAE699722922}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{95271823-A8FC-4BEF-BB1E-FAE699722922}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{95271823-A8FC-4BEF-BB1E-FAE699722922}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8B4CCF50-E109-4206-9FEB-93F199C42B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8B4CCF50-E109-4206-9FEB-93F199C42B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8B4CCF50-E109-4206-9FEB-93F199C42B8A}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8B4CCF50-E109-4206-9FEB-93F199C42B8A}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8B4CCF50-E109-4206-9FEB-93F199C42B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8B4CCF50-E109-4206-9FEB-93F199C42B8A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1E338315-4BA9-4091-A06E-DE80399A1CF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1E338315-4BA9-4091-A06E-DE80399A1CF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1E338315-4BA9-4091-A06E-DE80399A1CF9}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1E338315-4BA9-4091-A06E-DE80399A1CF9}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1E338315-4BA9-4091-A06E-DE80399A1CF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1E338315-4BA9-4091-A06E-DE80399A1CF9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A5B51533-33B6-43AF-9D2D-410613078E96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A5B51533-33B6-43AF-9D2D-410613078E96}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A5B51533-33B6-43AF-9D2D-410613078E96}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A5B51533-33B6-43AF-9D2D-410613078E96}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A5B51533-33B6-43AF-9D2D-410613078E96}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A5B51533-33B6-43AF-9D2D-410613078E96}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{08C31FF8-AC47-498D-ACD9-612FA8001F1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{08C31FF8-AC47-498D-ACD9-612FA8001F1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{08C31FF8-AC47-498D-ACD9-612FA8001F1F}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{08C31FF8-AC47-498D-ACD9-612FA8001F1F}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{08C31FF8-AC47-498D-ACD9-612FA8001F1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{08C31FF8-AC47-498D-ACD9-612FA8001F1F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{C6359697-25F1-4049-8D73-AC48043CA192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C6359697-25F1-4049-8D73-AC48043CA192}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C6359697-25F1-4049-8D73-AC48043CA192}.GlobalNadeko|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{C6359697-25F1-4049-8D73-AC48043CA192}.GlobalNadeko|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{C6359697-25F1-4049-8D73-AC48043CA192}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{C6359697-25F1-4049-8D73-AC48043CA192}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -147,6 +203,13 @@ Global
|
|||||||
{02499E3E-3B04-4BC8-9B3C-D9494661F78E} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{02499E3E-3B04-4BC8-9B3C-D9494661F78E} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{02ABC10E-3323-4698-A388-C61D7D03797E} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{02ABC10E-3323-4698-A388-C61D7D03797E} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
{5F4F36A5-5874-4461-BB34-EE107E4B7F15} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
{5F4F36A5-5874-4461-BB34-EE107E4B7F15} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{65E2A9D2-2239-41B0-AC46-48ACDDF6B121} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{95271823-A8FC-4BEF-BB1E-FAE699722922} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{8B4CCF50-E109-4206-9FEB-93F199C42B8A} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{1E338315-4BA9-4091-A06E-DE80399A1CF9} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{A5B51533-33B6-43AF-9D2D-410613078E96} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{08C31FF8-AC47-498D-ACD9-612FA8001F1F} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
|
{C6359697-25F1-4049-8D73-AC48043CA192} = {04929013-5BAB-42B0-B9B2-8F2BB8F16AF2}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {5F3F555C-855F-4BE8-B526-D062D3E8ACA4}
|
SolutionGuid = {5F3F555C-855F-4BE8-B526-D062D3E8ACA4}
|
||||||
|
@@ -1,6 +1,29 @@
|
|||||||
namespace Nadeko.Bot.Common;
|
using System.Globalization;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
|
namespace Nadeko.Bot.Common;
|
||||||
|
|
||||||
public interface ICurrencyProvider
|
public interface ICurrencyProvider
|
||||||
{
|
{
|
||||||
string GetCurrencySign();
|
string GetCurrencySign();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CurrencyHelper
|
||||||
|
{
|
||||||
|
public static string N<T>(T cur, IFormatProvider format)
|
||||||
|
where T : INumber<T>
|
||||||
|
=> cur.ToString("C0", format);
|
||||||
|
|
||||||
|
public static string N<T>(T cur, CultureInfo culture, string currencySign)
|
||||||
|
where T : INumber<T>
|
||||||
|
=> N(cur, GetCurrencyFormat(culture, currencySign));
|
||||||
|
|
||||||
|
private static IFormatProvider GetCurrencyFormat(CultureInfo culture, string currencySign)
|
||||||
|
{
|
||||||
|
var flowersCurrencyCulture = (CultureInfo)culture.Clone();
|
||||||
|
flowersCurrencyCulture.NumberFormat.CurrencySymbol = currencySign;
|
||||||
|
flowersCurrencyCulture.NumberFormat.CurrencyNegativePattern = 5;
|
||||||
|
|
||||||
|
return flowersCurrencyCulture;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -25,6 +25,9 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<Publish>True</Publish>
|
<Publish>True</Publish>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
|
||||||
|
|
||||||
<ProjectReference Include="..\Nadeko.Medusa\Nadeko.Medusa.csproj" />
|
<ProjectReference Include="..\Nadeko.Medusa\Nadeko.Medusa.csproj" />
|
||||||
|
|
||||||
<ProjectReference Include="..\NadekoBot.Generators\NadekoBot.Generators.csproj" OutputItemType="Analyzer" />
|
<ProjectReference Include="..\NadekoBot.Generators\NadekoBot.Generators.csproj" OutputItemType="Analyzer" />
|
||||||
|
6
src/Nadeko.Bot.Common/Services/ITimezoneService.cs
Normal file
6
src/Nadeko.Bot.Common/Services/ITimezoneService.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace NadekoBot.Common;
|
||||||
|
|
||||||
|
public interface ITimezoneService
|
||||||
|
{
|
||||||
|
TimeZoneInfo GetTimeZoneOrUtc(ulong? guildId);
|
||||||
|
}
|
@@ -1,13 +1,11 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
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 ITimezoneService _gts;
|
||||||
|
|
||||||
public GuildDateTimeTypeReader(GuildTimezoneService gts)
|
public GuildDateTimeTypeReader(ITimezoneService gts)
|
||||||
=> _gts = gts;
|
=> _gts = gts;
|
||||||
|
|
||||||
public override ValueTask<TypeReaderResult<GuildDateTime>> ReadAsync(ICommandContext context, string input)
|
public override ValueTask<TypeReaderResult<GuildDateTime>> ReadAsync(ICommandContext context, string input)
|
@@ -1,5 +1,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
|
using LinqToDB.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NadekoBot.Services.Database;
|
using NadekoBot.Services.Database;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
@@ -60,4 +61,12 @@ public static class UserXpExtensions
|
|||||||
|
|
||||||
public static void ResetGuildXp(this DbSet<UserXpStats> xps, ulong guildId)
|
public static void ResetGuildXp(this DbSet<UserXpStats> xps, ulong guildId)
|
||||||
=> xps.Delete(x => x.GuildId == guildId);
|
=> xps.Delete(x => x.GuildId == guildId);
|
||||||
|
|
||||||
|
public static async Task<LevelStats> GetLevelDataFor(this ITable<UserXpStats> userXp, ulong guildId, ulong userId)
|
||||||
|
=> await userXp
|
||||||
|
.Where(x => x.GuildId == guildId && x.UserId == userId)
|
||||||
|
.FirstOrDefaultAsyncLinqToDB() is UserXpStats uxs
|
||||||
|
? new(uxs.Xp + uxs.AwardedXp)
|
||||||
|
: new(0);
|
||||||
|
|
||||||
}
|
}
|
@@ -1,10 +1,11 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using NadekoBot.Modules.Xp.Services;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Xp;
|
namespace NadekoBot.Db;
|
||||||
|
|
||||||
public readonly struct LevelStats
|
public readonly struct LevelStats
|
||||||
{
|
{
|
||||||
|
public const int XP_REQUIRED_LVL_1 = 36;
|
||||||
|
|
||||||
public long Level { get; }
|
public long Level { get; }
|
||||||
public long LevelXp { get; }
|
public long LevelXp { get; }
|
||||||
public long RequiredXp { get; }
|
public long RequiredXp { get; }
|
||||||
@@ -17,7 +18,7 @@ public readonly struct LevelStats
|
|||||||
|
|
||||||
TotalXp = xp;
|
TotalXp = xp;
|
||||||
|
|
||||||
const int baseXp = XpService.XP_REQUIRED_LVL_1;
|
const int baseXp = XP_REQUIRED_LVL_1;
|
||||||
|
|
||||||
var required = baseXp;
|
var required = baseXp;
|
||||||
var totalXp = 0;
|
var totalXp = 0;
|
@@ -14,7 +14,7 @@ public class AdministrationService : INService
|
|||||||
private readonly ILogCommandService _logService;
|
private readonly ILogCommandService _logService;
|
||||||
|
|
||||||
public AdministrationService(
|
public AdministrationService(
|
||||||
Bot bot,
|
IBot bot,
|
||||||
CommandHandler cmdHandler,
|
CommandHandler cmdHandler,
|
||||||
DbService db,
|
DbService db,
|
||||||
ILogCommandService logService)
|
ILogCommandService logService)
|
@@ -1,11 +1,10 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using LinqToDB;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using NadekoBot.Db;
|
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Channels;
|
using System.Threading.Channels;
|
||||||
using Nadeko.Common;
|
using LinqToDB;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using NadekoBot.Db;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Services;
|
namespace NadekoBot.Modules.Administration.Services;
|
||||||
|
|
||||||
@@ -25,7 +24,7 @@ public sealed class AutoAssignRoleService : INService
|
|||||||
SingleWriter = false
|
SingleWriter = false
|
||||||
});
|
});
|
||||||
|
|
||||||
public AutoAssignRoleService(DiscordSocketClient client, Bot bot, DbService db)
|
public AutoAssignRoleService(DiscordSocketClient client, IBot bot, DbService db)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
_db = db;
|
_db = db;
|
@@ -10,7 +10,7 @@ public class GameVoiceChannelService : INService
|
|||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
|
|
||||||
public GameVoiceChannelService(DiscordSocketClient client, DbService db, Bot bot)
|
public GameVoiceChannelService(DiscordSocketClient client, DbService db, IBot bot)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_client = client;
|
_client = client;
|
32
src/Nadeko.Bot.Modules.Administration/GlobalUsings.cs
Normal file
32
src/Nadeko.Bot.Modules.Administration/GlobalUsings.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// // global using System.Collections.Concurrent;
|
||||||
|
global using NonBlocking;
|
||||||
|
//
|
||||||
|
// // packages
|
||||||
|
global using Serilog;
|
||||||
|
global using Humanizer;
|
||||||
|
global using Newtonsoft;
|
||||||
|
//
|
||||||
|
// // nadekobot
|
||||||
|
// global using NadekoBot;
|
||||||
|
global using NadekoBot.Services;
|
||||||
|
global using Nadeko.Common; // new project
|
||||||
|
global using NadekoBot.Common; // old + nadekobot specific things
|
||||||
|
global using NadekoBot.Common.Attributes;
|
||||||
|
global using NadekoBot.Extensions;
|
||||||
|
// global using Nadeko.Snake;
|
||||||
|
|
||||||
|
// discord
|
||||||
|
global using Discord;
|
||||||
|
global using Discord.Commands;
|
||||||
|
global using Discord.Net;
|
||||||
|
global using Discord.WebSocket;
|
||||||
|
|
||||||
|
// aliases
|
||||||
|
global using GuildPerm = Discord.GuildPermission;
|
||||||
|
global using ChannelPerm = Discord.ChannelPermission;
|
||||||
|
global using BotPermAttribute = Discord.Commands.RequireBotPermissionAttribute;
|
||||||
|
global using LeftoverAttribute = Discord.Commands.RemainderAttribute;
|
||||||
|
global using TypeReaderResult = NadekoBot.Common.TypeReaders.TypeReaderResult;
|
||||||
|
|
||||||
|
// non-essential
|
||||||
|
// global using JetBrains.Annotations;
|
@@ -21,7 +21,7 @@ public class GreetService : INService, IReadyExecutor
|
|||||||
|
|
||||||
public GreetService(
|
public GreetService(
|
||||||
DiscordSocketClient client,
|
DiscordSocketClient client,
|
||||||
Bot bot,
|
IBot bot,
|
||||||
DbService db,
|
DbService db,
|
||||||
BotConfigService bss)
|
BotConfigService bss)
|
||||||
{
|
{
|
@@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Discord.Net" Version="3.104.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Nadeko.Bot.Common\Nadeko.Bot.Common.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@@ -33,7 +33,7 @@ public class ProtectionService : INService
|
|||||||
|
|
||||||
public ProtectionService(
|
public ProtectionService(
|
||||||
DiscordSocketClient client,
|
DiscordSocketClient client,
|
||||||
Bot bot,
|
IBot bot,
|
||||||
MuteService mute,
|
MuteService mute,
|
||||||
DbService db,
|
DbService db,
|
||||||
UserPunishService punishService)
|
UserPunishService punishService)
|
@@ -2,8 +2,8 @@
|
|||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
using LinqToDB.EntityFrameworkCore;
|
using LinqToDB.EntityFrameworkCore;
|
||||||
using NadekoBot.Common.ModuleBehaviors;
|
using NadekoBot.Common.ModuleBehaviors;
|
||||||
|
using NadekoBot.Db;
|
||||||
using NadekoBot.Modules.Utility.Patronage;
|
using NadekoBot.Modules.Utility.Patronage;
|
||||||
using NadekoBot.Modules.Xp.Extensions;
|
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
using OneOf.Types;
|
using OneOf.Types;
|
||||||
using OneOf;
|
using OneOf;
|
@@ -1,7 +1,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NadekoBot.Db;
|
using NadekoBot.Db;
|
||||||
using NadekoBot.Modules.Xp;
|
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Services;
|
namespace NadekoBot.Modules.Administration.Services;
|
@@ -1,17 +1,16 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using Nadeko.Common;
|
|
||||||
using NadekoBot.Db;
|
using NadekoBot.Db;
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration.Services;
|
namespace NadekoBot.Modules.Administration.Services;
|
||||||
|
|
||||||
public class GuildTimezoneService : INService
|
public sealed class GuildTimezoneService : ITimezoneService, INService
|
||||||
{
|
{
|
||||||
public static ConcurrentDictionary<ulong, GuildTimezoneService> AllServices { get; } = new();
|
public static ConcurrentDictionary<ulong, GuildTimezoneService> AllServices { get; } = new();
|
||||||
private readonly ConcurrentDictionary<ulong, TimeZoneInfo> _timezones;
|
private readonly ConcurrentDictionary<ulong, TimeZoneInfo> _timezones;
|
||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
|
|
||||||
public GuildTimezoneService(DiscordSocketClient client, Bot bot, DbService db)
|
public GuildTimezoneService(DiscordSocketClient client, IBot bot, DbService db)
|
||||||
{
|
{
|
||||||
_timezones = bot.AllGuildConfigs.Select(GetTimzezoneTuple)
|
_timezones = bot.AllGuildConfigs.Select(GetTimzezoneTuple)
|
||||||
.Where(x => x.Timezone is not null)
|
.Where(x => x.Timezone is not null)
|
||||||
@@ -52,10 +51,11 @@ public class GuildTimezoneService : INService
|
|||||||
return (x.GuildId, Timezone: tz);
|
return (x.GuildId, Timezone: tz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeZoneInfo GetTimeZoneOrDefault(ulong guildId)
|
public TimeZoneInfo GetTimeZoneOrDefault(ulong? guildId)
|
||||||
{
|
{
|
||||||
if (_timezones.TryGetValue(guildId, out var tz))
|
if (guildId is ulong gid && _timezones.TryGetValue(gid, out var tz))
|
||||||
return tz;
|
return tz;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +73,6 @@ public class GuildTimezoneService : INService
|
|||||||
_timezones.AddOrUpdate(guildId, tz, (_, _) => tz);
|
_timezones.AddOrUpdate(guildId, tz, (_, _) => tz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeZoneInfo GetTimeZoneOrUtc(ulong guildId)
|
public TimeZoneInfo GetTimeZoneOrUtc(ulong? guildId)
|
||||||
=> GetTimeZoneOrDefault(guildId) ?? TimeZoneInfo.Utc;
|
=> GetTimeZoneOrDefault(guildId) ?? TimeZoneInfo.Utc;
|
||||||
}
|
}
|
@@ -3,7 +3,6 @@ using CommandLine;
|
|||||||
using Humanizer.Localisation;
|
using Humanizer.Localisation;
|
||||||
using NadekoBot.Common.TypeReaders.Models;
|
using NadekoBot.Common.TypeReaders.Models;
|
||||||
using NadekoBot.Modules.Administration.Services;
|
using NadekoBot.Modules.Administration.Services;
|
||||||
using NadekoBot.Modules.Permissions.Services;
|
|
||||||
using NadekoBot.Services.Database.Models;
|
using NadekoBot.Services.Database.Models;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Administration;
|
namespace NadekoBot.Modules.Administration;
|
||||||
@@ -19,12 +18,10 @@ public partial class Administration
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly MuteService _mute;
|
private readonly MuteService _mute;
|
||||||
private readonly BlacklistService _blacklistService;
|
|
||||||
|
|
||||||
public UserPunishCommands(MuteService mute, BlacklistService blacklistService)
|
public UserPunishCommands(MuteService mute)
|
||||||
{
|
{
|
||||||
_mute = mute;
|
_mute = mute;
|
||||||
_blacklistService = blacklistService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> CheckRoleHierarchy(IGuildUser target)
|
private async Task<bool> CheckRoleHierarchy(IGuildUser target)
|
@@ -13,7 +13,7 @@ public class VcRoleService : INService
|
|||||||
private readonly DbService _db;
|
private readonly DbService _db;
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
|
|
||||||
public VcRoleService(DiscordSocketClient client, Bot bot, DbService db)
|
public VcRoleService(DiscordSocketClient client, IBot bot, DbService db)
|
||||||
{
|
{
|
||||||
_db = db;
|
_db = db;
|
||||||
_client = client;
|
_client = client;
|
@@ -3,6 +3,7 @@ using NadekoBot.Modules.Gambling.Services;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Discord;
|
using Discord;
|
||||||
|
using Nadeko.Bot.Common;
|
||||||
using NadekoBot.Common;
|
using NadekoBot.Common;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Gambling.Common;
|
namespace NadekoBot.Modules.Gambling.Common;
|
||||||
@@ -42,21 +43,9 @@ public abstract class GamblingModule<TService> : NadekoModule<TService>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string N<T>(T cur, IFormatProvider format)
|
|
||||||
where T : INumber<T>
|
|
||||||
=> cur.ToString("C0", format);
|
|
||||||
|
|
||||||
protected string N<T>(T cur)
|
protected string N<T>(T cur)
|
||||||
where T : INumber<T>
|
where T : INumber<T>
|
||||||
=> N(cur, GetFlowersCiInternal());
|
=> CurrencyHelper.N(cur, Culture, CurrencySign);
|
||||||
|
|
||||||
protected IFormatProvider GetFlowersCiInternal()
|
|
||||||
{
|
|
||||||
var flowersCi = (CultureInfo)Culture.Clone();
|
|
||||||
flowersCi.NumberFormat.CurrencySymbol = CurrencySign;
|
|
||||||
flowersCi.NumberFormat.CurrencyNegativePattern = 5;
|
|
||||||
return flowersCi;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Task<bool> CheckBetMandatory(long amount)
|
protected Task<bool> CheckBetMandatory(long amount)
|
||||||
{
|
{
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
|
using NadekoBot.Common;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Help.Common;
|
namespace NadekoBot.Modules.Help.Common;
|
||||||
|
|
32
src/Nadeko.Bot.Modules.Help/GlobalUsings.cs
Normal file
32
src/Nadeko.Bot.Modules.Help/GlobalUsings.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// // global using System.Collections.Concurrent;
|
||||||
|
global using NonBlocking;
|
||||||
|
//
|
||||||
|
// // packages
|
||||||
|
global using Serilog;
|
||||||
|
global using Humanizer;
|
||||||
|
global using Newtonsoft;
|
||||||
|
//
|
||||||
|
// // nadekobot
|
||||||
|
// global using NadekoBot;
|
||||||
|
global using NadekoBot.Services;
|
||||||
|
global using Nadeko.Common; // new project
|
||||||
|
global using NadekoBot.Common; // old + nadekobot specific things
|
||||||
|
global using NadekoBot.Common.Attributes;
|
||||||
|
global using NadekoBot.Extensions;
|
||||||
|
// global using Nadeko.Snake;
|
||||||
|
|
||||||
|
// discord
|
||||||
|
global using Discord;
|
||||||
|
global using Discord.Commands;
|
||||||
|
global using Discord.Net;
|
||||||
|
global using Discord.WebSocket;
|
||||||
|
|
||||||
|
// aliases
|
||||||
|
global using GuildPerm = Discord.GuildPermission;
|
||||||
|
global using ChannelPerm = Discord.ChannelPermission;
|
||||||
|
global using BotPermAttribute = Discord.Commands.RequireBotPermissionAttribute;
|
||||||
|
global using LeftoverAttribute = Discord.Commands.RemainderAttribute;
|
||||||
|
global using TypeReaderResult = NadekoBot.Common.TypeReaders.TypeReaderResult;
|
||||||
|
|
||||||
|
// non-essential
|
||||||
|
// global using JetBrains.Annotations;
|
@@ -3,11 +3,9 @@ using Amazon.S3;
|
|||||||
using Nadeko.Medusa;
|
using Nadeko.Medusa;
|
||||||
using NadekoBot.Modules.Help.Common;
|
using NadekoBot.Modules.Help.Common;
|
||||||
using NadekoBot.Modules.Help.Services;
|
using NadekoBot.Modules.Help.Services;
|
||||||
using NadekoBot.Modules.Permissions.Services;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using Nadeko.Common;
|
|
||||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Help;
|
namespace NadekoBot.Modules.Help;
|
@@ -3,7 +3,6 @@ using CommandLine;
|
|||||||
using Nadeko.Common;
|
using Nadeko.Common;
|
||||||
using Nadeko.Medusa;
|
using Nadeko.Medusa;
|
||||||
using NadekoBot.Common.ModuleBehaviors;
|
using NadekoBot.Common.ModuleBehaviors;
|
||||||
using NadekoBot.Modules.Administration.Services;
|
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Help.Services;
|
namespace NadekoBot.Modules.Help.Services;
|
||||||
|
|
17
src/Nadeko.Bot.Modules.Help/Nadeko.Bot.Modules.Help.csproj
Normal file
17
src/Nadeko.Bot.Modules.Help/Nadeko.Bot.Modules.Help.csproj
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Nadeko.Bot.Common\Nadeko.Bot.Common.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AWSSDK.S3" Version="3.7.101.58" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
31
src/Nadeko.Bot.Modules.Music/GlobalUsings.cs
Normal file
31
src/Nadeko.Bot.Modules.Music/GlobalUsings.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
// global using System.Collections.Concurrent;
|
||||||
|
global using NonBlocking;
|
||||||
|
|
||||||
|
// packages
|
||||||
|
global using Serilog;
|
||||||
|
global using Humanizer;
|
||||||
|
|
||||||
|
// nadekobot
|
||||||
|
global using NadekoBot;
|
||||||
|
global using NadekoBot.Services;
|
||||||
|
global using Nadeko.Common; // new project
|
||||||
|
global using NadekoBot.Common; // old + nadekobot specific things
|
||||||
|
global using NadekoBot.Common.Attributes;
|
||||||
|
global using NadekoBot.Extensions;
|
||||||
|
global using Nadeko.Snake;
|
||||||
|
|
||||||
|
// discord
|
||||||
|
global using Discord;
|
||||||
|
global using Discord.Commands;
|
||||||
|
global using Discord.Net;
|
||||||
|
global using Discord.WebSocket;
|
||||||
|
|
||||||
|
// aliases
|
||||||
|
global using GuildPerm = Discord.GuildPermission;
|
||||||
|
global using ChannelPerm = Discord.ChannelPermission;
|
||||||
|
global using BotPermAttribute = Discord.Commands.RequireBotPermissionAttribute;
|
||||||
|
global using LeftoverAttribute = Discord.Commands.RemainderAttribute;
|
||||||
|
global using TypeReaderResult = NadekoBot.Common.TypeReaders.TypeReaderResult;
|
||||||
|
|
||||||
|
// non-essential
|
||||||
|
global using JetBrains.Annotations;
|
@@ -16,7 +16,7 @@ public sealed partial class Music : NadekoModule<IMusicService>
|
|||||||
Q = 2, Queue = 2, Playlist = 2, Pl = 2
|
Q = 2, Queue = 2, Playlist = 2, Pl = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
public const string MUSIC_ICON_URL = "http://i.imgur.com/nhKS3PT.png";
|
public const string MUSIC_ICON_URL = "https://i.imgur.com/nhKS3PT.png";
|
||||||
|
|
||||||
private const int LQ_ITEMS_PER_PAGE = 9;
|
private const int LQ_ITEMS_PER_PAGE = 9;
|
||||||
|
|
19
src/Nadeko.Bot.Modules.Music/Nadeko.Bot.Modules.Music.csproj
Normal file
19
src/Nadeko.Bot.Modules.Music/Nadeko.Bot.Modules.Music.csproj
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ayu\Ayu.Discord.Voice\Ayu.Discord.Voice.csproj" />
|
||||||
|
<ProjectReference Include="..\Nadeko.Bot.Common\Nadeko.Bot.Common.csproj" />
|
||||||
|
<ProjectReference Include="..\Nadeko.Bot.Modules.Searches\Nadeko.Bot.Modules.Searches.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user