Skip to content

Commit 2db5d1b

Browse files
committed
feat: format project
add braces, remove BOM
1 parent 7537286 commit 2db5d1b

11 files changed

Lines changed: 47 additions & 19 deletions

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
**/.dockerignore
1+
**/.dockerignore
22
**/.env
33
**/.git
44
**/.gitignore

EmbedBot/Commands/EmbedCommand.Create.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DSharpPlus;
1+
using DSharpPlus;
22
using DSharpPlus.Entities;
33
using DSharpPlus.SlashCommands;
44
using EmbedBot.Interactivity;
@@ -35,7 +35,9 @@ public async Task CreateEmbedAsync(InteractionContext context,
3535
DiscordColor color = DiscordColor.CornflowerBlue;
3636

3737
if (!string.IsNullOrWhiteSpace(colorInput.Value))
38+
{
3839
color = new DiscordColor(colorInput.Value);
40+
}
3941

4042
var embed = new DiscordEmbedBuilder();
4143
embed.WithColor(color);

EmbedBot/Commands/EmbedCommand.Edit.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public async Task EditAsync(InteractionContext context,
6565
await context.CreateResponseAsync(InteractionResponseType.ChannelMessageWithSource, response).ConfigureAwait(false);
6666
return;
6767
}
68-
68+
6969
var builder = new DiscordEmbedBuilder(message.Embeds[0]);
7070

7171
var modal = new DiscordModalBuilder(context.Client);
@@ -74,19 +74,26 @@ public async Task EditAsync(InteractionContext context,
7474
DiscordModalTextInput titleInput = modal.AddInput("Title", "The title of the embed.", maxLength: 256, isRequired: false, initialValue: builder.Title);
7575
DiscordModalTextInput colorInput = modal.AddInput("Color", "e.g. #007EC6", maxLength: 7, isRequired: false, initialValue: builder.Color.HasValue ? builder.Color.Value.ToString() : null);
7676
DiscordModalTextInput descriptionInput = modal.AddInput("Description", "The body of the embed.", isRequired: true, maxLength: 2048, inputStyle: TextInputStyle.Paragraph, initialValue: builder.Description);
77-
78-
DiscordModalResponse modalResponse = await modal.Build().RespondToAsync(context.Interaction, TimeSpan.FromMinutes(5)).ConfigureAwait(false);
77+
78+
DiscordModalResponse modalResponse =
79+
await modal.Build().RespondToAsync(context.Interaction, TimeSpan.FromMinutes(5)).ConfigureAwait(false);
7980
if (modalResponse == DiscordModalResponse.Timeout)
81+
{
8082
return;
83+
}
8184

8285
if (string.IsNullOrWhiteSpace(titleInput.Value) && string.IsNullOrWhiteSpace(descriptionInput.Value))
86+
{
8387
return;
88+
}
8489

8590
DiscordColor color = builder.Color.HasValue ? builder.Color.Value : DiscordColor.CornflowerBlue;
86-
91+
8792
if (!string.IsNullOrWhiteSpace(colorInput.Value))
93+
{
8894
color = new DiscordColor(colorInput.Value);
89-
95+
}
96+
9097
builder.WithColor(color);
9198
builder.WithTitle(titleInput.Value);
9299
builder.WithDescription(descriptionInput.Value);

EmbedBot/Commands/InfoCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Text;
1+
using System.Text;
22
using DSharpPlus;
33
using DSharpPlus.Entities;
44
using DSharpPlus.SlashCommands;

EmbedBot/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
1+
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
22
WORKDIR /app
33

44
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

EmbedBot/Interactivity/Conversation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Concurrent;
1+
using System.Collections.Concurrent;
22

33
namespace EmbedBot.Interactivity;
44

@@ -16,7 +16,7 @@ public Conversation(IServiceProvider services)
1616
{
1717
Services = services;
1818
}
19-
19+
2020
public ConcurrentDictionary<string, bool> BooleanBlackboard { get; } = new();
2121
public ConcurrentDictionary<string, int> Int32BlackBoard { get; } = new();
2222
public ConcurrentDictionary<string, string> StringBlackboard { get; } = new();

EmbedBot/Interactivity/ConversationContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DSharpPlus;
1+
using DSharpPlus;
22
using DSharpPlus.Entities;
33
using DSharpPlus.SlashCommands;
44
using Microsoft.Extensions.DependencyInjection;

EmbedBot/Interactivity/ConversationState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace EmbedBot.Interactivity;
1+
namespace EmbedBot.Interactivity;
22

33
/// <summary>
44
/// Represents a state of a <see cref="Conversation" />.

EmbedBot/Interactivity/DiscordModal.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DSharpPlus;
1+
using DSharpPlus;
22
using DSharpPlus.Entities;
33
using DSharpPlus.EventArgs;
44

@@ -38,7 +38,10 @@ internal DiscordModal(string title, IEnumerable<DiscordModalTextInput> inputs, D
3838
/// <exception cref="ArgumentNullException"><paramref name="interaction" /> is <see langword="null" />.</exception>
3939
public async Task<DiscordModalResponse> RespondToAsync(DiscordInteraction interaction, TimeSpan timeout)
4040
{
41-
if (interaction is null) throw new ArgumentNullException(nameof(interaction));
41+
if (interaction is null)
42+
{
43+
throw new ArgumentNullException(nameof(interaction));
44+
}
4245

4346
var builder = new DiscordInteractionResponseBuilder();
4447
builder.WithTitle(Title);
@@ -53,7 +56,9 @@ public async Task<DiscordModalResponse> RespondToAsync(DiscordInteraction intera
5356
var cancellationTokenSource = new CancellationTokenSource();
5457
cancellationTokenSource.Token.Register(() => _taskCompletionSource.TrySetCanceled());
5558
if (timeout != Timeout.InfiniteTimeSpan)
59+
{
5660
cancellationTokenSource.CancelAfter(timeout);
61+
}
5762

5863
try
5964
{
@@ -69,7 +74,9 @@ public async Task<DiscordModalResponse> RespondToAsync(DiscordInteraction intera
6974
private Task OnModalSubmitted(DiscordClient sender, ModalSubmitEventArgs e)
7075
{
7176
if (e.Interaction.Data.CustomId != _customId)
77+
{
7278
return Task.CompletedTask;
79+
}
7380

7481
_discordClient.ModalSubmitted -= OnModalSubmitted;
7582

@@ -78,7 +85,9 @@ private Task OnModalSubmitted(DiscordClient sender, ModalSubmitEventArgs e)
7885
foreach (TextInputComponent inputComponent in inputComponents)
7986
{
8087
if (_inputs.TryGetValue(inputComponent.CustomId, out DiscordModalTextInput? input))
88+
{
8189
input.Value = inputComponent.Value;
90+
}
8291
}
8392

8493
_taskCompletionSource.TrySetResult();

EmbedBot/Interactivity/DiscordModalBuilder.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using DSharpPlus;
1+
using DSharpPlus;
22
using DSharpPlus.Entities;
33

44
namespace EmbedBot.Interactivity;
@@ -31,7 +31,9 @@ public string Title
3131
set
3232
{
3333
if (string.IsNullOrWhiteSpace(value))
34+
{
3435
throw new ArgumentException("Value cannot be null or whitespace.", nameof(value));
36+
}
3537

3638
_title = value;
3739
}
@@ -79,7 +81,11 @@ public DiscordModalBuilder WithTitle(string title)
7981
/// <exception cref="ArgumentNullException"><paramref name="builder" /> is <see langword="null" />.</exception>
8082
public static implicit operator DiscordModal(DiscordModalBuilder builder)
8183
{
82-
if (builder is null) throw new ArgumentNullException(nameof(builder));
84+
if (builder is null)
85+
{
86+
throw new ArgumentNullException(nameof(builder));
87+
}
88+
8389
return builder.Build();
8490
}
8591

@@ -89,7 +95,11 @@ public static implicit operator DiscordModal(DiscordModalBuilder builder)
8995
/// <returns>The newly-constructed <see cref="DiscordModal" />.</returns>
9096
public DiscordModal Build()
9197
{
92-
if (string.IsNullOrWhiteSpace(_title)) throw new InvalidOperationException("Title cannot be null or whitespace.");
98+
if (string.IsNullOrWhiteSpace(_title))
99+
{
100+
throw new InvalidOperationException("Title cannot be null or whitespace.");
101+
}
102+
93103
return new DiscordModal(Title, _inputs, _discordClient);
94104
}
95105
}

0 commit comments

Comments
 (0)