Skip to content

Commit

Permalink
Migrated to NET Core 3.0
Browse files Browse the repository at this point in the history
- Migrated the project from NET Core 2.2 to 3.0
- Bumped the FlawBOT version number to 2.4
- Updated the output of the .tf2 server command.
- Updated the news command to use pagination.
- Updated the resources file to include emoji command strings.
- Updated the Twitch API URL from kraken (v3) to helix (v5)
- Fixed the amiibo not returning an output if only one result was found.
  • Loading branch information
CriticalFlaw committed Oct 21, 2019
1 parent eb0e5ee commit 5072cf9
Show file tree
Hide file tree
Showing 66 changed files with 359 additions and 299 deletions.
8 changes: 4 additions & 4 deletions src/FlawBOT.Core/Common/HelpFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DSharpPlus;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Converters;
using DSharpPlus.CommandsNext.Entities;
using DSharpPlus.Entities;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FlawBOT.Common
{
Expand Down
4 changes: 2 additions & 2 deletions src/FlawBOT.Core/Common/SharedData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using DSharpPlus.Entities;
using System;
using System.Reflection;
using DSharpPlus.Entities;

namespace FlawBOT.Common
{
Expand Down
14 changes: 7 additions & 7 deletions src/FlawBOT.Core/FlawBOT.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<ApplicationIcon>icon.ico</ApplicationIcon>
<StartupObject>FlawBOT.Program</StartupObject>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.3.1</Version>
<Version>2.4.0</Version>
<Win32Resource />
<LangVersion>7.2</LangVersion>
<AssemblyVersion>2.3.1.0</AssemblyVersion>
<FileVersion>2.3.1.0</FileVersion>
<AssemblyVersion>2.4.0.0</AssemblyVersion>
<FileVersion>2.4.0.0</FileVersion>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<AssemblyName>FlawBOT.Core</AssemblyName>
<RootNamespace>FlawBOT.Core</RootNamespace>
Expand Down Expand Up @@ -41,9 +41,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00624" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00624" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00624" />
<PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00625" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00625" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00625" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/FlawBOT.Core/Modules/Bot/BotModule.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
Expand All @@ -9,6 +7,8 @@
using FlawBOT.Core.Properties;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using System;
using System.Threading.Tasks;

namespace FlawBOT.Modules
{
Expand Down Expand Up @@ -47,7 +47,7 @@ public async Task LeaveAsync(CommandContext ctx)
{
await BotServices.SendEmbedAsync(ctx, $"Are you sure you want {SharedData.Name} to leave this server?\nRespond with **yes** to proceed or wait 10 seconds to cancel this operation.");
var interactivity = await ctx.Client.GetInteractivity().WaitForMessageAsync(m => m.Channel.Id == ctx.Channel.Id && m.Author.Id == ctx.User.Id && m.Content.ToLowerInvariant() == "yes", TimeSpan.FromSeconds(10));
if (interactivity.Result == null)
if (interactivity.Result is null)
await BotServices.SendEmbedAsync(ctx, Resources.REQUEST_TIMEOUT);
else
{
Expand Down Expand Up @@ -84,7 +84,7 @@ public async Task ReportIssue(CommandContext ctx,
{
await BotServices.SendEmbedAsync(ctx, "The following information will be sent to the developer for investigation: User ID, Server ID, Server Name and Server Owner Name.\nRespond with **yes** in the next 10 seconds to proceed, otherwise the operation will be canceled.");
var interactivity = await ctx.Client.GetInteractivity().WaitForMessageAsync(m => m.Channel.Id == ctx.Channel.Id && m.Author.Id == ctx.User.Id && m.Content.ToLowerInvariant() == "yes", TimeSpan.FromSeconds(10));
if (interactivity.Result == null)
if (interactivity.Result is null)
await BotServices.SendEmbedAsync(ctx, Resources.REQUEST_TIMEOUT);
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/FlawBOT.Core/Modules/Bot/OwnerModule.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using FlawBOT.Common;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using System.Threading.Tasks;

namespace FlawBOT.Modules
{
Expand Down
10 changes: 5 additions & 5 deletions src/FlawBOT.Core/Modules/Games/PokemonModule.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using FlawBOT.Core.Properties;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using System;
using System.Text;
using System.Threading.Tasks;

namespace FlawBOT.Modules
{
Expand Down Expand Up @@ -48,7 +48,7 @@ public async Task Pokemon(CommandContext ctx,
await ctx.RespondAsync(embed: output.Build());

var interactivity = await ctx.Client.GetInteractivity().WaitForMessageAsync(m => m.Channel.Id == ctx.Channel.Id && m.Content.ToLowerInvariant() == "next", TimeSpan.FromSeconds(10));
if (interactivity.Result == null) break;
if (interactivity.Result is null) break;
await BotServices.RemoveMessage(interactivity.Result);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/FlawBOT.Core/Modules/Games/SmashModule.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using FlawBOT.Core.Properties;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace FlawBOT.Modules
{
Expand All @@ -23,7 +23,7 @@ public async Task GetCharacter(CommandContext ctx,
{
if (!BotServices.CheckUserInput(query)) return;
var results = await SmashService.GetSmashCharacterAsync(query);
if (results == null)
if (results is null)
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_SMASH, EmbedType.Missing);
else
{
Expand Down
10 changes: 5 additions & 5 deletions src/FlawBOT.Core/Modules/Games/SpeedrunModule.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using FlawBOT.Core.Properties;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using System.Linq;
using System.Threading.Tasks;

namespace FlawBOT.Modules
{
Expand All @@ -21,7 +21,7 @@ public async Task Speedrun(CommandContext ctx,
{
if (!BotServices.CheckUserInput(query)) return;
var results = SpeedrunService.GetSpeedrunGameAsync(query).Result.Data.FirstOrDefault();
if (results == null)
if (results is null)
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing);
else
{
Expand All @@ -34,7 +34,7 @@ public async Task Speedrun(CommandContext ctx,
.AddField("Genres", (results.Genres.Count > 0) ? SpeedrunService.GetSpeedrunExtraAsync(results.Genres.Take(3).ToList(), SpeedrunExtras.Genres).Result : "Unknown", true)
.AddField("Platforms", (results.Platforms.Count > 0) ? SpeedrunService.GetSpeedrunExtraAsync(results.Platforms.Take(3).ToList(), SpeedrunExtras.Platforms).Result : "Unknown", true)
.WithFooter($"ID: {results.ID} - Abbreviation: {results.Abbreviation}")
.WithThumbnailUrl(results.Assets.CoverLarge.URL ?? results.Assets.Icon.URL)
.WithImageUrl(results.Assets.CoverLarge.URL ?? results.Assets.Icon.URL)
.WithUrl(results.WebLink)
.WithColor(new DiscordColor("#0F7A4D"));
await ctx.RespondAsync(embed: output.Build());
Expand Down
10 changes: 5 additions & 5 deletions src/FlawBOT.Core/Modules/Games/SteamModule.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Globalization;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using FlawBOT.Core.Properties;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using Steam.Models.SteamCommunity;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using UserStatus = Steam.Models.SteamCommunity.UserStatus;

namespace FlawBOT.Modules
Expand Down Expand Up @@ -61,7 +61,7 @@ public async Task SteamUser(CommandContext ctx,
if (!BotServices.CheckUserInput(query)) return;
var profile = SteamService.GetSteamUserProfileAsync(query).Result;
var summary = SteamService.GetSteamUserSummaryAsync(query).Result;
if (profile == null && summary == null)
if (profile is null && summary is null)
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing);
else
{
Expand Down
40 changes: 19 additions & 21 deletions src/FlawBOT.Core/Modules/Games/TeamFortressModule.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using FlawBOT.Core.Properties;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using System;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace FlawBOT.Modules
{
Expand All @@ -28,7 +28,7 @@ public async Task TF2Item(CommandContext ctx,
[Description("Item to find in the TF2 schema")] [RemainingText] string query = "The Scattergun")
{
var item = TeamFortressService.GetSchemaItemAsync(query);
if (item == null)
if (item is null)
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing);
else
{
Expand Down Expand Up @@ -65,7 +65,7 @@ public async Task TF2Map(CommandContext ctx,
{
if (!BotServices.CheckUserInput(query)) return;
var results = await TeamFortressService.GetMapStatsAsync(query.ToLowerInvariant());
if (results.MapName == null)
if (results.MapName is null)
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing);
else
{
Expand Down Expand Up @@ -102,25 +102,25 @@ public async Task TF2Map(CommandContext ctx,
public async Task TF2News(CommandContext ctx)
{
var results = await TeamFortressService.GetNewsOverviewAsync();
if (results == null || results.Count == 0)
if (results is null || results.Count == 0)
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing);
else
{
while (results.Count > 0)
{
var output = new DiscordEmbedBuilder()
.WithFooter("These are the latest news articles retrieved from teamwork.tf\nType next in the next 10 seconds for more news articles.")
.WithFooter("Type next in the next 10 seconds for more news articles.")
.WithColor(new DiscordColor("#E7B53B"));

foreach (var result in results.Take(5))
{
output.AddField(result.Title, result.Link);
results.Remove(result);
}
var message = await ctx.RespondAsync(embed: output.Build());
var message = await ctx.RespondAsync("Latest news articles from teamwork.tf", embed: output.Build());

var interactivity = await ctx.Client.GetInteractivity().WaitForMessageAsync(m => m.Channel.Id == ctx.Channel.Id && m.Content.ToLowerInvariant() == "next", TimeSpan.FromSeconds(10));
if (interactivity.Result == null) break;
if (interactivity.Result is null) break;
await BotServices.RemoveMessage(interactivity.Result);
await BotServices.RemoveMessage(message);
}
Expand Down Expand Up @@ -151,23 +151,21 @@ public async Task TF2Servers(CommandContext ctx,
var output = new DiscordEmbedBuilder()
.WithTitle(server.Name)
.WithDescription("steam://connect/" + server.IP + ":" + server.Port)
.AddField("Secure", server.ValveSecure ? "YES" : "NO", true)
//.AddField("Password", server.has_password ? "YES" : "NO", true)
.AddField("Provider", server.Provider ?? "Unknown", true)
.AddField("Max Players", (server.PlayerCount.ToString() ?? "Unknown") + "/" + (server.PlayerMax.ToString() ?? "Unknown"), true)
.AddField("Current Map", server.MapName ?? "Unknown", true)
.AddField("Next Map", server.NextMap ?? "Unknown", true)
.AddField("Provider", server.Provider ?? "Unknown", true)
.AddField("Roll the Dice>", server.HasRTD ? "Yes" : "No", true)
.AddField("Random Crits", server.HasRandomCrits == true ? "Yes" : "No", true)
.AddField("Respawn Timer", server.HasNoSpawnTimer ? "Yes" : "No", true)
.AddField("All Talk", server.HasAllTalk ? "Yes" : "No", true)
.AddField("Passworded?", (server.HasPassword == true) ? "Yes" : "No", true)
.AddField("Roll the Dice?", server.HasRTD ? "Yes" : "No", true)
.AddField("Random Crits?", server.HasRandomCrits == true ? "Yes" : "No", true)
.AddField("All Talk?", server.HasAllTalk ? "Yes" : "No", true)
.WithImageUrl("https://teamwork.tf" + server.MapThumbnail)
.WithFooter("Type 'next' within 10 seconds for the next server")
.WithColor(new DiscordColor("#E7B53B"));
var message = await ctx.RespondAsync(embed: output.Build());

var interactivity = await ctx.Client.GetInteractivity().WaitForMessageAsync(m => m.Channel.Id == ctx.Channel.Id && m.Content.ToLowerInvariant() == "next", TimeSpan.FromSeconds(10));
if (interactivity.Result == null) break;
if (interactivity.Result is null) break;
await BotServices.RemoveMessage(interactivity.Result);
await BotServices.RemoveMessage(message);
}
Expand Down
6 changes: 3 additions & 3 deletions src/FlawBOT.Core/Modules/Misc/MathModule.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using FlawBOT.Core.Properties;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using System.Linq;
using System.Threading.Tasks;

namespace FlawBOT.Modules
{
Expand Down
12 changes: 6 additions & 6 deletions src/FlawBOT.Core/Modules/Misc/MiscModule.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
Expand All @@ -11,6 +7,10 @@
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using Newtonsoft.Json.Linq;
using System;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace FlawBOT.Modules
{
Expand Down Expand Up @@ -156,7 +156,7 @@ public async Task DogPic(CommandContext ctx)
public async Task Greet(CommandContext ctx,
[Description("User to say hello to")] [RemainingText] DiscordMember member)
{
if (member == null)
if (member is null)
await ctx.RespondAsync($":wave: Hello, " + ctx.User.Mention);
else
await ctx.RespondAsync($":wave: Welcome " + member.Mention + " to " + ctx.Guild.Name + ". Enjoy your stay!");
Expand Down
10 changes: 5 additions & 5 deletions src/FlawBOT.Core/Modules/Misc/PollModule.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using DSharpPlus.Interactivity;
using FlawBOT.Core.Properties;
using FlawBOT.Framework.Models;
using FlawBOT.Framework.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace FlawBOT.Modules
{
Expand Down
Loading

0 comments on commit 5072cf9

Please sign in to comment.