From 7adec9d650c0abae8bcc37f4b7ab90550d30c944 Mon Sep 17 00:00:00 2001
From: Jan <42674570+omgitsjan@users.noreply.github.com>
Date: Fri, 19 Jan 2024 14:31:25 +0100
Subject: [PATCH] Refactor code and update dependencies
---
DiscordBot/Program.cs | 4 ++--
DiscordBot/Services/SlashCommandsService.cs | 2 +-
DiscordBot/SlashCommands.cs | 2 +-
.../ServiceTests/CryptoServiceTests.cs | 16 ++++++++--------
DiscordBotTests/ServiceTests/HttpServiceTests.cs | 4 ++--
.../ServiceTests/OpenAiServiceTests.cs | 4 ++--
.../ServiceTests/OpenWeatherMapServiceTests.cs | 4 ++--
.../ServiceTests/SlashCommandsServiceTests.cs | 14 +++++++-------
.../ServiceTests/Watch2GetherServiceTests.cs | 4 ++--
9 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs
index 1ddccd8..94d9975 100644
--- a/DiscordBot/Program.cs
+++ b/DiscordBot/Program.cs
@@ -23,7 +23,7 @@ public class Program
{
///
/// This is the Discord token from the bot
- ///
+ ///
private string? _discordToken;
///
@@ -46,7 +46,7 @@ public class Program
///
/// Init Program
///
- public static Task Main(string[] args)
+ public static Task Main()
{
return new Program().MainAsync();
}
diff --git a/DiscordBot/Services/SlashCommandsService.cs b/DiscordBot/Services/SlashCommandsService.cs
index 6d7b071..38f6f99 100644
--- a/DiscordBot/Services/SlashCommandsService.cs
+++ b/DiscordBot/Services/SlashCommandsService.cs
@@ -271,7 +271,7 @@ await ctx.CreateResponseAsync(InteractionResponseType.DeferredChannelMessageWith
Program.Log("Message: " + message);
if (success) {
- DiscordEmbedBuilder embedMessage = new DiscordEmbedBuilder
+ DiscordEmbedBuilder embedMessage = new()
{
Title = $"{symbol} - {physicalCurrency} | ${message}",
Description = $"Price of {symbol} - {physicalCurrency} is ${message}",
diff --git a/DiscordBot/SlashCommands.cs b/DiscordBot/SlashCommands.cs
index 0653983..5eb2829 100644
--- a/DiscordBot/SlashCommands.cs
+++ b/DiscordBot/SlashCommands.cs
@@ -61,7 +61,7 @@ public async Task CryptoSlashCommand(InteractionContext ctx,
[Option("PhysicalCurrency", "The physical currency to compare against, e.g., USDT")]
string physicalCurrency = "USDT")
{
- InteractionContextWrapper context = new InteractionContextWrapper(ctx);
+ InteractionContextWrapper context = new(ctx);
await slashCommandsService.CryptoSlashCommandAsync(context, symbol, physicalCurrency);
}
}
diff --git a/DiscordBotTests/ServiceTests/CryptoServiceTests.cs b/DiscordBotTests/ServiceTests/CryptoServiceTests.cs
index bbbdba6..c4eaa35 100644
--- a/DiscordBotTests/ServiceTests/CryptoServiceTests.cs
+++ b/DiscordBotTests/ServiceTests/CryptoServiceTests.cs
@@ -31,8 +31,8 @@ public void Setup()
public async Task GetCurrentCryptoPriceAsync_ReturnsCurrentPrice()
{
// Arrange
- string symbol = "BTC";
- string physicalCurrency = "USDT";
+ const string symbol = "BTC";
+ const string physicalCurrency = "USDT";
const string jsonResponse = "{\"result\": [{\"last_price\": \"50000\"}]}";
const string expectedPrice = "50000";
_mockHttpService.Setup(x => x.GetResponseFromUrl(It.IsAny(), It.IsAny(), It.IsAny(),
@@ -51,8 +51,8 @@ public async Task GetCurrentCryptoPriceAsync_ReturnsCurrentPrice()
public async Task GetCurrentCryptoPriceAsync_ApiError_ReturnsErrorMessage()
{
// Arrange
- string symbol = "BTC";
- string physicalCurrency = "USDT";
+ const string symbol = "BTC";
+ const string physicalCurrency = "USDT";
const string expectedErrorMessage = "API Error";
_mockHttpService.Setup(x => x.GetResponseFromUrl(It.IsAny(), It.IsAny(), It.IsAny(),
It.IsAny>>(), It.IsAny