mewslink
v1.1.0
Published
Another lavalink wrapper but focus on stability and rich features
Downloads
75
Maintainers
Readme
🌦️ Mewslink
Another lavalink wrapper but focus on stability and rich features
🌟 Features
- Stable client
- Support TypeScript
- 100% Compatible with Lavalink
- Object-oriented
- Easy to setup
- Inbuilt Queue System
- Extendable Player, Queue, Rest class
- Backward compatible (Can run lavalink version 3.7.x)
- Driver based (avaliable to run Nodelink v2 and port older lavalink version)
- Plugin system
- Using PWSL by The PerformanC Organization for better WS implementation
- Compatible with bun
🛠️ Installation
npm i mewslink
💾 Example bot:
const {Client, GatewayIntentBits} = require('discord.js');
const {Guilds, GuildVoiceStates, GuildMessages, MessageContent} = GatewayIntentBits;
const {Mewslink, Library} = require("mewslink");
const Nodes = [{
name: 'owo',
host: '192.168.0.66',
port: 2333,
auth: 'youshallnotpass',
secure: false,
}];
const client = new Client({intents: [Guilds, GuildVoiceStates, GuildMessages, MessageContent]});
const mewslink = new Mewslink({
library: new Library.DiscordJS(client),
nodes: Nodes,
});
client.on("ready", () => console.log(client.user?.tag + " Ready!"));
mewslink.on('nodeConnect', (node) => console.log(`Lavalink ${node.options.name}: Ready!`));
mewslink.on('nodeError', (node, error) => console.error(`Lavalink ${node.options.name}: Error Caught,`, error));
mewslink.on("nodeClosed", (node) => console.warn(`Lavalink ${node.options.name}: Closed`))
// mewslink.on('debug', (name, info) => console.debug(`Lavalink ${name}: Debug,`, info));
mewslink.on('nodeDisconnect', (node, code, reason) => {
console.warn(`Lavalink ${node.options.name}: Disconnected, Code ${code}, Reason ${reason || 'No reason'}`)
});
mewslink.on("trackStart", (player, track) => {
client.channels.cache.get(player.textId).send({content: `Now playing **${track.title}** by **${track.author}**`})
});
mewslink.on("trackEnd", (player) => {
client.channels.cache.get(player.textId).send({content: `Finished playing`})
});
mewslink.on("queueEmpty", player => {
client.channels.cache.get(player.textId).send({content: `Destroyed player due to inactivity.`})
player.destroy();
});
client.on("messageCreate", async msg => {
if (msg.author.bot) return;
if (msg.content.startsWith("!play")) {
const args = msg.content.split(" ");
const query = args.slice(1).join(" ");
const {channel} = msg.member.voice;
if (!channel) return msg.reply("You need to be in a voice channel to use this command!");
let player = await mewslink.create({
guildId: msg.guild.id,
textId: msg.channel.id,
voiceId: channel.id,
shardId: 0,
volume: 40
})
let result = await mewslink.search(query, {requester: msg.author});
if (!result.tracks.length) return msg.reply("No results found!");
if (result.type === "PLAYLIST") for (let track of result.tracks) player.queue.add(track);
else player.queue.add(result.tracks[0]);
if (!player.playing || !player.paused) player.play();
return msg.reply({content: result.type === "PLAYLIST" ? `Queued ${result.tracks.length} from ${result.playlistName}` : `Queued ${result.tracks[0].title}`});
}
})
client.login('');