distube-vk-music-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.3.4 • Public • Published

distube-vk-music-plugin

Custom Distube plugin for VK Music support.

Feature

type example link ☑️
playlist https://vk.com/music/playlist/-192000782_406
album https://vk.com/music/album/-2000892528_18892528
artist https://vk.com/artist/nepridymal_mty0oty4odm2mw
audio https://vk.com/audio-2001624323_122624323
user audios https://vk.com/titsex
group audios https://vk.com/ne_pridymal_group

Installation

npm install distube-vk-music-plugin
yarn add distube-vk-music-plugin
pnpm add distube-vk-music-plugin

Using

import { VKMusicPlugin } from 'distube-vk-music-plugin'
import { Client, GatewayIntentBits } from 'discord.js'
import { DisTube } from 'distube'

const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
        GatewayIntentBits.GuildMembers,
        GatewayIntentBits.GuildVoiceStates,
    ]
})

const distube = new DisTube(client, {
    plugins: [new VKMusicPlugin({ token: 'vk token' })]
})

client.login('bot token')

Example of plugin error handling

import { VK_PLUGIN_ERROR_CODE, VKMusicPluginErrors } from 'distube-vk-music-plugin'
import { DisTubeError } from 'distube'

client.on('error', (error) => {
    if (error instanceof DisTubeError) {
        if (error.errorCode === VK_PLUGIN_ERROR_CODE) {
            switch (error.message as VKMusicPluginErrors) {
                case VKMusicPluginErrors.PLAYLIST_NOT_FOUND:
                    // code here...
                    break
                case VKMusicPluginErrors.PLAYLIST_SONGS_NOT_FOUND:
                    // code here...
                    break
                case VKMusicPluginErrors.ARTIST_NOT_FOUND:
                    // code here...
                    break
                case VKMusicPluginErrors.ARTIST_SONGS_NOT_FOUND:
                    // code here...
                    break
                case VKMusicPluginErrors.AUDIO_NOT_FOUND:
                    // code here...
                    break
                case VKMusicPluginErrors.USER_OR_GROUP_NOT_FOUND:
                    // code here...
                    break
                case VKMusicPluginErrors.URL_NOT_SUPPORT:
                    // code here...
                    break
                case VKMusicPluginErrors.ACCESS_DENIED:
                    // code here...
                    break
                default:
                    // Unexpected errors, create an issue here: https://github.com/titsex/distube-vk-music-plugin/issues
                    break
            }
        }
    }
})

Documentation

VKMusicPlugin[VKMusicPluginOptions]

  • token is required, to get it, follow the link, click "allow" and copy everything between access_token= and &expires_in

Package Sidebar

Install

npm i distube-vk-music-plugin

Weekly Downloads

3

Version

1.3.4

License

none

Unpacked Size

73.4 kB

Total Files

19

Last publish

Collaborators

  • titsex