Skip to content

Commit

Permalink
Code Corrections
Browse files Browse the repository at this point in the history
- Removed the unused Steam app list.
- Minor tweaks to appease the ReSharper.
- Updated nuget packages.
  • Loading branch information
CriticalFlaw committed Jul 27, 2020
1 parent 4d379d0 commit f49286e
Show file tree
Hide file tree
Showing 36 changed files with 103 additions and 147 deletions.
12 changes: 6 additions & 6 deletions src/FlawBOT.Core/FlawBOT.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<ApplicationIcon>icon.ico</ApplicationIcon>
<StartupObject>FlawBOT.Program</StartupObject>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Version>2.6.0</Version>
<Version>2.6.1</Version>
<Win32Resource />
<LangVersion>7.2</LangVersion>
<AssemblyVersion>2.6.0.0</AssemblyVersion>
<FileVersion>2.6.0.0</FileVersion>
<AssemblyVersion>2.6.1.0</AssemblyVersion>
<FileVersion>2.6.1.0</FileVersion>
<AssemblyName>FlawBOT.Core</AssemblyName>
<RootNamespace>FlawBOT.Core</RootNamespace>
<PackageTags />
Expand Down Expand Up @@ -40,9 +40,9 @@
</ItemGroup>

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

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/FlawBOT.Core/Modules/Games/PokemonModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Mis
.AddField("HP", card.Hp ?? "Unknown", true)
.AddField("Ability", card.Ability != null ? card.Ability.Name : "Unknown", true)
.WithImageUrl(card.ImageUrlHiRes ?? card.ImageUrl)
.WithFooter(!card.Equals(results.Cards.Last())
.WithFooter(!string.Equals(card.Id, results.Cards.Last().Id)
? "Type 'next' within 10 seconds for the next Pokémon"
: "This is the last found Pokémon on the list.")
.WithColor(DiscordColor.Gold);
Expand All @@ -55,7 +55,7 @@ await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Mis
if (results.Cards.Count == 1) continue;
var interactivity = await BotServices.GetUserInteractivity(ctx, "next", 10).ConfigureAwait(false);
if (interactivity.Result is null) break;
if (!card.Equals(results.Cards.Last()))
if (!string.Equals(card.Id, results.Cards.Last().Id))
await BotServices.RemoveMessage(interactivity.Result).ConfigureAwait(false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/FlawBOT.Core/Modules/Games/SpeedrunModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Mis
.AddField("Publishers", SpeedrunService.GetSpeedrunExtraAsync(game.Publishers, SpeedrunExtras.Publishers).Result ?? "Unknown", true)
.AddField("Platforms", SpeedrunService.GetSpeedrunExtraAsync(game.Platforms, SpeedrunExtras.Platforms).Result ?? "Unknown")
.WithFooter($"ID: {game.Id} - Abbreviation: {game.Abbreviation}")
.WithThumbnailUrl(game.Assets.CoverLarge.Url ?? game.Assets.Icon.Url)
.WithThumbnail(game.Assets.CoverLarge.Url ?? game.Assets.Icon.Url)
.WithUrl(game.WebLink)
.WithColor(new DiscordColor("#0F7A4D"));

Expand Down
4 changes: 2 additions & 2 deletions src/FlawBOT.Core/Modules/Games/SteamModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Mis
.AddField("Publisher", app.Publishers[0] ?? "Unknown", true)
.AddField("Price", app.IsFree ? "Free" : app.PriceOverview.FinalFormatted ?? "Unknown", true)
.AddField("Metacritic", app.Metacritic != null ? app.Metacritic.Score.ToString() : "Unknown", true)
.WithThumbnailUrl(app.HeaderImage)
.WithThumbnail(app.HeaderImage)
.WithUrl("http://store.steampowered.com/app/" + app.SteamAppId)
.WithFooter("App ID: " + app.SteamAppId)
.WithColor(new DiscordColor("#1B2838"));
Expand Down Expand Up @@ -98,7 +98,7 @@ await BotServices.SendEmbedAsync(ctx, "This profile is private...", EmbedType.Wa
.WithTitle(summary.Data.Nickname)
.WithDescription(Regex.Replace(profile?.Summary ?? string.Empty, "<[^>]*>", "") ?? string.Empty)
.AddField("Member since", summary.Data.AccountCreatedDate.ToUniversalTime().ToString(CultureInfo.CurrentCulture), true)
.WithThumbnailUrl(profile?.AvatarFull.ToString() ?? profile.Avatar.ToString())
.WithThumbnail(profile?.AvatarFull.ToString() ?? profile.Avatar.ToString())
.WithColor(new DiscordColor("#1B2838"))
.WithUrl("http://steamcommunity.com/profiles/" + profile.SteamID)
.WithFooter("Steam ID: " + profile.SteamID);
Expand Down
4 changes: 2 additions & 2 deletions src/FlawBOT.Core/Modules/Games/TeamFortressModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public async Task Tf2Creators(CommandContext ctx,
[Description("Name of the community creator to find")] [RemainingText] string query)
{
if (!BotServices.CheckUserInput(query)) return;
var steamId = SteamService.GetSteamUserID(query).Result.Data;
var steamId = SteamService.GetSteamUserId(query).Result.Data;
var results = await TeamFortressService.GetCreatorByIdAsync(steamId).ConfigureAwait(false);
if (results is null)
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing)
Expand All @@ -167,7 +167,7 @@ await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Mis
var output = new DiscordEmbedBuilder()
.WithTitle(user?.Name)
.WithDescription("Main Class: " + user?.Main.ToString()?.ToUpper())
.WithThumbnailUrl(user?.ThumbnailUrl)
.WithThumbnail(user?.ThumbnailUrl)
.WithUrl(user?.Link)
.WithColor(new DiscordColor("#E7B53B"))
.WithFooter(!creator.Equals(results.Last())
Expand Down
2 changes: 1 addition & 1 deletion src/FlawBOT.Core/Modules/Misc/MiscModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_LOCATION, EmbedType.Wa
{
var output = new DiscordEmbedBuilder()
.AddField("Location", $"{results.City}, {results.Region}, {results.Country}")
.AddField("ISP", results.ISP)
.AddField("ISP", results.Isp)
.AddField("Coordinates", $"{results.Latitude}°N, {results.Longitude}°W")
.WithFooter($"IP: {results.Query}")
.WithColor(new DiscordColor("#4d2f63"));
Expand Down
2 changes: 1 addition & 1 deletion src/FlawBOT.Core/Modules/Search/GoogleModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public async Task Weather(CommandContext ctx,
{
if (!BotServices.CheckUserInput(query)) return;
var results = await GoogleService.GetWeatherDataAsync(query).ConfigureAwait(false);
if (results == null || results.COD == 404)
if (results == null || results.Cod == 404)
{
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_LOCATION, EmbedType.Missing)
.ConfigureAwait(false);
Expand Down
8 changes: 4 additions & 4 deletions src/FlawBOT.Core/Modules/Search/NASAModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
namespace FlawBOT.Modules
{
[Cooldown(3, 5, CooldownBucketType.Channel)]
public class NASAModule : BaseCommandModule
public class NasaModule : BaseCommandModule
{
#region COMMAND_NASA

[Command("nasa")]
[Aliases("apod", "space")]
[Description("Retrieve NASA's Astronomy Picture of the Day")]
public async Task NASA(CommandContext ctx)
public async Task Nasa(CommandContext ctx)
{
var results = await NASAService.GetNASAImageAsync().ConfigureAwait(false);
var results = await NasaService.GetNasaImageAsync().ConfigureAwait(false);
if (results is null)
{
await BotServices.SendEmbedAsync(ctx, Resources.ERR_NASA_API, EmbedType.Missing).ConfigureAwait(false);
Expand All @@ -27,7 +27,7 @@ public async Task NASA(CommandContext ctx)
{
var output = new DiscordEmbedBuilder()
.WithDescription(results.Title)
.WithImageUrl(results.ImageHD ?? results.ImageSD)
.WithImageUrl(results.ImageHd ?? results.ImageSd)
.WithFooter(results.Description)
.WithColor(new DiscordColor("#0B3D91"));
await ctx.RespondAsync(embed: output.Build()).ConfigureAwait(false);
Expand Down
6 changes: 3 additions & 3 deletions src/FlawBOT.Core/Modules/Search/OMDBModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
namespace FlawBOT.Modules
{
[Cooldown(3, 5, CooldownBucketType.Channel)]
public class OMDBModule : BaseCommandModule
public class OmdbModule : BaseCommandModule
{
#region COMMAND_OMDB

[Command("omdb")]
[Aliases("imdb", "movie")]
[Description("Retrieve a movie or TV show from OMDB")]
public async Task OMDB(CommandContext ctx,
public async Task Omdb(CommandContext ctx,
[Description("Movie or TV show to find on OMDB")] [RemainingText] string query)
{
if (!BotServices.CheckUserInput(query)) return;
var results = OMDBService.GetMovieDataAsync(query.Replace(" ", "+")).Result;
var results = OmdbService.GetMovieDataAsync(query.Replace(" ", "+")).Result;
if (results.Response == "False")
{
await BotServices.SendEmbedAsync(ctx, Resources.NOT_FOUND_GENERIC, EmbedType.Missing)
Expand Down
9 changes: 3 additions & 6 deletions src/FlawBOT.Core/Modules/Server/BotModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,10 @@ public async Task Say(CommandContext ctx,
[Aliases("talk")]
[Description("Make FlawBOT repeat a message in text-to-speech")]
[RequirePermissions(Permissions.SendTtsMessages)]
public Task SayTTS(CommandContext ctx,
public Task SayTts(CommandContext ctx,
[Description("Message for the bot to convert to speech")] [RemainingText] string text)
{
if (string.IsNullOrWhiteSpace(text))
return ctx.RespondAsync("I need something to say...");
return ctx.RespondAsync(Formatter.BlockCode(Formatter.Strip(text)), true);
return string.IsNullOrWhiteSpace(text) ? ctx.RespondAsync("I need something to say...") : ctx.RespondAsync(Formatter.BlockCode(Formatter.Strip(text)), true);
}

#endregion COMMAND_TTS
Expand Down Expand Up @@ -179,7 +177,7 @@ await BotServices.SendEmbedAsync(ctx,
[Command("activity")]
[Hidden]
[Aliases("setactivity")]
[Description("Set FlawBOT activity")]
[Description("Set FlawBOT's activity")]
public async Task SetBotActivity(CommandContext ctx,
[Description("Name of the activity")] [RemainingText] string activity)
{
Expand Down Expand Up @@ -281,7 +279,6 @@ await BotServices.SendEmbedAsync(ctx, SharedData.Name + " status has been change
public async Task Update(CommandContext ctx)
{
var message = await ctx.RespondAsync("Starting update...").ConfigureAwait(false);
await SteamService.UpdateSteamListAsync().ConfigureAwait(false);
await TeamFortressService.UpdateTf2SchemaAsync().ConfigureAwait(false);
await PokemonService.UpdatePokemonListAsync().ConfigureAwait(false);
await message.ModifyAsync("Starting update...done!").ConfigureAwait(false);
Expand Down
6 changes: 3 additions & 3 deletions src/FlawBOT.Core/Modules/Server/ChannelModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Task GetChannel(CommandContext ctx,
.AddField("Type", channel.Type.ToString(), true)
.AddField("Private", channel.IsPrivate ? "Yes" : "No", true)
.AddField("NSFW", channel.IsNSFW ? "Yes" : "No", true)
.WithThumbnailUrl(ctx.Guild.IconUrl)
.WithThumbnail(ctx.Guild.IconUrl)
.WithFooter("Created on " + channel.CreationTimestamp.DateTime.ToString(CultureInfo.InvariantCulture))
.WithColor(SharedData.DefaultColor);

Expand Down Expand Up @@ -201,7 +201,7 @@ public async Task CreateTextChannel(CommandContext ctx,
await BotServices.SendEmbedAsync(ctx, Resources.ERR_CHANNEL_NAME, EmbedType.Warning)
.ConfigureAwait(false);
}
else if (ctx.Guild.Channels.Any(chn => String.Compare(name, chn.Value.Name, StringComparison.OrdinalIgnoreCase) == 0))
else if (ctx.Guild.Channels.Any(chn => string.Compare(name, chn.Value.Name, StringComparison.OrdinalIgnoreCase) == 0))
{
await BotServices.SendEmbedAsync(ctx, Resources.ERR_CHANNEL_EXISTS, EmbedType.Warning)
.ConfigureAwait(false);
Expand Down Expand Up @@ -258,7 +258,7 @@ public async Task CreateVoiceChannel(CommandContext ctx,
await BotServices.SendEmbedAsync(ctx, Resources.ERR_CHANNEL_NAME, EmbedType.Warning)
.ConfigureAwait(false);
}
else if (ctx.Guild.Channels.Any(chn => String.Compare(name, chn.Value.Name, StringComparison.OrdinalIgnoreCase) == 0))
else if (ctx.Guild.Channels.Any(chn => string.Compare(name, chn.Value.Name, StringComparison.OrdinalIgnoreCase) == 0))
{
await BotServices.SendEmbedAsync(ctx, Resources.ERR_CHANNEL_EXISTS, EmbedType.Warning)
.ConfigureAwait(false);
Expand Down
6 changes: 3 additions & 3 deletions src/FlawBOT.Core/Modules/Server/EmojiModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public async Task GetEmoji(CommandContext ctx,
.AddField("Creation Date", emoji.CreationTimestamp.ToString(), true)
.WithColor(DiscordColor.PhthaloBlue)
.WithUrl(emoji.Url)
.WithThumbnailUrl(emoji.Url);
.WithThumbnail(emoji.Url);
await ctx.RespondAsync(embed: output.Build()).ConfigureAwait(false);
}

Expand All @@ -157,12 +157,12 @@ public async Task GetEmojiList(CommandContext ctx)
{
var emojiList = new StringBuilder();
foreach (var emoji in ctx.Guild.Emojis.Values.OrderBy(e => e.Name))
emojiList.Append(emoji.Name).Append(!emoji.Equals(ctx.Guild.Emojis.Last()) ? ", " : string.Empty);
emojiList.Append(emoji.Name).Append(!emoji.Equals(ctx.Guild.Emojis.Last().Value) ? ", " : string.Empty);

var output = new DiscordEmbedBuilder()
.WithTitle("Emojis available for " + ctx.Guild.Name)
.WithDescription(emojiList.ToString())
.WithThumbnailUrl(ctx.Guild.IconUrl)
.WithThumbnail(ctx.Guild.IconUrl)
.WithColor(DiscordColor.PhthaloBlue);
await ctx.RespondAsync(embed: output.Build()).ConfigureAwait(false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/FlawBOT.Core/Modules/Server/RoleModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ await BotServices.SendEmbedAsync(ctx, Resources.ERR_ROLE_EXISTING, EmbedType.War
.AddField("Hoisted", role.IsHoisted ? "Yes" : "No", true)
.AddField("Mentionable", role.IsMentionable ? "Yes" : "No", true)
.AddField("Permissions", role.Permissions.ToPermissionString())
.WithThumbnailUrl(ctx.Guild.IconUrl)
.WithThumbnail(ctx.Guild.IconUrl)
.WithFooter($"{ctx.Guild.Name} / #{ctx.Channel.Name} / {DateTime.Now}")
.WithColor(role.Color);
await ctx.RespondAsync(embed: output.Build()).ConfigureAwait(false);
Expand Down
4 changes: 2 additions & 2 deletions src/FlawBOT.Core/Modules/Server/ServerModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public async Task GetServer(CommandContext ctx)
.WithFooter(ctx.Guild.Name + " / #" + ctx.Channel.Name + " / " + DateTime.Now)
.WithColor(DiscordColor.Rose);
if (!string.IsNullOrEmpty(ctx.Guild.IconHash))
output.WithThumbnailUrl(ctx.Guild.IconUrl);
output.WithThumbnail(ctx.Guild.IconUrl);

var roles = new StringBuilder();
foreach (var role in ctx.Guild.Roles)
Expand Down Expand Up @@ -163,7 +163,7 @@ public async Task Warn(CommandContext ctx,
.WithDescription(Formatter.Bold(ctx.Guild.Name) + " has issued you a server warning!")
.AddField("Sender:", ctx.Member.Username + "#" + ctx.Member.Discriminator, true)
.AddField("Server Owner:", ctx.Guild.Owner.Username + "#" + ctx.Guild.Owner.Discriminator, true)
.WithThumbnailUrl(ctx.Guild.IconUrl)
.WithThumbnail(ctx.Guild.IconUrl)
.WithTimestamp(DateTime.Now)
.WithColor(DiscordColor.Red);
if (!string.IsNullOrWhiteSpace(reason)) output.AddField("Warning message:", reason);
Expand Down
2 changes: 1 addition & 1 deletion src/FlawBOT.Core/Modules/Server/UserModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async Task GetUser(CommandContext ctx,
.AddField("Nickname", member.Nickname ?? "None", true)
.AddField("Muted?", member.IsMuted ? "Yes" : "No", true)
.AddField("Deafened?", member.IsDeafened ? "Yes" : "No", true)
.WithThumbnailUrl(member.AvatarUrl)
.WithThumbnail(member.AvatarUrl)
.WithFooter($"{ctx.Guild.Name} / #{ctx.Channel.Name} / {DateTime.Now}")
.WithColor(member.Color);
if (member.IsBot)
Expand Down
5 changes: 2 additions & 3 deletions src/FlawBOT.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public async Task RunBotAsync()
Commands.RegisterCommands<ImgurModule>();
Commands.RegisterCommands<MathModule>();
Commands.RegisterCommands<MiscModule>();
Commands.RegisterCommands<NASAModule>();
Commands.RegisterCommands<OMDBModule>();
Commands.RegisterCommands<NasaModule>();
Commands.RegisterCommands<OmdbModule>();
Commands.RegisterCommands<PokemonModule>();
Commands.RegisterCommands<PollModule>();
Commands.RegisterCommands<RedditModule>();
Expand All @@ -107,7 +107,6 @@ public async Task RunBotAsync()
// Start the uptime counter
Console.Title = SharedData.Name + " - " + SharedData.Version;
SharedData.ProcessStarted = DateTime.Now;
await SteamService.UpdateSteamListAsync().ConfigureAwait(false);
await TeamFortressService.UpdateTf2SchemaAsync().ConfigureAwait(false);
await PokemonService.UpdatePokemonListAsync().ConfigureAwait(false);
await Client.ConnectAsync().ConfigureAwait(false); // Connect and log into Discord
Expand Down
18 changes: 9 additions & 9 deletions src/FlawBOT.Framework/FlawBOT.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyVersion>2.7.0.0</AssemblyVersion>
<Version>2.6.0</Version>
<FileVersion>2.6.0.0</FileVersion>
<AssemblyVersion>2.6.1.0</AssemblyVersion>
<Version>2.6.1</Version>
<FileVersion>2.6.1.0</FileVersion>
<Authors>Igor Nikitin</Authors>
<Company>CriticalFlaw</Company>
<Product>FlawBOT</Product>
Expand All @@ -15,16 +15,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00697" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00697" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00697" />
<PackageReference Include="Google.Apis.Books.v1" Version="1.45.0.1954" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.45.0.1929" />
<PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00709" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00709" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00709" />
<PackageReference Include="Google.Apis.Books.v1" Version="1.48.0.2024" />
<PackageReference Include="Google.Apis.YouTube.v3" Version="1.47.0.2008" />
<PackageReference Include="Imgur.API" Version="4.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="OMDbSharp" Version="0.3.0" />
<PackageReference Include="PokemonTcgSdk" Version="1.1.0" />
<PackageReference Include="SteamWebAPI2" Version="4.2.3" />
<PackageReference Include="SteamWebAPI2" Version="4.2.5" />
<PackageReference Include="System.ServiceModel.Syndication" Version="4.7.0" />
<PackageReference Include="TeamworkTF.Sharp" Version="1.1.2" />
<PackageReference Include="TwitchLib.Api" Version="3.1.3" />
Expand Down
2 changes: 1 addition & 1 deletion src/FlawBOT.Framework/Models/Misc/MiscData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class IpLocationData
public string CountryCode { get; set; }

[JsonProperty("isp")]
public string ISP { get; set; }
public string Isp { get; set; }

[JsonProperty("lat")]
public double Latitude { get; set; }
Expand Down
Loading

0 comments on commit f49286e

Please sign in to comment.