token helper: render auth link as a scannable QR PNG
Some checks failed
Release / semantic-release (push) Successful in 26s
tests / Unit tests (Linux, Python 3.11) (push) Successful in 9m54s
Release / build-linux (push) Failing after 7m13s
Release / build-windows (push) Has been cancelled
Release / build-macos (arm64, macos-latest) (push) Has been cancelled
Release / build-macos (x64, macos-15-intel) (push) Has been cancelled
Release / release-main (push) Has been cancelled
Release / release-develop (push) Has been cancelled

get-token.ts now writes the Remote Auth URL as a 512x512 QR image
(/tmp/javis_qr.png, override via QR_OUT) in addition to printing the link, so
it can be sent to the user and scanned from a second screen with the Discord
mobile app. Adds the qrcode dependency.
This commit is contained in:
javis-bot
2026-06-09 21:03:31 +09:00
parent f80a6fa0ba
commit 7aac92fc2c
3 changed files with 22 additions and 5 deletions

View File

@@ -18,11 +18,14 @@
*/
import { readFileSync, writeFileSync, existsSync } from "node:fs";
import { fileURLToPath } from "node:url";
import QRCode from "qrcode";
// Optional native peer dep; only needed for this helper.
// @ts-ignore - provided by discord.js-selfbot-v13 (optionalDependency)
import { DiscordAuthWebsocket } from "discord.js-selfbot-v13";
const ENV_PATH = fileURLToPath(new URL("../../.env", import.meta.url));
// Where to write the scannable QR image (so it can be sent to the user).
const QR_OUT = process.env.QR_OUT || "/tmp/javis_qr.png";
function upsertEnv(key: string, value: string) {
let lines: string[] = [];
@@ -41,11 +44,19 @@ function upsertEnv(key: string, value: string) {
async function main() {
const ws: any = new DiscordAuthWebsocket();
ws.on("ready", () => {
ws.on("ready", async () => {
// Render the auth URL as a scannable QR PNG. Show it on a SECOND screen
// (PC monitor) and scan it with the Discord mobile app's QR scanner.
try {
await QRCode.toFile(QR_OUT, ws.AuthURL, { width: 512, margin: 2 });
} catch (e) {
console.error("QR 생성 실패:", e);
}
console.log("\n================ DISCORD REMOTE LOGIN ================");
console.log("아래 링크를 디스코드 앱이 깔린 폰에서 여세요 (버너 계정으로 로그인된 상태!):");
console.log("\nAUTH_URL: " + ws.AuthURL + "\n");
console.log("열면 '새 기기 로그인' 승인 화면이 뜹니다. 승인하면 토큰이 자동 저장됩니다.");
console.log("QR_IMAGE: " + QR_OUT);
console.log("AUTH_URL: " + ws.AuthURL);
console.log("\nPC/두 번째 화면에 위 QR을 띄우고, 디스코드 모바일 앱의 QR 스캐너로 스캔하세요");
console.log("(버너 계정으로 로그인된 상태!). 승인하면 토큰이 자동 저장됩니다.");
console.log("링크는 약 2분 후 만료됩니다.");
console.log("=====================================================\n");
});