Skip to content

Commit f095a35

Browse files
committed
feat: Added info if the project is available or not
1 parent 1fb52fc commit f095a35

File tree

3 files changed

+4
-80
lines changed

3 files changed

+4
-80
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ bld/
4040
# Uncomment if you have tasks that create the project's static files in wwwroot
4141
#wwwroot/
4242

43+
.idea/
44+
4345
# Visual Studio 2017 auto generated files
4446
Generated\ Files/
4547

CFDiscordBot/Commands/FileLookup.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,35 +47,9 @@ int fileId
4747
}
4848

4949
var summaryText = new StringBuilder();
50-
var haveExtraLinebreak = false;
5150

5251
summaryText.AppendLine(mod.Summary);
5352

54-
if (mod.LatestFilesIndexes?.Count > 0)
55-
{
56-
var gameVersionList = new List<string>();
57-
var modloaderList = new List<string>();
58-
59-
var gameVersions = string.Join(", ", gameVersionList.Distinct().OrderBy(gvt => Regex.Replace(gvt, "\\d+", m => m.Value.PadLeft(10, '0'))));
60-
var modLoaders = string.Join(", ", modloaderList.Distinct().OrderBy(gvt => Regex.Replace(gvt, "\\d+", m => m.Value.PadLeft(10, '0'))));
61-
62-
if ((!string.IsNullOrWhiteSpace(gameVersions) || !string.IsNullOrWhiteSpace(modLoaders)) && !haveExtraLinebreak)
63-
{
64-
summaryText.AppendLine();
65-
haveExtraLinebreak = true;
66-
}
67-
68-
if (!string.IsNullOrWhiteSpace(gameVersions))
69-
{
70-
summaryText.AppendLine($"Game version(s): {gameVersions}");
71-
}
72-
73-
if (!string.IsNullOrWhiteSpace(modLoaders))
74-
{
75-
summaryText.AppendLine($"Modloader(s): {modLoaders}");
76-
}
77-
}
78-
7953
var projectEmbed = new EmbedBuilder
8054
{
8155
Title = "Project information",
@@ -102,6 +76,7 @@ int fileId
10276
new() { Name = "Released", Value = $"<t:{mod.DateReleased.ToUnixTimeSeconds()}:F>", IsInline = true },
10377
new() { Name = "Downloads", Value = mod.DownloadCount.ToString("n0"), IsInline = true },
10478
new() { Name = "Mod Distribution", Value = mod.AllowModDistribution ?? true ? "Allowed" : "Not allowed", IsInline = true },
79+
new() { Name = "Is available", Value = mod.IsAvailable ? "Yes" : "No", IsInline = true }
10580
};
10681

10782
if (!string.IsNullOrWhiteSpace(categories))

CFDiscordBot/Commands/ProjectLookup.cs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Discord;
22
using Discord.Interactions;
33
using System.Text;
4-
using System.Text.RegularExpressions;
54

65
namespace CFDiscordBot.Commands
76
{
@@ -33,63 +32,10 @@ int projectId
3332
return;
3433
}
3534

36-
//var modFiles = new List<CurseForge.APIClient.Models.Files.File>();
37-
38-
//var files = await apiClient.GetModFilesAsync(projectId, pageSize: 50);
39-
//modFiles.AddRange(files.Data);
40-
41-
//var index = files.Pagination.Index;
42-
//while (modFiles.Count < files.Pagination.TotalCount)
43-
//{
44-
// files = await apiClient.GetModFilesAsync(projectId, index: index++, pageSize: 50);
45-
// modFiles.AddRange(files.Data);
46-
//}
47-
4835
var summaryText = new StringBuilder();
49-
var haveExtraLinebreak = false;
5036

5137
summaryText.AppendLine(mod.Summary);
5238

53-
if (mod.LatestFilesIndexes?.Count > 0)
54-
{
55-
var gameVersionList = new List<string>();
56-
var modloaderList = new List<string>();
57-
58-
/*foreach (var modFile in modFiles)
59-
{
60-
if (modFile?.IsAvailable ?? true)
61-
{
62-
if (!string.IsNullOrWhiteSpace(file.GameVersion))
63-
{
64-
gameVersionList.Add(file.GameVersion);
65-
}
66-
if (!string.IsNullOrWhiteSpace(file.ModLoader?.ToString()))
67-
{
68-
modloaderList.Add(file.ModLoader.Value.ToString());
69-
}
70-
}
71-
}*/
72-
73-
var gameVersions = string.Join(", ", gameVersionList.Distinct().OrderBy(gvt => Regex.Replace(gvt, "\\d+", m => m.Value.PadLeft(10, '0'))));
74-
var modLoaders = string.Join(", ", modloaderList.Distinct().OrderBy(gvt => Regex.Replace(gvt, "\\d+", m => m.Value.PadLeft(10, '0'))));
75-
76-
if ((!string.IsNullOrWhiteSpace(gameVersions) || !string.IsNullOrWhiteSpace(modLoaders)) && !haveExtraLinebreak)
77-
{
78-
summaryText.AppendLine();
79-
haveExtraLinebreak = true;
80-
}
81-
82-
if (!string.IsNullOrWhiteSpace(gameVersions))
83-
{
84-
summaryText.AppendLine($"Game version(s): {gameVersions}");
85-
}
86-
87-
if (!string.IsNullOrWhiteSpace(modLoaders))
88-
{
89-
summaryText.AppendLine($"Modloader(s): {modLoaders}");
90-
}
91-
}
92-
9339
var projectEmbed = new EmbedBuilder
9440
{
9541
Title = "Project information",
@@ -116,6 +62,7 @@ int projectId
11662
new() { Name = "Released", Value = $"<t:{mod.DateReleased.ToUnixTimeSeconds()}:F>", IsInline = true },
11763
new() { Name = "Downloads", Value = mod.DownloadCount.ToString("n0"), IsInline = true },
11864
new() { Name = "Mod Distribution", Value = mod.AllowModDistribution ?? true ? "Allowed" : "Not allowed", IsInline = true },
65+
new() { Name = "Is available", Value = mod.IsAvailable ? "Yes" : "No", IsInline = true }
11966
};
12067

12168
if (!string.IsNullOrWhiteSpace(categories))

0 commit comments

Comments
 (0)