Skip to content

Commit a534af9

Browse files
committed
Fixed Everything My bad
1 parent 9c934f9 commit a534af9

File tree

10 files changed

+61
-65
lines changed

10 files changed

+61
-65
lines changed

.vs/ScriptBloxAPI/v17/.suo

195 KB
Binary file not shown.

Backend Functions/MiscFunctions.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Globalization;
4-
using System.Linq;
53
using System.Net.Http;
6-
using System.Text;
7-
using System.Threading.Tasks;
84

95
namespace ScriptBloxAPI
106
{
117
internal class MiscFunctions
128
{
139
internal static HttpClient HttpClient = new HttpClient();
14-
15-
internal static DateTime ConvertStringToDateTime(string dateString)
10+
internal static DateTime ConvertStringToDateTime(string dateString, string timeFormat = "MM/dd/yyyy hh:mm:ss")
1611
{
17-
string format = "yyyy-MM-dd'T'HH:mm:ss.fff'Z'";
18-
DateTime result = DateTime.ParseExact(dateString, format, CultureInfo.InvariantCulture);
12+
DateTime result = DateTime.ParseExact(dateString, timeFormat, CultureInfo.InvariantCulture);
1913
result = result.ToLocalTime();
2014
return result;
2115
}

DataTypes/GameObject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
{
33
public class GameObject
44
{
5-
private int _gameId = 0;
5+
private long _gameId = 0;
66
private string _gameName = string.Empty;
77
private string _gameThumbnail = string.Empty;
88
private string _gameUrl = string.Empty;
99

1010
/// <summary>
1111
/// Gets the place ID.
1212
/// </summary>
13-
public int PlaceId { get { return _gameId; } }
13+
public long PlaceId { get { return _gameId; } }
1414

1515
/// <summary>
1616
/// Gets the game name.
@@ -28,7 +28,7 @@ public class GameObject
2828
public string Url { get { return _gameUrl; } }
2929

3030

31-
public GameObject(int gameId, string gameName, string gameThumbnail)
31+
public GameObject(long gameId, string gameName, string gameThumbnail)
3232
{
3333
_gameId = gameId;
3434
_gameName = gameName;

DataTypes/ScriptObject.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ScriptBloxAPI.DataTypes
55
{
6-
public class Script
6+
public class ScriptObject
77
{
88
private GameObject game;
99

@@ -12,9 +12,9 @@ public class Script
1212
private string _scriptBloxId = string.Empty;
1313
private string _executingScript = string.Empty;
1414

15-
private int _scriptViews = 0;
16-
private int _scriptLikes = 0;
17-
private int _scriptDislikes = 0;
15+
private long _scriptViews = 0;
16+
private long _scriptLikes = 0;
17+
private long _scriptDislikes = 0;
1818

1919
private bool _isUniversal = false;
2020
private bool _isPatched = false;
@@ -59,17 +59,17 @@ public class Script
5959
/// <summary>
6060
/// Gets the number of views on the script.
6161
/// </summary>
62-
public int Views => _scriptViews;
62+
public long Views => _scriptViews;
6363

6464
/// <summary>
6565
/// Gets the number of likes on the script.
6666
/// </summary>
67-
public int Likes => _scriptLikes;
67+
public long Likes => _scriptLikes;
6868

6969
/// <summary>
7070
/// Gets the number of dislikes on the script.
7171
/// </summary>
72-
public int Dislikes => _scriptDislikes;
72+
public long Dislikes => _scriptDislikes;
7373

7474
/// <summary>
7575
/// Gets a value indicating whether the script is universal.
@@ -102,7 +102,7 @@ public class Script
102102
public DateTime UpdatedAt => _updatedAt;
103103

104104

105-
public Script(GameObject game, string scriptTitle, string scriptId, string scriptBloxId, string ExecutingScript, string epocUpdated, string epocCreated, int scriptViews, int scriptLikes, int scriptDislikes, bool isUniversal, bool isPatched, bool requireskey, bool isverified, List<string> scriptTags)
105+
public ScriptObject(GameObject game, string scriptTitle, string scriptId, string scriptBloxId, string ExecutingScript, string epocUpdated, string epocCreated, long scriptViews, long scriptLikes, long scriptDislikes, bool isUniversal, bool isPatched, bool requireskey, bool isverified, List<string> scriptTags)
106106
{
107107
this.game = game;
108108
_scriptTitle = scriptTitle;
@@ -118,6 +118,8 @@ public Script(GameObject game, string scriptTitle, string scriptId, string scrip
118118
_isVerified = isverified;
119119
_requiresKey = requireskey;
120120

121+
Console.WriteLine(epocUpdated);
122+
121123
_updatedAt = MiscFunctions.ConvertStringToDateTime(epocUpdated);
122124
_createdAt = MiscFunctions.ConvertStringToDateTime(epocCreated);
123125
}

Methods/Scripts.cs

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,21 @@
44

55
namespace ScriptBloxAPI.Methods
66
{
7-
public class Scripts
7+
public class ScriptsMethods
88
{
9-
private static Script _invalidScript = new Script(new GameObject(0, "", ""), "N/A", "N/A", "N/A", "N/A", "2023-05-22T10:36:23.273Z", "2023-05-22T10:36:23.273Z", -1, -1, -1, false, false, false, false, new List<string>());
10-
119
/// <summary>
1210
/// Retrieves a script from Scriptblox based on the provided Scriptblox ID.
1311
/// </summary>
1412
/// <param name="bloxId">The Scriptblox ID of the script to retrieve.</param>
1513
/// <returns>The script retrieved from the API, or a default script if the retrieval fails or the data is invalid.</returns>
16-
public static Script GetScriptFromScriptbloxId(string bloxId)
14+
public static ScriptObject GetScriptFromScriptbloxId(string bloxId)
1715
{
18-
dynamic jsonReturn = MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/api/script/{bloxId}").Result;
16+
JToken jsonReturn = JToken.Parse(MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/api/script/{bloxId}").Result);
1917

2018
if (jsonReturn == null)
2119
throw new ScriptBloxException("An error has occured while fetching the json, please submit a bug report.");
2220
if (jsonReturn["message"] != null)
23-
throw new ScriptBloxException(jsonReturn["message"]);
21+
throw new ScriptBloxException(jsonReturn.Value<string>("message"));
2422
if (jsonReturn["script"] == null)
2523
throw new ScriptBloxException("Backend error occured.");
2624

@@ -37,18 +35,18 @@ public static Script GetScriptFromScriptbloxId(string bloxId)
3735
/// </summary>
3836
/// <param name="pageNumber">The page number of the front page scripts (default is 1).</param>
3937
/// <returns>A list of Script objects representing the scripts from the front page.</returns>
40-
public static List<Script> GetFrontPageScripts(int pageNumber = 1)
38+
public static List<ScriptObject> GetFrontPageScripts(int pageNumber = 1)
4139
{
4240
if (pageNumber < 1) pageNumber = 1;
4341

44-
List<Script> scriptsToReturn = new List<Script>();
42+
List<ScriptObject> scriptsToReturn = new List<ScriptObject>();
4543

46-
dynamic jsonReturn = MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/api/script/fetch?page={pageNumber}").Result;
44+
JToken jsonReturn = JToken.Parse(MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/api/script/fetch?page={pageNumber}").Result);
4745

4846
if (jsonReturn == null)
4947
throw new ScriptBloxException("An error has occured while fetching the json, please submit a bug report.");
5048
if (jsonReturn["message"] != null)
51-
throw new ScriptBloxException(jsonReturn["message"]);
49+
throw new ScriptBloxException(jsonReturn.Value<string>("message"));
5250
if (jsonReturn["script"] == null)
5351
throw new ScriptBloxException("Backend error occured.");
5452

@@ -64,26 +62,26 @@ public static List<Script> GetFrontPageScripts(int pageNumber = 1)
6462
/// </summary>
6563
/// <param name="pageNumber">The page number of the front page scripts (default is 1).</param>
6664
/// <returns>A list of Script objects representing the scripts from the front page.</returns>
67-
public static List<Script> GetScriptsFromPageNumber(int pageNumber = 1) => GetFrontPageScripts(pageNumber);
65+
public static List<ScriptObject> GetScriptsFromPageNumber(int pageNumber = 1) => GetFrontPageScripts(pageNumber);
6866

6967
/// <summary>
7068
/// Retrieves a list of scripts from Scriptblox based on the provided search query and maximum results.
7169
/// </summary>
7270
/// <param name="searchQuery">The search query to filter the scripts.</param>
7371
/// <param name="maxResults">The maximum number of results to retrieve (default is 20).</param>
7472
/// <returns>A list of Script objects representing the scripts matching the search query.</returns>
75-
public static List<Script> GetScriptsFromQuery(string searchQuery, int maxResults = 20)
73+
public static List<ScriptObject> GetScriptsFromQuery(string searchQuery, int maxResults = 20)
7674
{
7775
if (maxResults < 1) maxResults = 1;
7876

79-
List<Script> scriptsToReturn = new List<Script>();
77+
List<ScriptObject> scriptsToReturn = new List<ScriptObject>();
8078

81-
dynamic jsonReturn = MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/api/script/search?q={searchQuery}&page=1&max={maxResults}").Result;
79+
JToken jsonReturn = JToken.Parse(MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/api/script/search?q={searchQuery}&page=1&max={maxResults}").Result);
8280

8381
if (jsonReturn == null)
8482
throw new ScriptBloxException("An error has occured while fetching the json, please submit a bug report.");
8583
if (jsonReturn["message"] != null)
86-
throw new ScriptBloxException(jsonReturn["message"]);
84+
throw new ScriptBloxException(jsonReturn.Value<string>("message"));
8785
if (jsonReturn["script"] == null)
8886
throw new ScriptBloxException("Backend error occured.");
8987

@@ -100,20 +98,20 @@ public static List<Script> GetScriptsFromQuery(string searchQuery, int maxResult
10098
/// </summary>
10199
/// <param name="username">The username of the user whose scripts to retrieve.</param>
102100
/// <returns>A list of Script objects representing the scripts owned by the user.</returns>
103-
public static List<Script> GetScriptsFromUser(string username)
101+
public static List<ScriptObject> GetScriptsFromUser(string username)
104102
{
105-
List<Script> scriptsToReturn = new List<Script>();
103+
List<ScriptObject> scriptsToReturn = new List<ScriptObject>();
106104

107-
dynamic jsonReturn = MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/u/{username}").Result;
105+
JToken jsonReturn = JToken.Parse(MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/u/{username}").Result);
108106

109107
if (jsonReturn == null)
110108
throw new ScriptBloxException("An error has occured while fetching the json, please submit a bug report.");
111109
if (jsonReturn["message"] != null)
112-
throw new ScriptBloxException(jsonReturn["message"]);
110+
throw new ScriptBloxException(jsonReturn.Value<string>("message"));
113111
if (jsonReturn["script"] == null)
114112
throw new ScriptBloxException("Backend error occured.");
115113

116-
List<string> slugsToCheck = GetSlugsFromResults(jsonReturn);
114+
List<string> slugsToCheck = GetSlugsFromResults(jsonReturn.ToString());
117115

118116
foreach (string slug in slugsToCheck) scriptsToReturn.Add(GetScriptFromScriptbloxId(slug));
119117

@@ -139,13 +137,11 @@ private static bool IsScriptDataInvalid(JToken scriptData)
139137
scriptData["id"] == null;
140138
}
141139

142-
private static List<string> GetSlugsFromResults(string json)
140+
private static List<string> GetSlugsFromResults(JToken json)
143141
{
144142
List<string> slugs = new List<string>();
145143

146-
JObject data = JObject.Parse(json);
147-
148-
JArray scripts = (JArray)data["result"]["scripts"];
144+
JArray scripts = (JArray)json["result"]["scripts"];
149145

150146
foreach (JToken script in scripts)
151147
{
@@ -156,22 +152,22 @@ private static List<string> GetSlugsFromResults(string json)
156152
return slugs;
157153
}
158154

159-
private static Script CreateScriptFromData(JToken scriptData)
155+
private static ScriptObject CreateScriptFromData(JToken scriptData)
160156
{
161-
GameObject game = new GameObject(scriptData["game"].Value<int>("gameId"),
157+
GameObject game = new GameObject(scriptData["game"].Value<long>("gameId"),
162158
scriptData["game"].Value<string>("name"),
163159
scriptData["game"].Value<string>("imageUrl"));
164160

165-
return new Script(game,
161+
return new ScriptObject(game,
166162
scriptData.Value<string>("title"),
167163
scriptData.Value<string>("_id"),
168164
scriptData.Value<string>("slug"),
169165
scriptData.Value<string>("script"),
170166
scriptData.Value<string>("createdAt"),
171167
scriptData.Value<string>("updatedAt"),
172-
scriptData.Value<int>("views"),
173-
scriptData.Value<int>("likeCount"),
174-
scriptData.Value<int>("dislikeCount"),
168+
scriptData.Value<long>("views"),
169+
scriptData.Value<long>("likeCount"),
170+
scriptData.Value<long>("dislikeCount"),
175171
scriptData.Value<bool>("isUniversal"),
176172
scriptData.Value<bool>("isPatched"),
177173
scriptData.Value<bool>("key"),

Methods/User.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
11
using Newtonsoft.Json.Linq;
22
using ScriptBloxAPI.DataTypes;
3-
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Net.Http;
7-
using System.Text;
8-
using System.Threading.Tasks;
93

104
namespace ScriptBloxAPI.Methods
115
{
12-
public class User
6+
public class UserMethods
137
{
14-
private UserObject _invalidUser = new UserObject(-1, -1, -1, "N/A", "N/A", "N/A", "N/A", "2023-05-22T10:36:23.273Z", "2023-05-22T10:36:23.273Z", false);
15-
168
/// <summary>
179
/// Retrieves user information from the ScriptBlox API based on the provided username.
1810
/// </summary>
1911
/// <param name="username">The username of the user to retrieve.</param>
2012
/// <returns>A UserObject representing the user's information.</returns>
2113
/// <exception cref="ScriptBloxException">Thrown when an error occurs while fetching user information.</exception>
22-
public UserObject GetUserFromUsername(string username)
14+
public static UserObject GetUserFromUsername(string username)
2315
{
24-
dynamic jsonReturn = MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/api/user/info/{username}").Result;
16+
JToken jsonReturn = JToken.Parse(MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/api/user/info/{username}").Result);
2517

2618
if (jsonReturn == null)
2719
throw new ScriptBloxException("An error has occured while fetching the json, please submit a bug report.");
2820
if (jsonReturn["message"] != null)
29-
throw new ScriptBloxException(jsonReturn["message"]);
21+
throw new ScriptBloxException(jsonReturn.Value<string>("message"));
3022
if (jsonReturn["user"] == null)
3123
throw new ScriptBloxException("Backend error occured.");
3224

@@ -51,7 +43,7 @@ public UserObject GetUserFromUsername(string username)
5143
/// </summary>
5244
/// <param name="username">The username to check.</param>
5345
/// <returns>True if the username is taken; otherwise, false.</returns>
54-
public bool IsUsernameTaken(string username)
46+
public static bool IsUsernameTaken(string username)
5547
{
5648
return MiscFunctions.HttpClient.GetStringAsync($"https://scriptblox.com/api/user/info/{username}").Result.Contains("true");
5749
}

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.0.0.0")]
36-
[assembly: AssemblyFileVersion("2.0.0.0")]
35+
[assembly: AssemblyVersion("3.0.0.0")]
36+
[assembly: AssemblyFileVersion("3.0.0.0")]

ScriptBloxAPI.csproj.user

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
4+
<StartAction>Program</StartAction>
5+
</PropertyGroup>
6+
</Project>

ScriptBloxAPI.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<!-- <icon>icon.png</icon> -->
1111
<projectUrl>https://github.com/IrisV3rm/ScriptBloxAPI</projectUrl>
1212
<description>$description$</description>
13-
<releaseNotes>Initial Release | Fixed Namespace</releaseNotes>
13+
<releaseNotes>3.0.0 | Fixed everything should work.</releaseNotes>
1414
<copyright>$copyright$</copyright>
1515
<tags>ScriptBlox ScriptBloxAPI</tags>
1616
</metadata>

ScriptBloxAPI.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.5.33414.496
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptBloxAPI", "ScriptBloxAPI.csproj", "{EF8D8243-431C-4505-86D3-331DB20B9189}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptBloxTestSuite", "..\ScriptBloxTestSuite\ScriptBloxTestSuite.csproj", "{AE41542F-735F-4906-891F-73A4B35D9EEB}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{EF8D8243-431C-4505-86D3-331DB20B9189}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{EF8D8243-431C-4505-86D3-331DB20B9189}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{EF8D8243-431C-4505-86D3-331DB20B9189}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{AE41542F-735F-4906-891F-73A4B35D9EEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{AE41542F-735F-4906-891F-73A4B35D9EEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{AE41542F-735F-4906-891F-73A4B35D9EEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{AE41542F-735F-4906-891F-73A4B35D9EEB}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)