Skip to content

OpenDiscussionCommandHandler

Opens a new discussion in the plugin’s repository. Unavailable when Discussions is disabled.

See the community commands guide and behavioral tests.

Import:

import { OpenDiscussionCommandHandler } from '@mnaoumov/obsidian-lib/command-handlers/open-discussion-command-handler';

Signature:

export class OpenDiscussionCommandHandler extends OpenGitHubCommandHandler

Extends: OpenGitHubCommandHandler

Constructor

new OpenDiscussionCommandHandler(params: OpenDiscussionCommandHandlerConstructorParams)

Constructs a new instance.

Properties

PropertyTypeDescription
gitHubRepostringThe plugin's repository, as owner/name.
(Inherited from OpenGitHubCommandHandler)
iconIconNameThe icon for the command.
(Inherited from OpenGitHubCommandHandler)
idstringThe ID of the command.
(Inherited from OpenGitHubCommandHandler)
namestringThe display name of the command.
(Inherited from OpenGitHubCommandHandler)

Methods

MethodReturnsDescription
buildCommand()CommandBuilds a plain Obsidian Command object with a checkCallback.
(Inherited from OpenGitHubCommandHandler)
canExecute()booleanChecks the repository's declared Discussions capability.
execute()Promise<void>Opens the page in the browser when the command is available.
(Inherited from OpenGitHubCommandHandler)
getUrl()stringBuilds the new-discussion URL.
onRegistered(context)Promise<void>Called after the command has been registered with Obsidian. Subclasses use the provided context to register menu event handlers.

Throws when the same instance is registered twice. A handler stores per-registration state — the plugin name here, the active-file provider and the submenu override in AbstractFileCommandHandler, plus whatever a subclass records — and the menu closures registered here read that state lazily, at menu-render time. So a second registration silently rewrites what the first registration's closures will see. CommandHandlerComponent registers a handler set once per menu surface, which is why CommandHandlerFactory must build FRESH instances on every call; this guard turns a factory that hands out shared instances into a loud failure instead of a wrong context menu.
(Inherited from OpenGitHubCommandHandler)

Links to this page: