npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

railway-music

v1.3.5

Published

A package that complies with railway's rules on playing music, but still lets you play music.

Downloads

6

Readme

Railway-Music:

Railway-Music is an npm package designed to not break railway's Terms of Serivce, but still let you play music.

This package was made because lot of people were having trouble with hosting their music bots on railway.

About the package:

Railway-Music uses Erela.js and Lavalink in a combination that does not download any DMCA protected content, therefor being in compliance with railway's Terms of Serivce, You can check out the Erela.js docs for more info on MusicClient.manager and Events. Note: Where ever Erela.js Docs say "client" that will translate to "MusicClient" if you are using the examples provided below.

Install:

npm install railway-music

or

yarn add railway-music

Music Bot Example:

const RailwayMusic = require("railway-music");
const MusicClient = new RailwayMusic({
  clientID: "ID",
  clientToken: "TOKEN",
  defaultLogs: true,
});
const discord = require("discord.js");
const client = new discord.Client({ intents: 32767 });
client.login("TOKEN");

// Log it when the client is ready.
client.on("ready", () => {
  console.log("Logged in.");
});

// Play command
client.on("messageCreate", async (m) => {
  if (m.author.bot || !m.content.toLowerCase().startsWith("!play")) return;
  try {
    const response = await MusicClient.play({
      message: m,
      song: m.content.replace("!play", "").trim(),
    });
    return m.reply({
      embeds: [
        new discord.MessageEmbed()
          .setTitle("Enqueueing")
          .setDescription(
            `Enqueueing: **${response.tracks[0].title}**, requested by \`${response.tracks[0].requester.tag}\` `
          ),
      ],
    });
  } catch (e) {
    return m.reply({
      embeds: [
        new discord.MessageEmbed().setTitle("Error").setDescription(String(e)),
      ],
    });
  }
});

// Stop | Leave command
client.on("messageCreate", async (m) => {
  if (m.author.bot || !m.content.toLowerCase().startsWith("!stop")) return;
  try {
    await MusicClient.stop(m);
    return m.reply({
      embeds: [
        new discord.MessageEmbed()
          .setTitle("Deleted Queue")
          .setDescription("Deleted the queue and exited the voice channel."),
      ],
    });
  } catch (e) {
    return m.reply({
      embeds: [
        new discord.MessageEmbed().setTitle("Error").setDescription(String(e)),
      ],
    });
  }
});

// Skip command
client.on("messageCreate", async (m) => {
  if (m.author.bot || !m.content.toLowerCase().startsWith("!skip")) return;
  try {
    await MusicClient.skip(m);
  } catch (e) {
    return m.reply({
      embeds: [
        new discord.MessageEmbed().setTitle("Error").setDescription(String(e)),
      ],
    });
  }
});

// Pause command
client.on("messageCreate", async (m) => {
  if (m.author.bot || !m.content.toLowerCase().startsWith("!pause")) return;
  try {
    await MusicClient.pause(m);
    return m.reply({
      embeds: [
        new discord.MessageEmbed()
          .setTitle("Paused")
          .setDescription("Paused the current song."),
      ],
    });
  } catch (e) {
    return m.reply({
      embeds: [
        new discord.MessageEmbed().setTitle("Error").setDescription(String(e)),
      ],
    });
  }
});

// Resume command
client.on("messageCreate", async (m) => {
  if (m.author.bot || !m.content.toLowerCase().startsWith("!resume")) return;
  try {
    await MusicClient.resume(m);
    return m.reply({
      embeds: [
        new discord.MessageEmbed()
          .setTitle("Resumed")
          .setDescription("Resumed the current song."),
      ],
    });
  } catch (e) {
    return m.reply({
      embeds: [
        new discord.MessageEmbed().setTitle("Error").setDescription(String(e)),
      ],
    });
  }
});

// Volume command
client.on("messageCreate", async (m) => {
  if (m.author.bot || !m.content.toLowerCase().startsWith("!volume")) return;
  try {
    await MusicClient.setVolume({
      message: m,
      volume: Number(m.content.replace("!volume", "").replace(/ /g, "").trim()),
    });
    return m.reply({
      embeds: [
        new discord.MessageEmbed()
          .setTitle("Volume set")
          .setDescription(
            `Set volume to: ${m.content
              .replace("!volume", "")
              .replace(/ /g, "")
              .trim()}`
          ),
      ],
    });
  } catch (e) {
    return m.reply({
      embeds: [
        new discord.MessageEmbed().setTitle("Error").setDescription(String(e)),
      ],
    });
  }
});

// Send a message to the channel when there is no more music left to play, and leave the voice channel.
MusicClient.manager.on("queueEnd", (player) => {
  const embed = new discord.MessageEmbed()
    .setTitle("Queue Ended")
    .setDescription(
      "There is no more songs to play! I have to leave the channel friends :("
    );

  client.channels.cache.get(player.textChannel).send({ embeds: [embed] });
  player.destroy();
});

// Send a message when a song starts playing
MusicClient.manager.on("trackStart", (player, track) => {
  const embed = new discord.MessageEmbed()
    .setTitle("Music Playing")
    .setDescription(
      `Now playing: **${track.title}**, requested by \`${track.requester.tag}\`.`
    );
  client.channels.cache.get(player.textChannel).send({ embeds: [embed] });
});
  • Apologies on the unorganized commands, but I wanted to have it be simple.

Documentation:

  • Note: If a property has "?" at the end of its name, it means said property is optional.

MusicClient Constructor

new RailwayMusic(MusicClientOptions);
  • MusicClientOptions:Type: ObjectProperties: {nodes?: Array<{host: String, port: Number, password: String}>, autoReply?: Object<{enabled: Boolean, funtionNameTitle?: String, functionNameDescription?: String, embedColor: DiscordJsColorResolvable}>, defaultLogs: Boolean, clientID: String, clientToken: String}Required: Yes

  • Notes:

Play Function

MusicClient.play(PlayOptions);
  • PlayOptions:Type: ObjectProperties: {message: Discord.js Message Object, song: String}Required: Yes

Stop Function

MusicClient.stop(Message);
  • Message:Type: Discord.js Message ObjectRequired: Yes

SetVolume Function

MusicClient.setVolume(VolumeOptions);
  • VolumeOptions:Type: ObjectProperties: {message: Discord.js Message Object, volume: Number}Required: Yes

Stop Function

MusicClient.skip(Message);
  • Message:Type: Discord.js Message ObjectRequired: Yes

Pause Function

MusicClient.pause(Message);
  • Message:Type: Discord.js Message ObjectRequired: Yes

Resume Function

MusicClient.resume(Message);
  • Message:Type: Discord.js Message ObjectRequired: Yes

LoopTrack Function

MusicClient.loopTrack(Message);
  • Message:Type: Discord.js Message ObjectRequired: Yes

LoopQueue Function

MusicClient.loopQueue(Message);
  • Message:Type: Discord.js Message ObjectRequired: Yes