Star ✨ on GitHub

SponsorBlockPlugin

API reference for the SponsorBlockPlugin in Moonlink.js

SponsorBlockPlugin Class

The SponsorBlockPlugin integrates with the SponsorBlock Lavalink plugin to provide functionality for skipping sponsored segments in YouTube videos. It also handles loading and starting chapters.

Properties

PropertyTypeDescription
namestringThe name of the plugin: sponsorblock-plugin.
capabilitiesstring[]Currently empty, but can declare capabilities related to SponsorBlock.
nodeNodeThe associated Node instance.

Methods

load

loadmethod

Load Plugin

Initializes the plugin for a given node.

Parameters
noderequiredNode
The node instance.

Returns & Example

Returnsvoid

// Called internally by PluginManager

::

unload

unloadmethod

Unload Plugin

Cleans up plugin resources.

Parameters
noderequiredNode
The node instance.

Returns & Example

Returnsvoid

// Called internally by PluginManager

getCategories

getCategoriesmethod

Get Categories

Retrieves the currently configured SponsorBlock categories for a guild.

Parameters
guildIdrequiredstring
The ID of the guild.

Returns & Example

ReturnsPromise<string[]> — An array of category strings.

const categories = await plugin.getCategories('123456789');
console.log('SponsorBlock Categories:', categories);

setCategories

setCategoriesmethod

Set Categories

Sets the SponsorBlock categories for a guild.

Parameters
guildIdrequiredstring
The ID of the guild.
categoriesrequiredstring[]
An array of category strings to set.

Returns & Example

ReturnsPromise<void>

await plugin.setCategories('123456789', ['sponsor', 'selfpromo']);

clearCategories

clearCategoriesmethod

Clear Categories

Clears all configured SponsorBlock categories for a guild.

Parameters
guildIdrequiredstring
The ID of the guild.

Returns & Example

ReturnsPromise<void>

await plugin.clearCategories('123456789');

handleEvent

handleEventmethod

Handle Event

Handles incoming events from the Lavalink node related to SponsorBlock. This method is called internally by the Node.

Parameters
noderequiredNode
The node instance.
payloadrequiredany
The event payload from Lavalink.

Returns & Example

Returnsvoid

// Called internally by Node