@valoranchi/riot-client 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +644 -0
- package/dist/RiotClient.d.ts +36 -0
- package/dist/RiotClient.d.ts.map +1 -0
- package/dist/RiotClient.js +115 -0
- package/dist/RiotClient.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -0
- package/dist/catalogue/Catalogue.d.ts +69 -0
- package/dist/catalogue/Catalogue.d.ts.map +1 -0
- package/dist/catalogue/Catalogue.js +206 -0
- package/dist/catalogue/Catalogue.js.map +1 -0
- package/dist/catalogue/CatalogueStore.d.ts +14 -0
- package/dist/catalogue/CatalogueStore.d.ts.map +1 -0
- package/dist/catalogue/CatalogueStore.js +38 -0
- package/dist/catalogue/CatalogueStore.js.map +1 -0
- package/dist/catalogue/ValorantApi.d.ts +26 -0
- package/dist/catalogue/ValorantApi.d.ts.map +1 -0
- package/dist/catalogue/ValorantApi.js +126 -0
- package/dist/catalogue/ValorantApi.js.map +1 -0
- package/dist/catalogue/types.d.ts +173 -0
- package/dist/catalogue/types.d.ts.map +1 -0
- package/dist/catalogue/types.js +2 -0
- package/dist/catalogue/types.js.map +1 -0
- package/dist/cli.d.ts +18 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +912 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/AccountService.d.ts +61 -0
- package/dist/client/AccountService.d.ts.map +1 -0
- package/dist/client/AccountService.js +319 -0
- package/dist/client/AccountService.js.map +1 -0
- package/dist/client/AccountValidator.d.ts +15 -0
- package/dist/client/AccountValidator.d.ts.map +1 -0
- package/dist/client/AccountValidator.js +49 -0
- package/dist/client/AccountValidator.js.map +1 -0
- package/dist/client/ChatValidator.d.ts +40 -0
- package/dist/client/ChatValidator.d.ts.map +1 -0
- package/dist/client/ChatValidator.js +154 -0
- package/dist/client/ChatValidator.js.map +1 -0
- package/dist/client/ClientContext.d.ts +16 -0
- package/dist/client/ClientContext.d.ts.map +1 -0
- package/dist/client/ClientContext.js +12 -0
- package/dist/client/ClientContext.js.map +1 -0
- package/dist/client/EventsService.d.ts +11 -0
- package/dist/client/EventsService.d.ts.map +1 -0
- package/dist/client/EventsService.js +54 -0
- package/dist/client/EventsService.js.map +1 -0
- package/dist/client/LiveMatchService.d.ts +18 -0
- package/dist/client/LiveMatchService.d.ts.map +1 -0
- package/dist/client/LiveMatchService.js +84 -0
- package/dist/client/LiveMatchService.js.map +1 -0
- package/dist/client/LoadoutValidator.d.ts +28 -0
- package/dist/client/LoadoutValidator.d.ts.map +1 -0
- package/dist/client/LoadoutValidator.js +330 -0
- package/dist/client/LoadoutValidator.js.map +1 -0
- package/dist/client/MatchService.d.ts +80 -0
- package/dist/client/MatchService.d.ts.map +1 -0
- package/dist/client/MatchService.js +199 -0
- package/dist/client/MatchService.js.map +1 -0
- package/dist/client/MatchValidator.d.ts +29 -0
- package/dist/client/MatchValidator.d.ts.map +1 -0
- package/dist/client/MatchValidator.js +81 -0
- package/dist/client/MatchValidator.js.map +1 -0
- package/dist/client/PartyService.d.ts +111 -0
- package/dist/client/PartyService.d.ts.map +1 -0
- package/dist/client/PartyService.js +460 -0
- package/dist/client/PartyService.js.map +1 -0
- package/dist/client/PartyValidator.d.ts +93 -0
- package/dist/client/PartyValidator.d.ts.map +1 -0
- package/dist/client/PartyValidator.js +390 -0
- package/dist/client/PartyValidator.js.map +1 -0
- package/dist/client/SessionManager.d.ts +28 -0
- package/dist/client/SessionManager.d.ts.map +1 -0
- package/dist/client/SessionManager.js +104 -0
- package/dist/client/SessionManager.js.map +1 -0
- package/dist/client/SocialService.d.ts +63 -0
- package/dist/client/SocialService.d.ts.map +1 -0
- package/dist/client/SocialService.js +185 -0
- package/dist/client/SocialService.js.map +1 -0
- package/dist/client/StoreService.d.ts +25 -0
- package/dist/client/StoreService.d.ts.map +1 -0
- package/dist/client/StoreService.js +88 -0
- package/dist/client/StoreService.js.map +1 -0
- package/dist/client/StoreValidator.d.ts +32 -0
- package/dist/client/StoreValidator.d.ts.map +1 -0
- package/dist/client/StoreValidator.js +111 -0
- package/dist/client/StoreValidator.js.map +1 -0
- package/dist/client/api.d.ts +323 -0
- package/dist/client/api.d.ts.map +1 -0
- package/dist/client/api.js +2 -0
- package/dist/client/api.js.map +1 -0
- package/dist/collection/AccountProgressionBuilder.d.ts +12 -0
- package/dist/collection/AccountProgressionBuilder.d.ts.map +1 -0
- package/dist/collection/AccountProgressionBuilder.js +132 -0
- package/dist/collection/AccountProgressionBuilder.js.map +1 -0
- package/dist/collection/CollectionBuilder.d.ts +19 -0
- package/dist/collection/CollectionBuilder.d.ts.map +1 -0
- package/dist/collection/CollectionBuilder.js +199 -0
- package/dist/collection/CollectionBuilder.js.map +1 -0
- package/dist/collection/ContentBuilder.d.ts +6 -0
- package/dist/collection/ContentBuilder.d.ts.map +1 -0
- package/dist/collection/ContentBuilder.js +36 -0
- package/dist/collection/ContentBuilder.js.map +1 -0
- package/dist/collection/CustomGameConfigsBuilder.d.ts +9 -0
- package/dist/collection/CustomGameConfigsBuilder.d.ts.map +1 -0
- package/dist/collection/CustomGameConfigsBuilder.js +49 -0
- package/dist/collection/CustomGameConfigsBuilder.js.map +1 -0
- package/dist/collection/FriendsBuilder.d.ts +12 -0
- package/dist/collection/FriendsBuilder.d.ts.map +1 -0
- package/dist/collection/FriendsBuilder.js +89 -0
- package/dist/collection/FriendsBuilder.js.map +1 -0
- package/dist/collection/GameSessionBuilder.d.ts +6 -0
- package/dist/collection/GameSessionBuilder.d.ts.map +1 -0
- package/dist/collection/GameSessionBuilder.js +11 -0
- package/dist/collection/GameSessionBuilder.js.map +1 -0
- package/dist/collection/LeaderboardBuilder.d.ts +9 -0
- package/dist/collection/LeaderboardBuilder.d.ts.map +1 -0
- package/dist/collection/LeaderboardBuilder.js +31 -0
- package/dist/collection/LeaderboardBuilder.js.map +1 -0
- package/dist/collection/LiveMatchBuilder.d.ts +22 -0
- package/dist/collection/LiveMatchBuilder.d.ts.map +1 -0
- package/dist/collection/LiveMatchBuilder.js +154 -0
- package/dist/collection/LiveMatchBuilder.js.map +1 -0
- package/dist/collection/LoadoutBuilder.d.ts +12 -0
- package/dist/collection/LoadoutBuilder.d.ts.map +1 -0
- package/dist/collection/LoadoutBuilder.js +126 -0
- package/dist/collection/LoadoutBuilder.js.map +1 -0
- package/dist/collection/LoadoutWriter.d.ts +32 -0
- package/dist/collection/LoadoutWriter.d.ts.map +1 -0
- package/dist/collection/LoadoutWriter.js +48 -0
- package/dist/collection/LoadoutWriter.js.map +1 -0
- package/dist/collection/MatchBuilder.d.ts +22 -0
- package/dist/collection/MatchBuilder.d.ts.map +1 -0
- package/dist/collection/MatchBuilder.js +209 -0
- package/dist/collection/MatchBuilder.js.map +1 -0
- package/dist/collection/MessagesBuilder.d.ts +11 -0
- package/dist/collection/MessagesBuilder.d.ts.map +1 -0
- package/dist/collection/MessagesBuilder.js +89 -0
- package/dist/collection/MessagesBuilder.js.map +1 -0
- package/dist/collection/MmrBuilder.d.ts +16 -0
- package/dist/collection/MmrBuilder.d.ts.map +1 -0
- package/dist/collection/MmrBuilder.js +134 -0
- package/dist/collection/MmrBuilder.js.map +1 -0
- package/dist/collection/PartyBuilder.d.ts +14 -0
- package/dist/collection/PartyBuilder.d.ts.map +1 -0
- package/dist/collection/PartyBuilder.js +37 -0
- package/dist/collection/PartyBuilder.js.map +1 -0
- package/dist/collection/PlayerSettingsBuilder.d.ts +6 -0
- package/dist/collection/PlayerSettingsBuilder.d.ts.map +1 -0
- package/dist/collection/PlayerSettingsBuilder.js +41 -0
- package/dist/collection/PlayerSettingsBuilder.js.map +1 -0
- package/dist/collection/QueueConfigBuilder.d.ts +6 -0
- package/dist/collection/QueueConfigBuilder.d.ts.map +1 -0
- package/dist/collection/QueueConfigBuilder.js +14 -0
- package/dist/collection/QueueConfigBuilder.js.map +1 -0
- package/dist/collection/RankResolver.d.ts +18 -0
- package/dist/collection/RankResolver.d.ts.map +1 -0
- package/dist/collection/RankResolver.js +91 -0
- package/dist/collection/RankResolver.js.map +1 -0
- package/dist/collection/StoreBuilder.d.ts +20 -0
- package/dist/collection/StoreBuilder.d.ts.map +1 -0
- package/dist/collection/StoreBuilder.js +153 -0
- package/dist/collection/StoreBuilder.js.map +1 -0
- package/dist/collection/StoreItemResolver.d.ts +14 -0
- package/dist/collection/StoreItemResolver.d.ts.map +1 -0
- package/dist/collection/StoreItemResolver.js +138 -0
- package/dist/collection/StoreItemResolver.js.map +1 -0
- package/dist/collection/StoreOffersBuilder.d.ts +12 -0
- package/dist/collection/StoreOffersBuilder.d.ts.map +1 -0
- package/dist/collection/StoreOffersBuilder.js +46 -0
- package/dist/collection/StoreOffersBuilder.js.map +1 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +52 -0
- package/dist/errors.js.map +1 -0
- package/dist/events/RiotEvents.d.ts +78 -0
- package/dist/events/RiotEvents.d.ts.map +1 -0
- package/dist/events/RiotEvents.js +284 -0
- package/dist/events/RiotEvents.js.map +1 -0
- package/dist/events/TypedEmitter.d.ts +10 -0
- package/dist/events/TypedEmitter.d.ts.map +1 -0
- package/dist/events/TypedEmitter.js +30 -0
- package/dist/events/TypedEmitter.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/local/ChatApi.d.ts +21 -0
- package/dist/local/ChatApi.d.ts.map +1 -0
- package/dist/local/ChatApi.js +89 -0
- package/dist/local/ChatApi.js.map +1 -0
- package/dist/local/Lockfile.d.ts +10 -0
- package/dist/local/Lockfile.d.ts.map +1 -0
- package/dist/local/Lockfile.js +37 -0
- package/dist/local/Lockfile.js.map +1 -0
- package/dist/local/Presence.d.ts +4 -0
- package/dist/local/Presence.d.ts.map +1 -0
- package/dist/local/Presence.js +118 -0
- package/dist/local/Presence.js.map +1 -0
- package/dist/local/RegionResolver.d.ts +12 -0
- package/dist/local/RegionResolver.d.ts.map +1 -0
- package/dist/local/RegionResolver.js +51 -0
- package/dist/local/RegionResolver.js.map +1 -0
- package/dist/local/RiotClientLocalApi.d.ts +48 -0
- package/dist/local/RiotClientLocalApi.d.ts.map +1 -0
- package/dist/local/RiotClientLocalApi.js +218 -0
- package/dist/local/RiotClientLocalApi.js.map +1 -0
- package/dist/local/RiotSocket.d.ts +56 -0
- package/dist/local/RiotSocket.d.ts.map +1 -0
- package/dist/local/RiotSocket.js +196 -0
- package/dist/local/RiotSocket.js.map +1 -0
- package/dist/local/chatTypes.d.ts +115 -0
- package/dist/local/chatTypes.d.ts.map +1 -0
- package/dist/local/chatTypes.js +2 -0
- package/dist/local/chatTypes.js.map +1 -0
- package/dist/model/index.d.ts +756 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +2 -0
- package/dist/model/index.js.map +1 -0
- package/dist/raw.d.ts +25 -0
- package/dist/raw.d.ts.map +1 -0
- package/dist/raw.js +24 -0
- package/dist/raw.js.map +1 -0
- package/dist/riot/HttpGateway.d.ts +14 -0
- package/dist/riot/HttpGateway.d.ts.map +1 -0
- package/dist/riot/HttpGateway.js +87 -0
- package/dist/riot/HttpGateway.js.map +1 -0
- package/dist/riot/ResponseCache.d.ts +15 -0
- package/dist/riot/ResponseCache.d.ts.map +1 -0
- package/dist/riot/ResponseCache.js +75 -0
- package/dist/riot/ResponseCache.js.map +1 -0
- package/dist/riot/RiotApi.d.ts +87 -0
- package/dist/riot/RiotApi.d.ts.map +1 -0
- package/dist/riot/RiotApi.js +305 -0
- package/dist/riot/RiotApi.js.map +1 -0
- package/dist/riot/Session.d.ts +24 -0
- package/dist/riot/Session.d.ts.map +1 -0
- package/dist/riot/Session.js +41 -0
- package/dist/riot/Session.js.map +1 -0
- package/dist/riot/types.d.ts +676 -0
- package/dist/riot/types.d.ts.map +1 -0
- package/dist/riot/types.js +17 -0
- package/dist/riot/types.js.map +1 -0
- package/package.json +68 -0
- package/schema/AccountXp.json +86 -0
- package/schema/BlockedPlayer.json +22 -0
- package/schema/ClientInfo.json +41 -0
- package/schema/Content.json +83 -0
- package/schema/ContractProgress.json +69 -0
- package/schema/Conversation.json +49 -0
- package/schema/CustomGameConfigs.json +64 -0
- package/schema/CustomGameSettings.json +46 -0
- package/schema/Favourite.json +22 -0
- package/schema/Friend.json +215 -0
- package/schema/FriendRequest.json +26 -0
- package/schema/GameSession.json +25 -0
- package/schema/Leaderboard.json +103 -0
- package/schema/LeaderboardEntry.json +75 -0
- package/schema/LiveMatch.json +354 -0
- package/schema/Loadout.json +241 -0
- package/schema/Match.json +494 -0
- package/schema/MatchSummary.json +38 -0
- package/schema/Message.json +48 -0
- package/schema/Mission.json +31 -0
- package/schema/Mmr.json +172 -0
- package/schema/Offer.json +163 -0
- package/schema/Order.json +177 -0
- package/schema/OwnedItems.json +308 -0
- package/schema/Participant.json +50 -0
- package/schema/Party.json +185 -0
- package/schema/PartyInvite.json +45 -0
- package/schema/PartyRequest.json +42 -0
- package/schema/Penalty.json +22 -0
- package/schema/Player.json +31 -0
- package/schema/PlayerSettings.json +76 -0
- package/schema/Premier.json +19 -0
- package/schema/QueueConfig.json +34 -0
- package/schema/RankChange.json +89 -0
- package/schema/Store.json +455 -0
- package/schema/Wallet.json +22 -0
package/dist/cli.js
ADDED
|
@@ -0,0 +1,912 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
import { RiotClientError, ValidationError } from "./errors.js";
|
|
4
|
+
import { RiotClient } from "./RiotClient.js";
|
|
5
|
+
export const USAGE = `Usage: riotclient <command> [options]
|
|
6
|
+
|
|
7
|
+
Account:
|
|
8
|
+
whoami Print signed-in player profile and region
|
|
9
|
+
owned-items Print owned inventory items
|
|
10
|
+
loadout Print currently equipped loadout
|
|
11
|
+
wallet Print VP, Radianite, and Kingdom Credits balances
|
|
12
|
+
xp Print account level, XP progression and recent match XP history
|
|
13
|
+
contracts Print progression across agent, battlepass and event contracts
|
|
14
|
+
missions Print active daily and weekly missions and objectives
|
|
15
|
+
penalties Print active penalties and restrictions
|
|
16
|
+
favourites Print favorited weapon skins
|
|
17
|
+
session Print current client session loop state and playtime
|
|
18
|
+
config Print shared client configuration mapping
|
|
19
|
+
client Print client identity, locale, region, and Valorant running state
|
|
20
|
+
settings Print cloud player settings (--raw for unprocessed dump)
|
|
21
|
+
settings-save Save player settings from JSON file (<file.json>, requires --yes --confirm)
|
|
22
|
+
equip Equip skins, buddies, sprays, card, title, border, flex (dry-run, --yes to apply)
|
|
23
|
+
equip-collection Equip a collection of skins (<skinUuid,...>) (dry-run, --yes to apply)
|
|
24
|
+
contract-activate Activate an agent contract (<uuid>) (dry-run, --yes to apply)
|
|
25
|
+
favourite-add Add skin to favourites (<skin>) (dry-run, --yes to apply)
|
|
26
|
+
favourite-remove Remove skin from favourites (<skin>) (dry-run, --yes to apply)
|
|
27
|
+
privacy Update account privacy toggles (--badge on|off, --leaderboard on|off)
|
|
28
|
+
|
|
29
|
+
Social:
|
|
30
|
+
friends Print friends roster and presence
|
|
31
|
+
friend-requests Print incoming and outgoing friend requests
|
|
32
|
+
blocked Print blocked players
|
|
33
|
+
conversations Print whisper and match chat conversations
|
|
34
|
+
messages Print chat messages (filter with --cid <id>)
|
|
35
|
+
participants Print chat participants (filter with --cid <id>)
|
|
36
|
+
send Send chat message (--to <puuid|name#tag|cid> --text <msg>)
|
|
37
|
+
friend-request Send friend request (<name#tag>)
|
|
38
|
+
friend-accept Accept friend request (<puuid>)
|
|
39
|
+
friend-decline Decline friend request (<puuid>)
|
|
40
|
+
friend-cancel Cancel friend request (<puuid>)
|
|
41
|
+
friend-remove Remove friend (<puuid>)
|
|
42
|
+
block Block player (<puuid|name#tag>)
|
|
43
|
+
unblock Unblock player (<puuid>)
|
|
44
|
+
|
|
45
|
+
Store:
|
|
46
|
+
store Print storefront (daily, night market, bundles, accessories)
|
|
47
|
+
offers Print full item offers catalog and pricing
|
|
48
|
+
order <id> Print store order details
|
|
49
|
+
night-market-reveal Reveal night market offers (dry-run, --yes to apply)
|
|
50
|
+
buy Purchase offer or bundle (--offer <id> | --bundle <id>, requires --yes --confirm)
|
|
51
|
+
|
|
52
|
+
Matches:
|
|
53
|
+
matches Print recent match history summaries
|
|
54
|
+
match <id> Print full match details by ID
|
|
55
|
+
mmr Print current rank, rating, and MMR breakdown
|
|
56
|
+
rank-history Print competitive rating adjustments and tier changes
|
|
57
|
+
live Print live pregame or in-game lobby status and loadouts
|
|
58
|
+
matches-for <puuid> Print recent match history summaries for player
|
|
59
|
+
mmr-for <puuid> Print rank, rating, and MMR for player
|
|
60
|
+
rank-history-for <puuid> Print competitive updates for player
|
|
61
|
+
leaderboard Print competitive leaderboard [--season] [--start] [--size] [--query]
|
|
62
|
+
content Print active act, episode and live events
|
|
63
|
+
premier Print premier eligibility, roster, and season info
|
|
64
|
+
agent-select Select an agent in pregame (<uuid|name>) (dry-run, --yes to apply)
|
|
65
|
+
agent-lock Lock in an agent in pregame (<uuid|name>) (dry-run, --yes to apply)
|
|
66
|
+
dodge Dodge pregame agent select (requires --yes --confirm)
|
|
67
|
+
leave-match Leave active in-game match (requires --yes --confirm)
|
|
68
|
+
|
|
69
|
+
Party:
|
|
70
|
+
party Print current party details and members
|
|
71
|
+
queues Print matchmaking queue configurations
|
|
72
|
+
custom-game-configs Print custom game configuration options
|
|
73
|
+
party-invite Invite player to party (<name#tag>)
|
|
74
|
+
party-kick Kick member from party (<puuid>)
|
|
75
|
+
party-promote Promote member to party owner (<puuid>)
|
|
76
|
+
party-code Generate or revoke party invite code [--revoke]
|
|
77
|
+
party-join Join party by invite code or party ID (<partyId|code>)
|
|
78
|
+
party-invites Print incoming party invites
|
|
79
|
+
party-requests Print incoming party join requests
|
|
80
|
+
party-decline-invite Decline party invite (<id>) (dry-run, --yes to apply)
|
|
81
|
+
party-request Request to join party (<partyId>) (dry-run, --yes to apply)
|
|
82
|
+
party-decline-request Decline party join request (<id>) (dry-run, --yes to apply)
|
|
83
|
+
custom-game Convert party into a custom game (dry-run, --yes to apply)
|
|
84
|
+
custom-game-settings Configure custom game (--map <name> --mode <name> [--server <id>] [--rule k=v...])
|
|
85
|
+
custom-game-team Set member custom game team (<puuid> <team>) (dry-run, --yes to apply)
|
|
86
|
+
custom-game-start Start custom game match (dry-run, --yes to apply)
|
|
87
|
+
custom-game-balance Balance custom game teams (dry-run, --yes to apply)
|
|
88
|
+
party-default Set party default queue (<queue>) (dry-run, --yes to apply)
|
|
89
|
+
party-servers Set preferred game servers (<id,...>) (dry-run, --yes to apply)
|
|
90
|
+
party-moderator Set member moderator status (<puuid> on|off) (dry-run, --yes to apply)
|
|
91
|
+
party-refresh Refresh party member pings and identity (dry-run, --yes to apply)
|
|
92
|
+
party-ready Set party ready state (on|off)
|
|
93
|
+
party-queue Change party queue (<queue>)
|
|
94
|
+
party-access Set party accessibility (open|closed)
|
|
95
|
+
party-start Start party matchmaking
|
|
96
|
+
party-stop Stop party matchmaking
|
|
97
|
+
party-leave Leave current party
|
|
98
|
+
|
|
99
|
+
Raw (unsupported):
|
|
100
|
+
local Send raw request to local Riot client API (<get|post|put|delete> <path> [--body json])
|
|
101
|
+
riot Send raw request to remote Riot game servers (<get|post|put|delete> <url> [--body json])
|
|
102
|
+
|
|
103
|
+
Events:
|
|
104
|
+
watch Stream real-time events as JSON lines until interrupted
|
|
105
|
+
|
|
106
|
+
Options:
|
|
107
|
+
--yes Execute write command (default is dry-run)
|
|
108
|
+
--confirm Confirm write action (required with buy, dodge, leave-match, settings-save)
|
|
109
|
+
--offer <id> Store offer ID to purchase
|
|
110
|
+
--bundle <id> Store bundle ID to purchase
|
|
111
|
+
--badge <on|off> Hide or show act rank badge
|
|
112
|
+
--leaderboard <on|off> Anonymize or reveal leaderboard presence
|
|
113
|
+
--season <uuid> Season ID for leaderboard
|
|
114
|
+
--start <n> Leaderboard starting index
|
|
115
|
+
--size <n> Leaderboard page size (max 510)
|
|
116
|
+
--query <text> Leaderboard player search query
|
|
117
|
+
--revoke Revoke party invite code (used with party-code)
|
|
118
|
+
--to <target> Message recipient (puuid, name#tag, or cid)
|
|
119
|
+
--text <msg> Message text
|
|
120
|
+
--gun <spec> Gun to equip: <weapon>=<skin>[:level[:chroma]] (repeatable)
|
|
121
|
+
--buddy <spec> Buddy to equip: <weapon>=<buddy|none> (repeatable)
|
|
122
|
+
--spray <spec> Spray to equip: <slot>=<uuid|none> (repeatable)
|
|
123
|
+
--card <uuid> Player card UUID
|
|
124
|
+
--title <uuid> Player title UUID
|
|
125
|
+
--flex <uuid|none> Flex item UUID or none
|
|
126
|
+
--border <uuid> Level border UUID
|
|
127
|
+
--incognito <on|off> Enable or disable incognito
|
|
128
|
+
--hide-level <on|off> Hide or show account level
|
|
129
|
+
--count <n> Number of matches or rank history entries to fetch
|
|
130
|
+
--queue <queue> Queue filter (e.g. competitive, unrated)
|
|
131
|
+
--ranks Fetch MMR and rank for each player in live match
|
|
132
|
+
--no-loadouts Skip fetching player loadouts in live match
|
|
133
|
+
--map <name> Map name or path for custom game
|
|
134
|
+
--mode <name> Game mode name or path for custom game
|
|
135
|
+
--server <id> Server pod ID for custom game
|
|
136
|
+
--rule <spec> Game rule override: <name>=<value> (repeatable)
|
|
137
|
+
--body <json> JSON request body for local and riot raw commands
|
|
138
|
+
--only <events> Comma-separated list of event names to print
|
|
139
|
+
--raw Include raw client event frames or unformatted settings
|
|
140
|
+
--cid <id> Conversation ID for filtering messages or participants
|
|
141
|
+
--language <lang> Catalogue language (default: en-US)
|
|
142
|
+
--cache <seconds> Reuse Riot responses younger than this many seconds
|
|
143
|
+
--pretty Pretty-print JSON output
|
|
144
|
+
--help Show usage instructions
|
|
145
|
+
--version Show version number
|
|
146
|
+
`;
|
|
147
|
+
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
|
|
148
|
+
const ERROR_EXIT_CODES = {
|
|
149
|
+
RIOT_CLIENT_NOT_RUNNING: 2,
|
|
150
|
+
RIOT_CLIENT_NOT_READY: 3,
|
|
151
|
+
REGION_UNKNOWN: 4,
|
|
152
|
+
RIOT_API_ERROR: 5,
|
|
153
|
+
VALIDATION: 6,
|
|
154
|
+
};
|
|
155
|
+
export function exitCodeForError(error) {
|
|
156
|
+
if (error instanceof RiotClientError) {
|
|
157
|
+
return ERROR_EXIT_CODES[error.code] ?? 1;
|
|
158
|
+
}
|
|
159
|
+
return 1;
|
|
160
|
+
}
|
|
161
|
+
export function formatError(error) {
|
|
162
|
+
if (error instanceof ValidationError) {
|
|
163
|
+
return {
|
|
164
|
+
error: {
|
|
165
|
+
code: error.code,
|
|
166
|
+
reason: error.reason,
|
|
167
|
+
message: error.message,
|
|
168
|
+
details: error.details,
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (error instanceof RiotClientError) {
|
|
173
|
+
return {
|
|
174
|
+
error: {
|
|
175
|
+
code: error.code,
|
|
176
|
+
message: error.message,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
181
|
+
return {
|
|
182
|
+
error: {
|
|
183
|
+
code: "UNKNOWN_ERROR",
|
|
184
|
+
message,
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
export function formatWatchLine(event, data, at = new Date().toISOString()) {
|
|
189
|
+
return JSON.stringify({
|
|
190
|
+
event,
|
|
191
|
+
at,
|
|
192
|
+
data: data !== undefined ? data : null,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
const WATCH_EVENTS = [
|
|
196
|
+
"connected",
|
|
197
|
+
"disconnected",
|
|
198
|
+
"friend:presence",
|
|
199
|
+
"friend:added",
|
|
200
|
+
"friend:removed",
|
|
201
|
+
"friend:request",
|
|
202
|
+
"message",
|
|
203
|
+
"party",
|
|
204
|
+
"game",
|
|
205
|
+
"self:state",
|
|
206
|
+
"raw",
|
|
207
|
+
"error",
|
|
208
|
+
];
|
|
209
|
+
export async function runWatch(client, options = {}) {
|
|
210
|
+
const allowed = options.only
|
|
211
|
+
? new Set(options.only
|
|
212
|
+
.split(",")
|
|
213
|
+
.map((s) => s.trim())
|
|
214
|
+
.filter(Boolean))
|
|
215
|
+
: null;
|
|
216
|
+
const includeRaw = Boolean(options.raw);
|
|
217
|
+
const events = client.events();
|
|
218
|
+
const printEvent = (event, data) => {
|
|
219
|
+
if (event === "raw" && !includeRaw)
|
|
220
|
+
return;
|
|
221
|
+
if (allowed && !allowed.has(event))
|
|
222
|
+
return;
|
|
223
|
+
const payload = data instanceof Error ? { name: data.name, message: data.message } : data;
|
|
224
|
+
process.stdout.write(`${formatWatchLine(event, payload)}\n`);
|
|
225
|
+
};
|
|
226
|
+
for (const name of WATCH_EVENTS) {
|
|
227
|
+
events.on(name, (...args) => {
|
|
228
|
+
printEvent(name, args[0]);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
await new Promise((resolve) => {
|
|
232
|
+
const onSignal = () => {
|
|
233
|
+
process.off("SIGINT", onSignal);
|
|
234
|
+
process.off("SIGTERM", onSignal);
|
|
235
|
+
resolve();
|
|
236
|
+
};
|
|
237
|
+
process.on("SIGINT", onSignal);
|
|
238
|
+
process.on("SIGTERM", onSignal);
|
|
239
|
+
});
|
|
240
|
+
await client.close();
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
243
|
+
const UNKNOWN_COMMAND = Symbol("UNKNOWN_COMMAND");
|
|
244
|
+
function parseTarget(to) {
|
|
245
|
+
if (to.includes("#"))
|
|
246
|
+
return { riotId: to };
|
|
247
|
+
if (to.includes("@"))
|
|
248
|
+
return { conversationId: to };
|
|
249
|
+
return { puuid: to };
|
|
250
|
+
}
|
|
251
|
+
function parseBooleanFlag(name, value) {
|
|
252
|
+
if (value === undefined || value === null)
|
|
253
|
+
return undefined;
|
|
254
|
+
const str = String(value).toLowerCase();
|
|
255
|
+
if (str === "on" || str === "true")
|
|
256
|
+
return true;
|
|
257
|
+
if (str === "off" || str === "false")
|
|
258
|
+
return false;
|
|
259
|
+
throw new ValidationError("invalid-argument", `Expected ${name} on|off, received: ${String(value)}`);
|
|
260
|
+
}
|
|
261
|
+
function parseNullableUuid(value) {
|
|
262
|
+
if (value === undefined || value === null)
|
|
263
|
+
return undefined;
|
|
264
|
+
const str = String(value);
|
|
265
|
+
if (str.toLowerCase() === "none" || str.toLowerCase() === "null")
|
|
266
|
+
return null;
|
|
267
|
+
return str;
|
|
268
|
+
}
|
|
269
|
+
function parseSprays(sprayArgs) {
|
|
270
|
+
if (!sprayArgs)
|
|
271
|
+
return undefined;
|
|
272
|
+
const sprays = [undefined, undefined, undefined];
|
|
273
|
+
for (const arg of sprayArgs) {
|
|
274
|
+
const eqIdx = arg.indexOf("=");
|
|
275
|
+
if (eqIdx === -1) {
|
|
276
|
+
throw new ValidationError("invalid-argument", `Invalid spray spec: ${arg}. Expected <slot>=<uuid|none>`);
|
|
277
|
+
}
|
|
278
|
+
const slotNum = Number(arg.slice(0, eqIdx));
|
|
279
|
+
if (isNaN(slotNum) || slotNum < 0 || slotNum > 2) {
|
|
280
|
+
throw new ValidationError("too-many-sprays", `Invalid spray slot: ${arg.slice(0, eqIdx)}. Expected 0, 1, or 2`);
|
|
281
|
+
}
|
|
282
|
+
sprays[slotNum] = parseNullableUuid(arg.slice(eqIdx + 1));
|
|
283
|
+
}
|
|
284
|
+
return sprays;
|
|
285
|
+
}
|
|
286
|
+
function parseGuns(gunArgs, buddyArgs) {
|
|
287
|
+
if (!gunArgs && !buddyArgs)
|
|
288
|
+
return undefined;
|
|
289
|
+
const gunsMap = new Map();
|
|
290
|
+
if (gunArgs) {
|
|
291
|
+
for (const arg of gunArgs) {
|
|
292
|
+
const eqIdx = arg.indexOf("=");
|
|
293
|
+
if (eqIdx === -1) {
|
|
294
|
+
throw new ValidationError("invalid-argument", `Invalid gun spec: ${arg}. Expected <weapon>=<skin>[:level[:chroma]]`);
|
|
295
|
+
}
|
|
296
|
+
const weapon = arg.slice(0, eqIdx);
|
|
297
|
+
const rest = arg.slice(eqIdx + 1);
|
|
298
|
+
const parts = rest.split(":");
|
|
299
|
+
const skin = parts[0] || undefined;
|
|
300
|
+
const level = parts[1] || undefined;
|
|
301
|
+
const chroma = parts[2] || undefined;
|
|
302
|
+
gunsMap.set(weapon.toLowerCase(), { weapon, skin, level, chroma });
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
if (buddyArgs) {
|
|
306
|
+
for (const arg of buddyArgs) {
|
|
307
|
+
const eqIdx = arg.indexOf("=");
|
|
308
|
+
if (eqIdx === -1) {
|
|
309
|
+
throw new ValidationError("invalid-argument", `Invalid buddy spec: ${arg}. Expected <weapon>=<buddy|none>`);
|
|
310
|
+
}
|
|
311
|
+
const weapon = arg.slice(0, eqIdx);
|
|
312
|
+
const buddy = parseNullableUuid(arg.slice(eqIdx + 1));
|
|
313
|
+
const existing = gunsMap.get(weapon.toLowerCase());
|
|
314
|
+
if (existing) {
|
|
315
|
+
existing.buddy = buddy;
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
gunsMap.set(weapon.toLowerCase(), { weapon, buddy });
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return Array.from(gunsMap.values());
|
|
323
|
+
}
|
|
324
|
+
function parseEquipChange(values) {
|
|
325
|
+
const border = (values.border ?? values["level-border"]);
|
|
326
|
+
return {
|
|
327
|
+
guns: parseGuns(values.gun, values.buddy),
|
|
328
|
+
sprays: parseSprays(values.spray),
|
|
329
|
+
flex: parseNullableUuid(values.flex),
|
|
330
|
+
card: values.card,
|
|
331
|
+
title: values.title,
|
|
332
|
+
levelBorder: border,
|
|
333
|
+
incognito: parseBooleanFlag("incognito", values.incognito),
|
|
334
|
+
hideAccountLevel: parseBooleanFlag("hide-level", values["hide-level"] ?? values["hide-account-level"]),
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function requirePositional(pos, index, usage) {
|
|
338
|
+
const val = pos[index];
|
|
339
|
+
if (!val)
|
|
340
|
+
throw new ValidationError("invalid-argument", usage);
|
|
341
|
+
return val;
|
|
342
|
+
}
|
|
343
|
+
async function executeStandardCommand(client, command, options) {
|
|
344
|
+
const pos = options?.positionals ?? [];
|
|
345
|
+
switch (command) {
|
|
346
|
+
case "whoami":
|
|
347
|
+
return client.account.whoami();
|
|
348
|
+
case "owned-items":
|
|
349
|
+
return client.account.ownedItems({ language: options?.language });
|
|
350
|
+
case "loadout":
|
|
351
|
+
return client.account.loadout();
|
|
352
|
+
case "wallet":
|
|
353
|
+
return client.account.wallet();
|
|
354
|
+
case "xp":
|
|
355
|
+
return client.account.xp();
|
|
356
|
+
case "contracts":
|
|
357
|
+
return client.account.contracts();
|
|
358
|
+
case "missions":
|
|
359
|
+
return client.account.missions();
|
|
360
|
+
case "penalties":
|
|
361
|
+
return client.account.penalties();
|
|
362
|
+
case "favourites":
|
|
363
|
+
return client.account.favourites();
|
|
364
|
+
case "session":
|
|
365
|
+
return client.account.session();
|
|
366
|
+
case "config":
|
|
367
|
+
return client.account.config();
|
|
368
|
+
case "friends":
|
|
369
|
+
return client.social.friends();
|
|
370
|
+
case "friend-requests":
|
|
371
|
+
return client.social.friendRequests();
|
|
372
|
+
case "blocked":
|
|
373
|
+
return client.social.blocked();
|
|
374
|
+
case "conversations":
|
|
375
|
+
return client.social.conversations();
|
|
376
|
+
case "messages":
|
|
377
|
+
return client.social.messages(options?.cid);
|
|
378
|
+
case "store":
|
|
379
|
+
return client.store.current({ language: options?.language });
|
|
380
|
+
case "offers":
|
|
381
|
+
return client.store.offers();
|
|
382
|
+
case "order":
|
|
383
|
+
return client.store.order(requirePositional(pos, 1, "Usage: riotclient order <id>"));
|
|
384
|
+
case "client":
|
|
385
|
+
return client.account.client();
|
|
386
|
+
case "participants":
|
|
387
|
+
return client.social.participants(options?.cid);
|
|
388
|
+
case "settings": {
|
|
389
|
+
const settings = await client.account.settings();
|
|
390
|
+
return options?.rawValues?.raw ? settings.raw : settings;
|
|
391
|
+
}
|
|
392
|
+
default:
|
|
393
|
+
return UNKNOWN_COMMAND;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
async function executeGameCommand(client, command, options) {
|
|
397
|
+
const pos = options?.positionals ?? [];
|
|
398
|
+
const vals = options?.rawValues ?? {};
|
|
399
|
+
switch (command) {
|
|
400
|
+
case "matches":
|
|
401
|
+
return client.matches.list({ count: options?.count, queue: options?.queue });
|
|
402
|
+
case "match":
|
|
403
|
+
if (!options?.matchId)
|
|
404
|
+
throw new Error("Missing match ID: riotclient match <id>");
|
|
405
|
+
return client.matches.get(options.matchId);
|
|
406
|
+
case "mmr":
|
|
407
|
+
return client.matches.mmr();
|
|
408
|
+
case "rank-history":
|
|
409
|
+
return client.matches.rankHistory({ count: options?.count });
|
|
410
|
+
case "live":
|
|
411
|
+
return client.matches.live({ ranks: options?.ranks, loadouts: options?.loadouts });
|
|
412
|
+
case "matches-for":
|
|
413
|
+
return client.matches.listFor(requirePositional(pos, 1, "Usage: riotclient matches-for <puuid>"), { count: options?.count, queue: options?.queue });
|
|
414
|
+
case "mmr-for":
|
|
415
|
+
return client.matches.mmrFor(requirePositional(pos, 1, "Usage: riotclient mmr-for <puuid>"));
|
|
416
|
+
case "rank-history-for":
|
|
417
|
+
return client.matches.rankHistoryFor(requirePositional(pos, 1, "Usage: riotclient rank-history-for <puuid>"), { count: options?.count });
|
|
418
|
+
case "leaderboard":
|
|
419
|
+
return client.matches.leaderboard({
|
|
420
|
+
season: vals.season,
|
|
421
|
+
start: vals.start ? Number(vals.start) : undefined,
|
|
422
|
+
size: vals.size ? Number(vals.size) : undefined,
|
|
423
|
+
query: vals.query,
|
|
424
|
+
});
|
|
425
|
+
case "content":
|
|
426
|
+
return client.matches.content();
|
|
427
|
+
case "premier":
|
|
428
|
+
return client.matches.premier();
|
|
429
|
+
case "party":
|
|
430
|
+
return client.party.current();
|
|
431
|
+
case "queues":
|
|
432
|
+
return client.party.queues();
|
|
433
|
+
case "custom-game-configs":
|
|
434
|
+
return client.party.customGameConfigs();
|
|
435
|
+
default:
|
|
436
|
+
return UNKNOWN_COMMAND;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
async function executeSocialWriteCommand(client, command, yes, pos, vals) {
|
|
440
|
+
switch (command) {
|
|
441
|
+
case "send": {
|
|
442
|
+
const to = vals.to;
|
|
443
|
+
const text = vals.text;
|
|
444
|
+
if (!to || text === undefined) {
|
|
445
|
+
throw new ValidationError("invalid-argument", "Usage: riotclient send --to <puuid|name#tag|cid> --text <message>");
|
|
446
|
+
}
|
|
447
|
+
const target = parseTarget(to);
|
|
448
|
+
return yes ? client.social.sendMessage(target, text) : client.social.validateSendMessage(target, text);
|
|
449
|
+
}
|
|
450
|
+
case "friend-request": {
|
|
451
|
+
const riotId = requirePositional(pos, 1, "Usage: riotclient friend-request <name#tag>");
|
|
452
|
+
return yes ? client.social.sendFriendRequest(riotId) : client.social.validateSendFriendRequest(riotId);
|
|
453
|
+
}
|
|
454
|
+
case "friend-accept": {
|
|
455
|
+
const puuid = requirePositional(pos, 1, "Usage: riotclient friend-accept <puuid>");
|
|
456
|
+
return yes ? client.social.acceptFriendRequest(puuid) : client.social.validateAcceptFriendRequest(puuid);
|
|
457
|
+
}
|
|
458
|
+
case "friend-decline": {
|
|
459
|
+
const puuid = requirePositional(pos, 1, "Usage: riotclient friend-decline <puuid>");
|
|
460
|
+
return yes ? client.social.declineFriendRequest(puuid) : client.social.validateDeclineFriendRequest(puuid);
|
|
461
|
+
}
|
|
462
|
+
case "friend-cancel": {
|
|
463
|
+
const puuid = requirePositional(pos, 1, "Usage: riotclient friend-cancel <puuid>");
|
|
464
|
+
return yes ? client.social.cancelFriendRequest(puuid) : client.social.validateCancelFriendRequest(puuid);
|
|
465
|
+
}
|
|
466
|
+
case "friend-remove": {
|
|
467
|
+
const puuid = requirePositional(pos, 1, "Usage: riotclient friend-remove <puuid>");
|
|
468
|
+
return yes ? client.social.removeFriend(puuid) : client.social.validateRemoveFriend(puuid);
|
|
469
|
+
}
|
|
470
|
+
case "block": {
|
|
471
|
+
const target = requirePositional(pos, 1, "Usage: riotclient block <puuid|name#tag>");
|
|
472
|
+
return yes ? client.social.blockPlayer(target) : client.social.validateBlockPlayer(target);
|
|
473
|
+
}
|
|
474
|
+
case "unblock": {
|
|
475
|
+
const puuid = requirePositional(pos, 1, "Usage: riotclient unblock <puuid>");
|
|
476
|
+
return yes ? client.social.unblockPlayer(puuid) : client.social.validateUnblockPlayer(puuid);
|
|
477
|
+
}
|
|
478
|
+
default:
|
|
479
|
+
return UNKNOWN_COMMAND;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
async function executePrivacyCommand(client, yes, vals) {
|
|
483
|
+
const badgeVal = vals.badge ? parseBooleanFlag("badge", vals.badge) : undefined;
|
|
484
|
+
const lbVal = vals.leaderboard ? parseBooleanFlag("leaderboard", vals.leaderboard) : undefined;
|
|
485
|
+
if (badgeVal === undefined && lbVal === undefined) {
|
|
486
|
+
throw new ValidationError("invalid-argument", "Usage: riotclient privacy [--badge on|off] [--leaderboard on|off]");
|
|
487
|
+
}
|
|
488
|
+
const result = {};
|
|
489
|
+
if (badgeVal !== undefined) {
|
|
490
|
+
result.badge = yes
|
|
491
|
+
? await client.account.setActRankBadgeHidden(badgeVal)
|
|
492
|
+
: await client.account.validateSetActRankBadgeHidden(badgeVal);
|
|
493
|
+
}
|
|
494
|
+
if (lbVal !== undefined) {
|
|
495
|
+
result.leaderboard = yes
|
|
496
|
+
? await client.account.setLeaderboardAnonymized(lbVal)
|
|
497
|
+
: await client.account.validateSetLeaderboardAnonymized(lbVal);
|
|
498
|
+
}
|
|
499
|
+
return result;
|
|
500
|
+
}
|
|
501
|
+
async function executeAccountWriteCommand(client, command, yes, pos, vals) {
|
|
502
|
+
switch (command) {
|
|
503
|
+
case "equip": {
|
|
504
|
+
const change = parseEquipChange(vals);
|
|
505
|
+
return yes ? client.account.equip(change) : client.account.validateEquip(change);
|
|
506
|
+
}
|
|
507
|
+
case "equip-collection": {
|
|
508
|
+
const raw = pos.slice(1).join(",");
|
|
509
|
+
const skinUuids = raw.split(",").map((s) => s.trim()).filter(Boolean);
|
|
510
|
+
if (skinUuids.length === 0) {
|
|
511
|
+
throw new ValidationError("invalid-argument", "Usage: riotclient equip-collection <skinUuid,...>");
|
|
512
|
+
}
|
|
513
|
+
return yes ? client.account.equipCollection(skinUuids) : client.account.validateEquipCollection(skinUuids);
|
|
514
|
+
}
|
|
515
|
+
case "contract-activate": {
|
|
516
|
+
const uuid = requirePositional(pos, 1, "Usage: riotclient contract-activate <uuid>");
|
|
517
|
+
return yes ? client.account.activateContract(uuid) : client.account.validateActivateContract(uuid);
|
|
518
|
+
}
|
|
519
|
+
case "favourite-add": {
|
|
520
|
+
const skin = requirePositional(pos, 1, "Usage: riotclient favourite-add <skin>");
|
|
521
|
+
return yes ? client.account.addFavourite(skin) : client.account.validateAddFavourite(skin);
|
|
522
|
+
}
|
|
523
|
+
case "favourite-remove": {
|
|
524
|
+
const skin = requirePositional(pos, 1, "Usage: riotclient favourite-remove <skin>");
|
|
525
|
+
return yes ? client.account.removeFavourite(skin) : client.account.validateRemoveFavourite(skin);
|
|
526
|
+
}
|
|
527
|
+
case "privacy":
|
|
528
|
+
return executePrivacyCommand(client, yes, vals);
|
|
529
|
+
default:
|
|
530
|
+
return UNKNOWN_COMMAND;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
async function executeBuyCommand(client, yes, vals) {
|
|
534
|
+
const offer = vals.offer;
|
|
535
|
+
const bundle = vals.bundle;
|
|
536
|
+
if (!offer && !bundle) {
|
|
537
|
+
throw new ValidationError("invalid-argument", "Usage: riotclient buy (--offer <id> | --bundle <id>) [--yes --confirm]");
|
|
538
|
+
}
|
|
539
|
+
const target = offer ? { offerId: offer } : { bundleId: bundle };
|
|
540
|
+
if (!yes) {
|
|
541
|
+
return client.store.validateBuy(target, { confirm: true });
|
|
542
|
+
}
|
|
543
|
+
if (!vals.confirm) {
|
|
544
|
+
throw new ValidationError("confirm-required", "Purchase confirmation required: pass --confirm with --yes");
|
|
545
|
+
}
|
|
546
|
+
return client.store.buy(target, { confirm: true });
|
|
547
|
+
}
|
|
548
|
+
async function executeStoreWriteCommand(client, command, yes, vals) {
|
|
549
|
+
switch (command) {
|
|
550
|
+
case "night-market-reveal":
|
|
551
|
+
return yes ? client.store.revealNightMarket() : client.store.validateRevealNightMarket();
|
|
552
|
+
case "buy":
|
|
553
|
+
return executeBuyCommand(client, yes, vals);
|
|
554
|
+
default:
|
|
555
|
+
return UNKNOWN_COMMAND;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
async function executePartyCommand(client, command, options) {
|
|
559
|
+
const yes = Boolean(options?.yes);
|
|
560
|
+
const pos = options?.positionals ?? [];
|
|
561
|
+
const vals = options?.rawValues ?? {};
|
|
562
|
+
switch (command) {
|
|
563
|
+
case "party-invite": {
|
|
564
|
+
const riotId = requirePositional(pos, 1, "Usage: riotclient party-invite <name#tag>");
|
|
565
|
+
return yes ? client.party.invite(riotId) : client.party.validateInvite(riotId);
|
|
566
|
+
}
|
|
567
|
+
case "party-kick": {
|
|
568
|
+
const puuid = requirePositional(pos, 1, "Usage: riotclient party-kick <puuid>");
|
|
569
|
+
return yes ? client.party.kick(puuid) : client.party.validateKick(puuid);
|
|
570
|
+
}
|
|
571
|
+
case "party-promote": {
|
|
572
|
+
const puuid = requirePositional(pos, 1, "Usage: riotclient party-promote <puuid>");
|
|
573
|
+
return yes ? client.party.promote(puuid) : client.party.validatePromote(puuid);
|
|
574
|
+
}
|
|
575
|
+
case "party-code":
|
|
576
|
+
return vals.revoke
|
|
577
|
+
? (yes ? client.party.revokeInviteCode() : client.party.validateRevokeInviteCode())
|
|
578
|
+
: (yes ? client.party.createInviteCode() : client.party.validateCreateInviteCode());
|
|
579
|
+
case "party-join": {
|
|
580
|
+
const target = requirePositional(pos, 1, "Usage: riotclient party-join <partyId|code>");
|
|
581
|
+
const isPartyId = target.includes("-") || target.length >= 32;
|
|
582
|
+
if (isPartyId) {
|
|
583
|
+
return yes ? client.party.join(target) : client.party.validateJoin(target);
|
|
584
|
+
}
|
|
585
|
+
return yes ? client.party.joinByCode(target) : client.party.validateJoinByCode(target);
|
|
586
|
+
}
|
|
587
|
+
case "party-ready": {
|
|
588
|
+
const ready = parseBooleanFlag("ready", requirePositional(pos, 1, "Usage: riotclient party-ready on|off"));
|
|
589
|
+
return yes ? client.party.setReady(Boolean(ready)) : client.party.validateSetReady(Boolean(ready));
|
|
590
|
+
}
|
|
591
|
+
case "party-queue": {
|
|
592
|
+
const queue = requirePositional(pos, 1, "Usage: riotclient party-queue <queue>");
|
|
593
|
+
return yes ? client.party.setQueue(queue) : client.party.validateSetQueue(queue);
|
|
594
|
+
}
|
|
595
|
+
case "party-access": {
|
|
596
|
+
const access = requirePositional(pos, 1, "Usage: riotclient party-access open|closed").toLowerCase();
|
|
597
|
+
if (access !== "open" && access !== "closed") {
|
|
598
|
+
throw new ValidationError("invalid-argument", "Usage: riotclient party-access open|closed");
|
|
599
|
+
}
|
|
600
|
+
return yes ? client.party.setAccessibility(access) : client.party.validateSetAccessibility(access);
|
|
601
|
+
}
|
|
602
|
+
case "party-start":
|
|
603
|
+
return yes ? client.party.startMatchmaking() : client.party.validateStartMatchmaking();
|
|
604
|
+
case "party-stop":
|
|
605
|
+
return yes ? client.party.stopMatchmaking() : client.party.validateStopMatchmaking();
|
|
606
|
+
case "party-leave":
|
|
607
|
+
return yes ? client.party.leave() : client.party.validateLeave();
|
|
608
|
+
default:
|
|
609
|
+
return UNKNOWN_COMMAND;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
async function executeWriteCommand(client, command, options) {
|
|
613
|
+
const yes = Boolean(options?.yes);
|
|
614
|
+
const pos = options?.positionals ?? [];
|
|
615
|
+
const vals = options?.rawValues ?? {};
|
|
616
|
+
const acc = await executeAccountWriteCommand(client, command, yes, pos, vals);
|
|
617
|
+
if (acc !== UNKNOWN_COMMAND)
|
|
618
|
+
return acc;
|
|
619
|
+
const soc = await executeSocialWriteCommand(client, command, yes, pos, vals);
|
|
620
|
+
if (soc !== UNKNOWN_COMMAND)
|
|
621
|
+
return soc;
|
|
622
|
+
return executeStoreWriteCommand(client, command, yes, vals);
|
|
623
|
+
}
|
|
624
|
+
async function executePartyExtraCommand(client, command, yes, pos) {
|
|
625
|
+
switch (command) {
|
|
626
|
+
case "party-invites":
|
|
627
|
+
return client.party.invites();
|
|
628
|
+
case "party-requests":
|
|
629
|
+
return client.party.requests();
|
|
630
|
+
case "party-decline-invite": {
|
|
631
|
+
const id = requirePositional(pos, 1, "Usage: riotclient party-decline-invite <id>");
|
|
632
|
+
return yes ? client.party.declineInvite(id) : client.party.validateDeclineInvite(id);
|
|
633
|
+
}
|
|
634
|
+
case "party-request": {
|
|
635
|
+
const id = requirePositional(pos, 1, "Usage: riotclient party-request <partyId>");
|
|
636
|
+
return yes ? client.party.requestToJoin(id) : client.party.validateRequestToJoin(id);
|
|
637
|
+
}
|
|
638
|
+
case "party-decline-request": {
|
|
639
|
+
const id = requirePositional(pos, 1, "Usage: riotclient party-decline-request <id>");
|
|
640
|
+
return yes ? client.party.declineRequest(id) : client.party.validateDeclineRequest(id);
|
|
641
|
+
}
|
|
642
|
+
case "party-default": {
|
|
643
|
+
const queue = requirePositional(pos, 1, "Usage: riotclient party-default <queue>");
|
|
644
|
+
return yes ? client.party.makeDefault(queue) : client.party.validateMakeDefault(queue);
|
|
645
|
+
}
|
|
646
|
+
case "party-servers": {
|
|
647
|
+
const raw = requirePositional(pos, 1, "Usage: riotclient party-servers <id,...>");
|
|
648
|
+
const ids = raw.split(",").map((s) => s.trim()).filter(Boolean);
|
|
649
|
+
return yes ? client.party.setPreferredServers(ids) : client.party.validateSetPreferredServers(ids);
|
|
650
|
+
}
|
|
651
|
+
case "party-moderator": {
|
|
652
|
+
const puuid = requirePositional(pos, 1, "Usage: riotclient party-moderator <puuid> on|off");
|
|
653
|
+
const mod = parseBooleanFlag("moderator", requirePositional(pos, 2, "Usage: riotclient party-moderator <puuid> on|off"));
|
|
654
|
+
return yes ? client.party.setModerator(puuid, Boolean(mod)) : client.party.validateSetModerator(puuid, Boolean(mod));
|
|
655
|
+
}
|
|
656
|
+
case "party-refresh":
|
|
657
|
+
return yes ? client.party.refresh() : client.party.validateRefresh();
|
|
658
|
+
default:
|
|
659
|
+
return UNKNOWN_COMMAND;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
function parseCustomGameRules(vals) {
|
|
663
|
+
const ruleList = Array.isArray(vals.rule) ? vals.rule : vals.rule ? [String(vals.rule)] : [];
|
|
664
|
+
const rules = {};
|
|
665
|
+
for (const r of ruleList) {
|
|
666
|
+
const idx = r.indexOf("=");
|
|
667
|
+
if (idx !== -1) {
|
|
668
|
+
const k = r.slice(0, idx);
|
|
669
|
+
const v = r.slice(idx + 1);
|
|
670
|
+
rules[k] = v === "true" ? true : v === "false" ? false : isNaN(Number(v)) ? v : Number(v);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return rules;
|
|
674
|
+
}
|
|
675
|
+
async function executeCustomGameCommand(client, command, yes, pos, vals) {
|
|
676
|
+
switch (command) {
|
|
677
|
+
case "custom-game":
|
|
678
|
+
return yes ? client.party.makeCustomGame() : client.party.validateMakeCustomGame();
|
|
679
|
+
case "custom-game-settings": {
|
|
680
|
+
const map = vals.map;
|
|
681
|
+
const mode = vals.mode;
|
|
682
|
+
if (!map || !mode) {
|
|
683
|
+
throw new ValidationError("invalid-argument", "Usage: riotclient custom-game-settings --map <name> --mode <name> [--server <id>] [--rule k=v...]");
|
|
684
|
+
}
|
|
685
|
+
const settings = {
|
|
686
|
+
map,
|
|
687
|
+
mode,
|
|
688
|
+
server: vals.server ? String(vals.server) : null,
|
|
689
|
+
rules: parseCustomGameRules(vals),
|
|
690
|
+
};
|
|
691
|
+
return yes
|
|
692
|
+
? client.party.setCustomGameSettings(settings)
|
|
693
|
+
: client.party.validateSetCustomGameSettings(settings);
|
|
694
|
+
}
|
|
695
|
+
case "custom-game-team": {
|
|
696
|
+
const puuid = requirePositional(pos, 1, "Usage: riotclient custom-game-team <puuid> <team>");
|
|
697
|
+
const team = requirePositional(pos, 2, "Usage: riotclient custom-game-team <puuid> <team>");
|
|
698
|
+
return yes ? client.party.setTeam(puuid, team) : client.party.validateSetTeam(puuid, team);
|
|
699
|
+
}
|
|
700
|
+
case "custom-game-start":
|
|
701
|
+
return yes ? client.party.startCustomGame() : client.party.validateStartCustomGame();
|
|
702
|
+
case "custom-game-balance":
|
|
703
|
+
return yes ? client.party.balanceTeams() : client.party.validateBalanceTeams();
|
|
704
|
+
default:
|
|
705
|
+
return UNKNOWN_COMMAND;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
async function executeMatchActionCommand(client, command, yes, pos, vals) {
|
|
709
|
+
switch (command) {
|
|
710
|
+
case "agent-select": {
|
|
711
|
+
const agent = requirePositional(pos, 1, "Usage: riotclient agent-select <uuid|name>");
|
|
712
|
+
return yes ? client.matches.selectAgent(agent) : client.matches.validateSelectAgent(agent);
|
|
713
|
+
}
|
|
714
|
+
case "agent-lock": {
|
|
715
|
+
const agent = requirePositional(pos, 1, "Usage: riotclient agent-lock <uuid|name>");
|
|
716
|
+
return yes ? client.matches.lockAgent(agent) : client.matches.validateLockAgent(agent);
|
|
717
|
+
}
|
|
718
|
+
case "dodge": {
|
|
719
|
+
if (!yes) {
|
|
720
|
+
return client.matches.validateDodge({ confirm: true }).catch(async () => {
|
|
721
|
+
return { method: "POST", path: "/pregame/v1/matches/{matchId}/quit" };
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
if (!vals.confirm) {
|
|
725
|
+
throw new ValidationError("confirm-required", "Dodge requires explicit confirmation: pass --confirm with --yes");
|
|
726
|
+
}
|
|
727
|
+
return client.matches.dodge({ confirm: true });
|
|
728
|
+
}
|
|
729
|
+
case "leave-match": {
|
|
730
|
+
if (!yes) {
|
|
731
|
+
return client.matches.validateLeaveMatch({ confirm: true }).catch(async () => {
|
|
732
|
+
return { method: "POST", path: "/core-game/v1/players/{puuid}/disassociate/{matchId}" };
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
if (!vals.confirm) {
|
|
736
|
+
throw new ValidationError("confirm-required", "Leaving match requires explicit confirmation: pass --confirm with --yes");
|
|
737
|
+
}
|
|
738
|
+
return client.matches.leaveMatch({ confirm: true });
|
|
739
|
+
}
|
|
740
|
+
default:
|
|
741
|
+
return UNKNOWN_COMMAND;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
async function executeSettingsCommand(client, command, yes, pos, vals) {
|
|
745
|
+
if (command !== "settings-save")
|
|
746
|
+
return UNKNOWN_COMMAND;
|
|
747
|
+
const filePath = requirePositional(pos, 1, "Usage: riotclient settings-save <file.json> [--yes --confirm]");
|
|
748
|
+
const content = JSON.parse(readFileSync(filePath, "utf-8"));
|
|
749
|
+
if (!yes) {
|
|
750
|
+
return client.account.validateSaveSettings(content, { confirm: true });
|
|
751
|
+
}
|
|
752
|
+
if (!vals.confirm) {
|
|
753
|
+
throw new ValidationError("confirm-required", "Settings save requires explicit confirmation: pass --confirm with --yes");
|
|
754
|
+
}
|
|
755
|
+
return client.account.saveSettings(content, { confirm: true });
|
|
756
|
+
}
|
|
757
|
+
async function executeRawCommand(client, command, pos, vals) {
|
|
758
|
+
if (command !== "local" && command !== "riot")
|
|
759
|
+
return UNKNOWN_COMMAND;
|
|
760
|
+
const method = requirePositional(pos, 1, `Usage: riotclient ${command} <get|post|put|delete> <path|url> [--body json]`).toLowerCase();
|
|
761
|
+
const target = requirePositional(pos, 2, `Usage: riotclient ${command} <get|post|put|delete> <path|url> [--body json]`);
|
|
762
|
+
const body = vals.body
|
|
763
|
+
? typeof vals.body === "string"
|
|
764
|
+
? JSON.parse(vals.body)
|
|
765
|
+
: vals.body
|
|
766
|
+
: undefined;
|
|
767
|
+
const targetApi = command === "local" ? client.local : client.riot;
|
|
768
|
+
switch (method) {
|
|
769
|
+
case "get":
|
|
770
|
+
return targetApi.get(target);
|
|
771
|
+
case "post":
|
|
772
|
+
return targetApi.post(target, body);
|
|
773
|
+
case "put":
|
|
774
|
+
return targetApi.put(target, body);
|
|
775
|
+
case "delete":
|
|
776
|
+
return targetApi.delete(target, body);
|
|
777
|
+
default:
|
|
778
|
+
throw new ValidationError("invalid-argument", `Unknown HTTP method: ${method}. Expected get, post, put, or delete`);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
async function executeCommand(client, command, options) {
|
|
782
|
+
const pos = options?.positionals ?? [];
|
|
783
|
+
const vals = options?.rawValues ?? {};
|
|
784
|
+
const yes = Boolean(options?.yes);
|
|
785
|
+
const std = await executeStandardCommand(client, command, options);
|
|
786
|
+
if (std !== UNKNOWN_COMMAND)
|
|
787
|
+
return std;
|
|
788
|
+
const game = await executeGameCommand(client, command, options);
|
|
789
|
+
if (game !== UNKNOWN_COMMAND)
|
|
790
|
+
return game;
|
|
791
|
+
const party = await executePartyCommand(client, command, options);
|
|
792
|
+
if (party !== UNKNOWN_COMMAND)
|
|
793
|
+
return party;
|
|
794
|
+
const partyExtra = await executePartyExtraCommand(client, command, yes, pos);
|
|
795
|
+
if (partyExtra !== UNKNOWN_COMMAND)
|
|
796
|
+
return partyExtra;
|
|
797
|
+
const custom = await executeCustomGameCommand(client, command, yes, pos, vals);
|
|
798
|
+
if (custom !== UNKNOWN_COMMAND)
|
|
799
|
+
return custom;
|
|
800
|
+
const matchAct = await executeMatchActionCommand(client, command, yes, pos, vals);
|
|
801
|
+
if (matchAct !== UNKNOWN_COMMAND)
|
|
802
|
+
return matchAct;
|
|
803
|
+
const raw = await executeRawCommand(client, command, pos, vals);
|
|
804
|
+
if (raw !== UNKNOWN_COMMAND)
|
|
805
|
+
return raw;
|
|
806
|
+
const setts = await executeSettingsCommand(client, command, yes, pos, vals);
|
|
807
|
+
if (setts !== UNKNOWN_COMMAND)
|
|
808
|
+
return setts;
|
|
809
|
+
return executeWriteCommand(client, command, options);
|
|
810
|
+
}
|
|
811
|
+
export async function runCli(args) {
|
|
812
|
+
const parsed = parseArgs({
|
|
813
|
+
args,
|
|
814
|
+
options: {
|
|
815
|
+
cid: { type: "string" },
|
|
816
|
+
count: { type: "string" },
|
|
817
|
+
queue: { type: "string" },
|
|
818
|
+
ranks: { type: "boolean", default: false },
|
|
819
|
+
"no-loadouts": { type: "boolean", default: false },
|
|
820
|
+
loadouts: { type: "boolean" },
|
|
821
|
+
language: { type: "string" },
|
|
822
|
+
cache: { type: "string" },
|
|
823
|
+
only: { type: "string" },
|
|
824
|
+
raw: { type: "boolean", default: false },
|
|
825
|
+
pretty: { type: "boolean", default: false },
|
|
826
|
+
help: { type: "boolean", default: false },
|
|
827
|
+
version: { type: "boolean", default: false },
|
|
828
|
+
yes: { type: "boolean", default: false },
|
|
829
|
+
revoke: { type: "boolean", default: false },
|
|
830
|
+
to: { type: "string" },
|
|
831
|
+
text: { type: "string" },
|
|
832
|
+
gun: { type: "string", multiple: true },
|
|
833
|
+
buddy: { type: "string", multiple: true },
|
|
834
|
+
spray: { type: "string", multiple: true },
|
|
835
|
+
card: { type: "string" },
|
|
836
|
+
title: { type: "string" },
|
|
837
|
+
flex: { type: "string" },
|
|
838
|
+
border: { type: "string" },
|
|
839
|
+
"level-border": { type: "string" },
|
|
840
|
+
incognito: { type: "string" },
|
|
841
|
+
"hide-level": { type: "string" },
|
|
842
|
+
"hide-account-level": { type: "string" },
|
|
843
|
+
season: { type: "string" },
|
|
844
|
+
start: { type: "string" },
|
|
845
|
+
size: { type: "string" },
|
|
846
|
+
query: { type: "string" },
|
|
847
|
+
offer: { type: "string" },
|
|
848
|
+
bundle: { type: "string" },
|
|
849
|
+
confirm: { type: "boolean", default: false },
|
|
850
|
+
badge: { type: "string" },
|
|
851
|
+
leaderboard: { type: "string" },
|
|
852
|
+
map: { type: "string" },
|
|
853
|
+
mode: { type: "string" },
|
|
854
|
+
server: { type: "string" },
|
|
855
|
+
rule: { type: "string", multiple: true },
|
|
856
|
+
body: { type: "string" },
|
|
857
|
+
},
|
|
858
|
+
allowPositionals: true,
|
|
859
|
+
});
|
|
860
|
+
if (parsed.values.version) {
|
|
861
|
+
process.stdout.write(`${packageJson.version}\n`);
|
|
862
|
+
return 0;
|
|
863
|
+
}
|
|
864
|
+
if (parsed.values.help || parsed.positionals.length === 0) {
|
|
865
|
+
process.stdout.write(USAGE);
|
|
866
|
+
return 0;
|
|
867
|
+
}
|
|
868
|
+
const command = parsed.positionals[0];
|
|
869
|
+
const cacheSeconds = Number(parsed.values.cache ?? 0);
|
|
870
|
+
const client = new RiotClient({
|
|
871
|
+
language: parsed.values.language,
|
|
872
|
+
responseCache: cacheSeconds > 0 ? { ttlMs: cacheSeconds * 1000 } : undefined,
|
|
873
|
+
});
|
|
874
|
+
try {
|
|
875
|
+
if (command === "watch") {
|
|
876
|
+
return await runWatch(client, {
|
|
877
|
+
only: parsed.values.only,
|
|
878
|
+
raw: parsed.values.raw,
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
const count = parsed.values.count ? Number(parsed.values.count) : undefined;
|
|
882
|
+
const loadouts = parsed.values["no-loadouts"] ? false : (parsed.values.loadouts ?? true);
|
|
883
|
+
const result = await executeCommand(client, command, {
|
|
884
|
+
language: parsed.values.language,
|
|
885
|
+
cid: parsed.values.cid,
|
|
886
|
+
count,
|
|
887
|
+
queue: parsed.values.queue,
|
|
888
|
+
ranks: Boolean(parsed.values.ranks),
|
|
889
|
+
loadouts,
|
|
890
|
+
matchId: command === "match" ? parsed.positionals[1] : undefined,
|
|
891
|
+
yes: Boolean(parsed.values.yes),
|
|
892
|
+
positionals: parsed.positionals,
|
|
893
|
+
rawValues: parsed.values,
|
|
894
|
+
});
|
|
895
|
+
if (result === UNKNOWN_COMMAND) {
|
|
896
|
+
process.stderr.write(`Unknown command: ${command}\n\n${USAGE}`);
|
|
897
|
+
return 1;
|
|
898
|
+
}
|
|
899
|
+
const output = parsed.values.pretty ? JSON.stringify(result, null, 2) : JSON.stringify(result);
|
|
900
|
+
process.stdout.write(`${output}\n`);
|
|
901
|
+
return 0;
|
|
902
|
+
}
|
|
903
|
+
catch (error) {
|
|
904
|
+
const formatted = formatError(error);
|
|
905
|
+
process.stderr.write(`${JSON.stringify(formatted)}\n`);
|
|
906
|
+
return exitCodeForError(error);
|
|
907
|
+
}
|
|
908
|
+
finally {
|
|
909
|
+
await client.close();
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
//# sourceMappingURL=cli.js.map
|