Fix rp command not working with badge upgrades

Of course volvo had to use different endpoint for that, it'd be too easy otherwise
This commit is contained in:
Łukasz Domeradzki
2025-09-08 02:41:31 +02:00
parent 22e424a78c
commit 1eadaad9bd
3 changed files with 42 additions and 12 deletions

View File

@@ -628,6 +628,36 @@ public sealed class ArchiHandler : ClientMsgHandler, IDisposable {
return response.Result;
}
[PublicAPI]
public async Task<EResult> RedeemPointsForBadgeLevel(uint definitionID, byte levels = 1) {
ArgumentOutOfRangeException.ThrowIfZero(definitionID);
if (Client == null) {
throw new InvalidOperationException(nameof(Client));
}
if (!Client.IsConnected) {
return EResult.NoConnection;
}
CLoyaltyRewards_RedeemPointsForBadgeLevel_Request request = new() {
defid = definitionID,
num_levels = levels
};
SteamUnifiedMessages.ServiceMethodResponse<CLoyaltyRewards_RedeemPoints_Response> response;
try {
response = await UnifiedLoyaltyRewards.RedeemPointsForBadgeLevel(request).ToLongRunningTask().ConfigureAwait(false);
} catch (Exception e) {
ArchiLogger.LogGenericWarningException(e);
return EResult.Timeout;
}
return response.Result;
}
[PublicAPI]
public async Task<bool> RemoveFriend(ulong steamID) {
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {

View File

@@ -354,23 +354,23 @@ public sealed class Actions : IAsyncDisposable, IDisposable {
public async Task<EResult> RedeemPoints(uint definitionID, bool forced = false) {
ArgumentOutOfRangeException.ThrowIfZero(definitionID);
Dictionary<uint, LoyaltyRewardDefinition>? definitions = await Bot.Actions.GetRewardItems(new HashSet<uint>(1) { definitionID }).ConfigureAwait(false);
if (definitions == null) {
return EResult.Timeout;
}
if (!definitions.TryGetValue(definitionID, out LoyaltyRewardDefinition? definition)) {
return EResult.InvalidParam;
}
if (!forced) {
Dictionary<uint, LoyaltyRewardDefinition>? definitions = await Bot.Actions.GetRewardItems(new HashSet<uint>(1) { definitionID }).ConfigureAwait(false);
if (definitions == null) {
return EResult.Timeout;
}
if (!definitions.TryGetValue(definitionID, out LoyaltyRewardDefinition? definition)) {
return EResult.InvalidParam;
}
if (definition.point_cost > 0) {
return EResult.InvalidState;
}
}
return await Bot.ArchiHandler.RedeemPoints(definitionID).ConfigureAwait(false);
return definition.type == 2 ? await Bot.ArchiHandler.RedeemPointsForBadgeLevel(definitionID).ConfigureAwait(false) : await Bot.ArchiHandler.RedeemPoints(definitionID).ConfigureAwait(false);
}
[PublicAPI]

View File

@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>6.2.2.0</Version>
<Version>6.2.2.1</Version>
</PropertyGroup>
<PropertyGroup>