|
| 1 | +module.exports = { |
| 2 | + name: "mimo", |
| 3 | + description: "Manually run Traveling Mimo automation for all games or a specific game.", |
| 4 | + params: [ |
| 5 | + { |
| 6 | + name: "game", |
| 7 | + description: "The game you want to run Mimo for. Leave empty for all games.", |
| 8 | + type: "string", |
| 9 | + choices: [ |
| 10 | + { name: "All Games", value: "all" }, |
| 11 | + { name: "Honkai: Star Rail", value: "starrail" }, |
| 12 | + { name: "Zenless Zone Zero", value: "nap" } |
| 13 | + ], |
| 14 | + required: false |
| 15 | + } |
| 16 | + ], |
| 17 | + run: (async function mimo (context, game) { |
| 18 | + const { interaction } = context; |
| 19 | + |
| 20 | + const gameMapping = { |
| 21 | + zenless: "nap", |
| 22 | + zzz: "nap", |
| 23 | + hsr: "starrail" |
| 24 | + }; |
| 25 | + |
| 26 | + if (game) { |
| 27 | + game = gameMapping[game.toLowerCase()] || game.toLowerCase(); |
| 28 | + } |
| 29 | + |
| 30 | + const supportedGames = ["starrail", "nap"]; |
| 31 | + const gamesToRun = game && game !== "all" |
| 32 | + ? [game].filter(g => supportedGames.includes(g)) |
| 33 | + : supportedGames; |
| 34 | + |
| 35 | + if (gamesToRun.length === 0) { |
| 36 | + const message = "Invalid game specified. Supported games are: Star Rail, ZZZ"; |
| 37 | + return interaction |
| 38 | + ? interaction.reply({ content: message, ephemeral: true }) |
| 39 | + : { success: false, reply: message }; |
| 40 | + } |
| 41 | + |
| 42 | + if (interaction) { |
| 43 | + await interaction.deferReply({ ephemeral: true }); |
| 44 | + } |
| 45 | + |
| 46 | + const results = []; |
| 47 | + const errors = []; |
| 48 | + |
| 49 | + for (const gameName of gamesToRun) { |
| 50 | + const accounts = app.HoyoLab.getActiveAccounts({ whitelist: gameName }); |
| 51 | + if (accounts.length === 0) { |
| 52 | + continue; |
| 53 | + } |
| 54 | + |
| 55 | + const gamePlatform = app.HoyoLab.get(gameName); |
| 56 | + if (!gamePlatform || typeof gamePlatform.mimo !== "function") { |
| 57 | + errors.push({ game: gameName, error: "Mimo not supported" }); |
| 58 | + continue; |
| 59 | + } |
| 60 | + |
| 61 | + for (const account of accounts) { |
| 62 | + try { |
| 63 | + app.Logger.info("Command:Mimo", `Running Mimo for ${gameName} - ${account.uid}`); |
| 64 | + |
| 65 | + const result = await gamePlatform.mimo(account); |
| 66 | + if (!result.success) { |
| 67 | + errors.push({ |
| 68 | + game: gameName, |
| 69 | + uid: account.uid, |
| 70 | + error: result.message || "Unknown error" |
| 71 | + }); |
| 72 | + continue; |
| 73 | + } |
| 74 | + |
| 75 | + results.push({ |
| 76 | + game: gameName, |
| 77 | + uid: account.uid, |
| 78 | + nickname: account.nickname, |
| 79 | + ...result.data |
| 80 | + }); |
| 81 | + } |
| 82 | + catch (e) { |
| 83 | + app.Logger.error("Command:Mimo", { |
| 84 | + message: "Mimo automation failed", |
| 85 | + game: gameName, |
| 86 | + uid: account.uid, |
| 87 | + error: e.message |
| 88 | + }); |
| 89 | + errors.push({ |
| 90 | + game: gameName, |
| 91 | + uid: account.uid, |
| 92 | + error: e.message |
| 93 | + }); |
| 94 | + } |
| 95 | + } |
| 96 | + } |
| 97 | + |
| 98 | + if (results.length === 0 && errors.length === 0) { |
| 99 | + const message = "No accounts found with Mimo enabled."; |
| 100 | + return interaction |
| 101 | + ? interaction.editReply({ content: message }) |
| 102 | + : { success: false, reply: message }; |
| 103 | + } |
| 104 | + |
| 105 | + // Build response |
| 106 | + const summaryLines = ["🐾 **Traveling Mimo Results**\n"]; |
| 107 | + |
| 108 | + for (const r of results) { |
| 109 | + const gameShort = { genshin: "GI", starrail: "HSR", nap: "ZZZ" }[r.game] || r.game; |
| 110 | + summaryLines.push(`**${gameShort}** - ${r.nickname} (${r.uid})`); |
| 111 | + |
| 112 | + if (r.tasksClaimed.length > 0) { |
| 113 | + const totalPoints = r.tasksClaimed.reduce((sum, t) => sum + t.points, 0); |
| 114 | + summaryLines.push(` 🎯 Tasks Claimed: ${r.tasksClaimed.length} (+${totalPoints} pts)`); |
| 115 | + } |
| 116 | + |
| 117 | + if (r.tasksFinished.length > 0) { |
| 118 | + summaryLines.push(` ✅ Tasks Finished: ${r.tasksFinished.length}`); |
| 119 | + } |
| 120 | + |
| 121 | + if (r.itemsExchanged.length > 0) { |
| 122 | + summaryLines.push(` 🎁 Items Exchanged: ${r.itemsExchanged.map(i => i.name).join(", ")}`); |
| 123 | + } |
| 124 | + |
| 125 | + if (r.codesRedeemed.length > 0) { |
| 126 | + summaryLines.push(` 🔑 Codes Redeemed: ${r.codesRedeemed.join(", ")}`); |
| 127 | + } |
| 128 | + |
| 129 | + summaryLines.push(` 💎 Current Points: ${r.points}`, ""); |
| 130 | + } |
| 131 | + |
| 132 | + if (errors.length > 0) { |
| 133 | + summaryLines.push("**❌ Errors:**"); |
| 134 | + for (const e of errors) { |
| 135 | + summaryLines.push(` • ${e.game} ${e.uid ? `(${e.uid})` : ""}: ${e.error}`); |
| 136 | + } |
| 137 | + } |
| 138 | + |
| 139 | + const summary = summaryLines.join("\n").slice(0, 2000); |
| 140 | + |
| 141 | + if (interaction) { |
| 142 | + await interaction.editReply({ content: summary }); |
| 143 | + return; |
| 144 | + } |
| 145 | + |
| 146 | + return { success: true, reply: summary }; |
| 147 | + }) |
| 148 | +}; |
0 commit comments