Skip to content

A extension to falicitate the use of Lavalink server with ForgeScript.

License

Notifications You must be signed in to change notification settings

tryforge/ForgeLinked

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


ForgeLinked

Music made stronger with Lavalink for ForgeScript.

@tryforge/forge.linked @tryforge/forgescript Discord


Features

  • Simple and easy-to-use functions
  • Support for multiple event listeners
  • Various filters support (Coming soon)
  • Support for different audio providers
  • Playlist support

Contents

  1. Installation
  2. Setup
    1. Listening Events
  3. Lavalink Configuration
  4. Tips
    1. Default Search Engine
  5. Contributors

Installation

Caution

⚠️ Warning
ForgeLinked is not compatible with ForgeMusic at the moment. Use it only if you understand Lavalink and its setup.

To install ForgeLinked in your project, use:

npm install @tryforge/forge.linked

If you're using a different package manager, look up how to install Node.js dependencies accordingly.


Setup

First, import ForgeLink and ForgeClient in your main file:

const { ForgeClient } = require('@tryforge/forgescript');
const { ForgeLink } = require('@tryforge/forge.link');

Then, create a new instance of ForgeLink with event listeners and Lavalink nodes:

const lavalink = new ForgeLink({
    events: {
        kazagumo: ['playerStart'],
        shoukaku: ['debug', 'ready']
    },
    kazagumoOptions: {
        defaultSearchEngine: 'youtube'
    },
    nodes: [
        {
            name: 'Public Node',
            auth: 'youshallnotpass',
            url: 'lavalink.jirayu.net:13592',
            secure: false
        }
    ]
});

Now, create the ForgeClient and attach lavalink as an extension:

const client = new ForgeClient({
    intents: [
        'Guilds',
        'GuildMessages',
        'MessageContent',
        'GuildVoiceStates'
    ],
    events: [
        'messageCreate'
    ],
    extensions: [lavalink],
    prefixes: ['.']
});

[!INFO] ⚠️ Important
Ensure your ForgeClient has the GuildVoiceStates intent enabled for ForgeLink functions to work properly.


Listening Events

ForgeLinked allows you to listen to specific Lavalink events. To do this, define them inside the events object:

const lavalink = new ForgeLink({
    events: {
        kazagumo: ['playerStart'],
        shoukaku: ['debug', 'ready']
    }
});

Then, you can add custom event handlers:

lavalink.commands.kazagumo.add({
    type: 'playerStart',
    code: '$log[A track started playing now.]'
});

lavalink.commands.shoukaku.add(
    {
        type: 'debug',
        code: '$log[NODE "$env[name]" -> $env[info]]'
    },
    {
        type: 'ready',
        code: '$log[NODE "$env[name]" IS READY]'
    }
);

Lavalink Configuration

To connect ForgeLinked to a Lavalink server, provide the nodes parameter in the setup:

const lavalink = new ForgeLink({
    events: {
        kazagumo: ['playerStart'],
        shoukaku: ['debug', 'ready']
    },
    nodes: [
        {
            name: 'Public Node',
            auth: 'youshallnotpass',
            url: 'lavalink.jirayu.net:13592',
            secure: false
        }
    ]
});

You can find public Lavalink nodes online or host your own.


Tips

Default Search Engine

Lavalink supports multiple search engines. To specify a default, add it under kazagumoOptions:

const lavalink = new ForgeLink({
    kazagumoOptions: {
        defaultSearchEngine: 'youtube'
    }
});

Contributors

Many thanks to everyone who contributed to this project! ❤️

Special thanks to Cyberghost for assisting with the event and command managers—without them, this wouldn’t have been possible!

This package was developed with ♥️ by Econome.

We hope you enjoy using ForgeLink!

Contributors


About

A extension to falicitate the use of Lavalink server with ForgeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •