Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion src/FischBot.UnitTests/FischBot.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/FischBot.UnitTests/Modules/InfoModuleTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using FischBot.Modules;
using FischBot.Services.DiscordModuleService;
using Microsoft.Extensions.Configuration;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using FischBot.Api.CalendarificHolidaysApiClient.Dtos;
Expand Down
2 changes: 0 additions & 2 deletions src/FischBot/Api/DeepAiApiClient/IDeepAiApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;
using System.IO;
using System.Threading.Tasks;
using FischBot.Api.DeepAiApiClient.Dtos;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
using System;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Discord;
using FischBot.Api.HalfStaffJsScraperClient.Dtos;
using FischBot.Api.NasaApiClient.Dtos;
using Microsoft.Extensions.Configuration;

namespace FischBot.Api.HalfStaffJsScraperClient
{
Expand Down
4 changes: 1 addition & 3 deletions src/FischBot/Api/OpenWeatherMapApiClient/Dtos/Clouds.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace FischBot.Api.OpenWeatherMapApiClient.Dtos
{
Expand Down
4 changes: 1 addition & 3 deletions src/FischBot/Api/OpenWeatherMapApiClient/Dtos/Coordinates.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace FischBot.Api.OpenWeatherMapApiClient.Dtos
{
Expand Down
4 changes: 1 addition & 3 deletions src/FischBot/Api/OpenWeatherMapApiClient/Dtos/Main.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace FischBot.Api.OpenWeatherMapApiClient.Dtos
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using System.Text.Json.Serialization;

namespace FischBot.Api.OpenWeatherMapApiClient.Dtos
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace FischBot.Api.OpenWeatherMapApiClient.Dtos
{
Expand Down
4 changes: 1 addition & 3 deletions src/FischBot/Api/OpenWeatherMapApiClient/Dtos/Sys.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace FischBot.Api.OpenWeatherMapApiClient.Dtos
{
Expand Down
4 changes: 1 addition & 3 deletions src/FischBot/Api/OpenWeatherMapApiClient/Dtos/Weather.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace FischBot.Api.OpenWeatherMapApiClient.Dtos
{
Expand Down
4 changes: 1 addition & 3 deletions src/FischBot/Api/OpenWeatherMapApiClient/Dtos/Wind.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace FischBot.Api.OpenWeatherMapApiClient.Dtos
{
Expand Down
28 changes: 14 additions & 14 deletions src/FischBot/FischBot.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AssemblyVersion>0.4.5</AssemblyVersion>
<Version>0.4-dragonfish-rev5</Version>
<Deterministic>false</Deterministic>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.NET" Version="3.7.2"/>
<PackageReference Include="HtmlAgilityPack" Version="1.11.43"/>
<PackageReference Include="ImageCharts" Version="6.1.201"/>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9"/>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1"/>
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0"/>
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0"/>
<PackageReference Include="ScrapySharp" Version="3.0.0"/>
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1"/>
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1"/>
<PackageReference Include="TwelveDataSharp" Version="1.1.0"/>
<PackageReference Include="Discord.NET" Version="3.7.2" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.43" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="ScottPlot" Version="5.0.55" />
<PackageReference Include="ScrapySharp" Version="3.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="TwelveDataSharp" Version="1.1.0" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion src/FischBot/Handlers/CommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Discord.Commands;
using Discord.WebSocket;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace FischBot.Handlers
Expand Down
19 changes: 11 additions & 8 deletions src/FischBot/Handlers/InteractionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ public class InteractionHandler
private readonly ILogger _logger;
private readonly IConfiguration _configuration;

public InteractionHandler(IConfiguration configuration, DiscordSocketClient discordClient, InteractionService commands, IServiceProvider services, ILogger<InteractionHandler> logger)
public InteractionHandler(IConfiguration configuration, DiscordSocketClient discordClient, InteractionService commands, IServiceProvider services, ILogger<InteractionHandler> logger)
{
_discordClient = discordClient;
_commands = commands;
_services = services;
_logger = logger;
_configuration = configuration;
}
public async Task InitializeAsync()

public async Task InitializeAsync()
{
await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services);

Expand All @@ -41,7 +41,7 @@ public async Task InitializeAsync()
_discordClient.Ready += async () =>
{
// If running the bot with DEBUG flag, register all commands to guild specified in config
if (IsDebug())
if (IsDebug())
{
var testGuildId = _configuration.GetValue<ulong>("FischBot:testGuildId");

Expand All @@ -51,7 +51,7 @@ public async Task InitializeAsync()

Console.WriteLine($"Registered the following interaction commands: {string.Join(',', registeredCommands.Select(command => command.Name))}");
}
else
else
{
await _services
.GetRequiredService<InteractionService>()
Expand All @@ -60,11 +60,11 @@ await _services
};
}

private async Task HandleInteraction(SocketInteraction interaction)
private async Task HandleInteraction(SocketInteraction interaction)
{
var context = new SocketInteractionContext(_discordClient, interaction);

try
try
{
await _commands.ExecuteCommandAsync(context, _services);
}
Expand Down Expand Up @@ -112,7 +112,10 @@ private async Task SlashCommandExecuted(SlashCommandInfo command, Discord.IInter
else
{
_logger.LogError($"Slash command failed to execute for [{context.User.Username}] <-> [{result}]!");
await context.Interaction.RespondAsync($"Sorry, {context.User.Username}... something went wrong -> [{result}]!", ephemeral: true);
if (context.Interaction.HasResponded)
await context.Interaction.RespondAsync($"Sorry, {context.User.Username}... something went wrong -> [{result}]!", ephemeral: true);
else
await context.Interaction.FollowupAsync($"Sorry, {context.User.Username}... something went wrong -> [{result}]!", ephemeral: true);
}
}

Expand Down
6 changes: 1 addition & 5 deletions src/FischBot/Models/Weather/CurrentWeather.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FischBot.Models.Weather
{
Expand All @@ -11,7 +7,7 @@ public class CurrentWeather
public string CityName { get; set; }
public string CountryCode { get; set; }
public string Location => $"{CityName}, {CountryCode}";
public string WeatherIconUrl { get; set; }
public string WeatherIconUrl { get; set; }
public string Weather { get; set; }
public string WeatherDescription { get; set; }
public DateTimeOffset DateCalculated { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/FischBot/Modules/CryptocurrencyModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public async Task DisplayRealtimeCryptoInfo([Summary(description: "Crypto symbol

.AddField(
"Price",
$"{price.ToString("C")} {(quote.Change > 0 ? "▲" : "▼")}{quote.Change.ToString("C")} ({quote.PercentChange.ToString("F2")}%)"
$"{price:C} {(quote.Change > 0 ? "▲" : "▼")}{quote.Change:C} ({quote.PercentChange:F2}%)"
)

.AddField("Trading info for last trading day", quote.Datetime.ToString("d"))

.AddField("Open/Close", $"{quote.Open.ToString("C")}/{quote.Close.ToString("C")}")
.AddField("High/Low", $"{quote.High.ToString("C")}/{quote.Low.ToString("C")}")
.AddField("Open/Close", $"{quote.Open:C}/{quote.Close:C}")
.AddField("High/Low", $"{quote.High:C}/{quote.Low:C}")

.WithFooter($"Source: twelvedata | Daily usage: {usageStats.daily_usage}/{usageStats.plan_daily_limit}")
.Build();
Expand Down
3 changes: 0 additions & 3 deletions src/FischBot/Modules/HalfMastModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Discord;
using Discord.Interactions;
Expand Down
6 changes: 2 additions & 4 deletions src/FischBot/Modules/InfoModule.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Discord;
using Discord.Interactions;
using FischBot.Services.DiscordModuleService;
using Microsoft.Extensions.Configuration;

namespace FischBot.Modules
{
Expand All @@ -16,14 +14,14 @@ public InfoModule(IDiscordModuleService moduleService) : base(moduleService)
}

[SlashCommand("say", "Echoes a message.")]
public async Task SayAsync([Summary(description: "The text to echo.")] string echo, [Summary(description: "Whether to show your identity. (optional)")]bool anonymous = false)
public async Task SayAsync([Summary(description: "The text to echo.")] string echo, [Summary(description: "Whether to show your identity. (optional)")] bool anonymous = false)
{
if (anonymous)
{
await ReplyAsync(echo);
await RespondAsync("_Shhh... I've said your super secret message._", ephemeral: true);
}
else
else
{
await RespondAsync(echo);
}
Expand Down
Loading