项目文件夹

文件
wehub-resource-sync 9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:48 +08:00

39 行
1.4 KiB
JavaScript

import { cli, Strategy } from '@jackwener/opencli/registry';
import {
navigateToDiscordTarget,
parsePositiveInt,
resolveDiscordChannelTarget,
} from './utils.js';
export const gotoCommand = cli({
site: 'discord-app',
name: 'goto',
access: 'read',
description: 'Open a Discord channel by id/name/url without sending messages',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [
{ name: 'guild', required: false, help: 'Guild/server id or visible name' },
{ name: 'channel', required: false, help: 'Channel id or visible name' },
{ name: 'url', required: false, help: 'Discord channel URL' },
{ name: 'timeout', required: false, default: '8', help: 'Seconds to wait for Discord to show the route (default: 8)' },
],
columns: ['Status', 'guild_id', 'channel_id', 'url'],
func: async (page, kwargs) => {
const timeoutSeconds = parsePositiveInt(kwargs.timeout, 8, 'timeout');
const target = await resolveDiscordChannelTarget(page, kwargs, { required: true });
await navigateToDiscordTarget(page, target, { timeoutMs: timeoutSeconds * 1000 });
return [{
Status: 'Opened',
guild_id: target.guild_id,
channel_id: target.channel_id,
url: target.url,
}];
},
});
export const __test__ = {
gotoCommand,
};