A standard music extension library for forgescript
You can install from github:
npm install https://github.com/tryforge/ForgeMusic.git
From Node.js Package Manager:
# NPM
npm install forge-music
# YARN
yarn add forge-music
Add package to your client initialization
const { ForgeMusic } = require('forge-music');
const { ForgeClient } = require('forgescript');
const client = new ForgeClient({
// "GuildVoiceStates" is important for music
intents: [
"Guilds",
"GuildMessages",
"MessageContent",
"GuildVoiceStates"
],
extension: [
new ForgeMusic({ soundsFolder: `${process.cwd()}/sounds` })
]
});
The ForgeMusic
instantiated class is exposed in client.music
and available as typings.
The ForgeMusic
extension registers functions listed below:
$vcJoin[voiceChannel]
- Connects to a voice channelvoiceChannel (Channel)
- The voice channel to establish connection
$defaultProvider[providerName]
- Changes the default provider of current executionproviderName (String)
- The provider to use for searching tracks
$getSoundsFolder
- Returns thesoundsFolder
from specified options inForgeMusic.options
$getTrackInfo[track encoded id;record key]
- Returns information about record key from tracktrack encoded id (String)
- The encoded id to get track from cacherecord key (String)
- The key from object record to retreive information
$loadTracks[query;loadType;providerName?]
- Search tracks from specified provider. Returns an array oftrack encoded id
query (String)
- The query to search for tracksloadType (Enum: LoadResultType)
- The type to filter result. Enum:Search
,Track
,Playlist
.
$playTrack[track encoded id]
- Sends request to the Audio player to play tracktrack encoded id (String)
- The encoded id to get track from cache
$playerStop
- Sends request to the Audio player to stop playing
The extension which manages music handlers for forgescript
ForgeMusic.options
- The options that is provided to constructorsoundsFolder
- The path to folder for sounds
ForgeMusic.manager
- The music manager which manages tracks and audio players.ForgeMusic.addProvider(Provider)
- Adds a provider to collecton
The provider which the service that serves tracks and audios.
Provider can be custom created, and it is not limited to any service.
Current providers is added within package:
The goal for future updates:
- A track queue system
- Audio player features for
filter
,seek
, and etc - Music Events
playing
,resumed
,paused
,stopped
,filters
, and etc - Extensive Provider support.