Skip to content

Commit

Permalink
Update packages
Browse files Browse the repository at this point in the history
  • Loading branch information
KubaZ2 committed Oct 10, 2024
1 parent 1ff8bcb commit da1d83c
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Backend/Sandbox/Asm/Asm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="8.0.400" />
<PackageReference Include="FSharp.Core" Version="8.0.401" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Backend/Sandbox/Runner/Runner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="8.0.400" />
<PackageReference Include="FSharp.Core" Version="8.0.401" />
</ItemGroup>

<PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions Bot/Sharp/Attachments/AttachmentCodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace Sharp.Attachments;

public class AttachmentCodeProvider(IHttpClientFactory httpClientFactory, IOptions<Options> options) : IAttachmentCodeProvider
{
public async ValueTask<AttachmentCodeResult> GetCodeAsync(IEnumerable<Attachment> attachments)
public async ValueTask<AttachmentCodeResult> GetCodeAsync(IReadOnlyList<Attachment> attachments)
{
var attachment = attachments.FirstOrDefault();

if (attachment is null)
if (attachments.Count is 0)
return new AttachmentCodeResult.CodeNotFound();

var attachment = attachments[0];

if (attachment.Size > options.Value.MaxFileSize)
return new AttachmentCodeResult.FileTooLarge();

Expand Down
2 changes: 1 addition & 1 deletion Bot/Sharp/Attachments/IAttachmentCodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public record FileTooLarge : AttachmentCodeResult;

public interface IAttachmentCodeProvider
{
public ValueTask<AttachmentCodeResult> GetCodeAsync(IEnumerable<Attachment> attachments);
public ValueTask<AttachmentCodeResult> GetCodeAsync(IReadOnlyList<Attachment> attachments);
}
2 changes: 1 addition & 1 deletion Bot/Sharp/CommandHostExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static IHost AddDecompileCommands(this IHost host)

host.AddCommand<CommandContext>(aliases, async (IServiceProvider services, IAttachmentCodeProvider attachmentCodeProvider, CommandContext context) =>
{
var result = await attachmentCodeProvider.GetCodeAsync(context.Message.Attachments.Values);
var result = await attachmentCodeProvider.GetCodeAsync(context.Message.Attachments);

if (result is not AttachmentCodeResult.Success { Language: var sourceLanguage, Code: var code })
return services.GetRequiredService<IResponseProvider>().AttachmentCodeResultResponse<ReplyMessageProperties>(context.Message.Id, result);
Expand Down
2 changes: 1 addition & 1 deletion Bot/Sharp/Modules/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Task<ReplyMessageProperties> RunAsync([CommandParameter(Remainder = true)
[Command("run", Priority = 2)]
public async Task<ReplyMessageProperties> RunAsync(BackendArchitecture architecture)
{
var result = await attachmentCodeProvider.GetCodeAsync(Context.Message.Attachments.Values);
var result = await attachmentCodeProvider.GetCodeAsync(Context.Message.Attachments);

if (result is not AttachmentCodeResult.Success { Language: var language, Code: var code })
return responseProvider.AttachmentCodeResultResponse<ReplyMessageProperties>(Context.Message.Id, result);
Expand Down
7 changes: 2 additions & 5 deletions Bot/Sharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,13 @@
.AddSingleton<ILanguageMatcher, LanguageMatcher>()
.AddSingleton<ICompilationProvider, CompilationProvider>()
.AddSingleton<IDecompilationProvider, DecompilationProvider>()
.AddSingleton<IRateLimiter, RateLimiter>()
.AddSingleton<Sharp.RateLimits.IRateLimiter, RateLimiter>()
.AddCommands<CommandContext>(o => o.ResultHandler = new EnhancedCommandServiceResultHandler<CommandContext>())
.AddApplicationCommands<SlashCommandInteraction, SlashCommandContext>(o => o.ResultHandler = new EnhancedApplicationCommandServiceResultHandler<SlashCommandContext>())
.AddComponentInteractions<ButtonInteraction, ButtonInteractionContext>(o => o.ResultHandler = new EnhancedComponentInteractionServiceResultHandler<ButtonInteractionContext>())
.AddDiscordGateway(o =>
{
o.Configuration = new()
{
Intents = GatewayIntents.GuildMessages | GatewayIntents.DirectMessages | GatewayIntents.MessageContent,
};
o.Intents = GatewayIntents.GuildMessages | GatewayIntents.DirectMessages | GatewayIntents.MessageContent;
});

var host = builder.Build();
Expand Down
2 changes: 1 addition & 1 deletion Bot/Sharp/Responding/ResponseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public class ResponseProvider(IOptions<Options> options, IOptions<CommandService

var discordOptionsValue = discordOptions.Value;

var prefix = discordOptionsValue.Prefixes is { Count: > 0 } prefixes ? prefixes[0] : discordOptionsValue.Prefix;
var prefix = discordOptionsValue.Prefixes?.FirstOrDefault() ?? discordOptionsValue.Prefix;

message.AddEmbeds(new EmbedProperties().WithDescription(
$"""
Expand Down
20 changes: 10 additions & 10 deletions Bot/Sharp/Sharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.4" />
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.9" />
<PackageReference Include="ICSharpCode.Decompiler" Version="8.2.0.7535" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="4.11.0" />
<PackageReference Include="FSharp.Compiler.Service" Version="43.8.400" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="NetCord" Version="1.0.0-alpha.311" />
<PackageReference Include="NetCord.Services" Version="1.0.0-alpha.212" />
<PackageReference Include="NetCord.Hosting" Version="1.0.0-alpha.81" />
<PackageReference Include="NetCord.Hosting.Services" Version="1.0.0-alpha.90" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="FSharp.Compiler.Service" Version="43.8.401" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="NetCord" Version="1.0.0-alpha.325" />
<PackageReference Include="NetCord.Services" Version="1.0.0-alpha.226" />
<PackageReference Include="NetCord.Hosting" Version="1.0.0-alpha.95" />
<PackageReference Include="NetCord.Hosting.Services" Version="1.0.0-alpha.104" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit da1d83c

Please sign in to comment.