Skip to content

Commit 4c925fa

Browse files
Merge pull request #114 from nullinside-development-group/feat/profile
feat: providing more user information
2 parents 27bdc0b + 50dba77 commit 4c925fa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Nullinside.Api.Common/Twitch/ITwitchApiProxy.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using TwitchLib.Api.Helix.Models.Chat.GetChatters;
44
using TwitchLib.Api.Helix.Models.Moderation.BanUser;
55
using TwitchLib.Api.Helix.Models.Moderation.GetModerators;
6+
using TwitchLib.Api.Helix.Models.Users.GetUsers;
67

78
namespace Nullinside.Api.Common.Twitch;
89

@@ -49,7 +50,7 @@ public interface ITwitchApiProxy {
4950
/// </summary>
5051
/// <param name="token">The cancellation token.</param>
5152
/// <returns>The twitch user information if successful, null otherwise.</returns>
52-
Task<(string? id, string? username)> GetUser(CancellationToken token = new());
53+
Task<User?> GetUser(CancellationToken token = new());
5354

5455
/// <summary>
5556
/// Gets the twitch id and username of the username provided.

src/Nullinside.Api.Common/Twitch/TwitchApiProxy.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,23 @@ public TwitchApiProxy(string token, string refreshToken, DateTime tokenExpires,
129129
/// <inheritdoc />
130130
public async Task<bool> GetAccessTokenIsValid(CancellationToken token = new()) {
131131
try {
132-
return !string.IsNullOrWhiteSpace((await GetUser(token)).id);
132+
return !string.IsNullOrWhiteSpace((await GetUser(token))?.Id);
133133
}
134134
catch {
135135
return false;
136136
}
137137
}
138138

139139
/// <inheritdoc />
140-
public virtual async Task<(string? id, string? username)> GetUser(CancellationToken token = new()) {
140+
public virtual async Task<User?> GetUser(CancellationToken token = new()) {
141141
return await Retry.Execute(async () => {
142142
ITwitchAPI api = GetApi();
143143
GetUsersResponse? response = await api.Helix.Users.GetUsersAsync();
144144
if (null == response) {
145-
return (null, null);
145+
return null;
146146
}
147147

148-
User? user = response.Users.FirstOrDefault();
149-
return (user?.Id, user?.Login);
148+
return response.Users.FirstOrDefault();
150149
}, Retries, token);
151150
}
152151

0 commit comments

Comments
 (0)