Git Product home page Git Product logo

appujet / lavamusic Goto Github PK

View Code? Open in Web Editor NEW
547.0 11.0 478.0 9.33 MB

lavalink music bot base in shoukaku and discord.js v14

Home Page: https://appujet.github.io/lavamusic/

License: GNU General Public License v3.0

TypeScript 99.09% Nix 0.07% Dockerfile 0.51% Batchfile 0.01% JavaScript 0.32%
youtube spotify soundcloud- lavaplayer discord-bot discord-js discord-music-bot lavalink-musicbot lavalink music-bot-discord

lavamusic's Introduction

Version Contributors Forks Stargazers Issues Support Server MIT License Run on Repl.it Remix on Glitch


lavamusic

Lavamusic

Lavamusic is a Discord music bot that uses Discord.js, Shoukaku, and TypeScript.

Invite Lavamusic Β· Report Bug & Request Feature

πŸ”₯ Unique Features

  • Developed using TypeScript and Discord.js v14
  • Advanced Music System
  • Customizable Prefix
  • Powerful Search Engine
  • 12 + Music Filters
  • Hybrid Command Handling (Slash and Normal Commands)
  • Highly Configurable
  • User-friendly and Easy to Use
  • 24/7 Music Playback
  • Playlist commands
  • Music channel system

🎢 Support Sources

πŸ” Default Sources

πŸ”Œ Plugin Sources: (Require: LavaLink v4.1.x)

Note: You need to install the plugins to use these sources

To Setup a Lavalink server on Windows, Linux, or Replit, Click Here.

Need Help with plugins? Join our Discord Server and ask for help in the #support channel.

πŸ”§ Requirements

Before starting with the installation, you need to have the following:

Optional

πŸš€ Installation from source

  1. Clone the Lavamusic repository:
git clone https://github.com/appujet/lavamusic.git
  1. Change to the Lavamusic directory:
cd lavamusic
  1. Install the required packages:
npm i
  1. Set up your environment variables: Create a .env file in the root directory of your project with the following variables: or you can use the .env.example file
TOKEN = "" # Your bot token.
CLIENT_ID = "" # Your bot's client ID (If this value is left blank, bots cannot be invited using /invite or /about commands.).
PREFIX = "!" # Your prefix.
OWNER_IDS = ["",""] # Your discord id (You can add multiple ids.).
GUILD_ID = "" # Your server ID (If you want to use the for single server).
PRODUCTION = "true" # true for production.
BOT_STATUS = "online" # Your bot status (online, dnd, idle, invisible or offline).
BOT_ACTIVITY_TYPE = 0 # Activity type is a number from 0 to 5. See more here: https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-types
BOT_ACTIVITY = "Lavamusic" # Your bot activity
DATABASE_URL = "" # Your database url (If you want to use sqlite, then you can leave it blank.).
AUTO_NODE = "false" # true for auto node. It is gave from lavainfo-api (https://lavainfo-api.deno.dev).
LAVALINK_URL = "localhost:2333" # Your Lavalink url (If auto node is true, then you can leave it blank)
LAVALINK_AUTH = "youshallnotpass" # Your Lavalink password (If auto node is true, then you can leave it blank.).
LAVALINK_NAME = "Lavamusic" # Your Lavalink name (If auto node is true, then you can leave it blank.).
LAVALINK_SECURE = "false" # true for secure Lavalink (If auto node is true, then you can leave it blank.).
SEARCH_ENGINE = "ytsearch" # ytsearch (YouTube Search), spsearch (Spotify Search), scsearch (SoundCloud Search) or ytmsearch (YouTube Music Search).
MAX_PLAYLIST_SIZE = "100" # Max playlist size.
MAX_QUEUE_SIZE = "100" # Max queue size.
KEEP_ALIVE = "false" # true for keep alive in https://replit.com
LOG_CHANNEL_ID = "" # If you enter this, you will be able to receive the status of Lavalink nodes and guild join/leave logs through the corresponding channel.
  1. Generate the Prisma client:
npm run db:push
  1. Run the migrations (Only if you want to migrate your database)
npm run db:migrate
  1. Run the bot:

If you are using Windows, click run.bat on Windows explorer.

npm start
  1. Invite the bot to your server:

Generate an invite link for your bot and invite it to your server using the Discord Developer Portal or using Permissions Calculator.

πŸš€ Installation using Docker Compose

This section assumes you have Docker and Docker Compose installed and running correctly. Download the docker-compose.yml file in a separate folder like lavamusic. Edit docker-compose.yml and make sure to set the following variables: Your .env file should look like this or you can use the .env.example file.

TOKEN="." # Your bot token and remember, don't show everyone your bot token
PREFIX="!" # Your prefix
OWNER_IDS=["859640640640640640","859640640640640640"] # Your discord id, you can add multiple ids
GUILD_ID="859640640640640640" # Your server ID (if you want to use it for a single server)
PRODUCTION="true" # "true" for production

For more information how to fill all the variables go to this page. You do not need to edit anything like the LAVA_LINK_URL, LAVA_LINK_AUTH, LAVA_LINK_NAME, LAVA_LINK_SECURE, DATABASE_URL, and the ports unless you know what you're doing. After saving your changes you can open a terminal and go to the same location as the docker-compose.yml file. Then run the following:

docker-compose up -d

The above command will start all your services and your bot should be up and running! To update, you only have to type the following:

docker-compose up --force-recreate --build -d
image prune -f

You can automate this by using Watchtower. The following should be sufficient:

docker run --detach \
    --name watchtower \
    --volume /var/run/docker.sock:/var/run/docker.sock \
    --restart on-failure \
    containrrr/watchtower --cleanup

Do note that the bot will restart itself to update to the latest!

πŸ”— Useful Links

πŸ“ Tutorial

A tutorial has been uploaded on YouTube. Watch it by clicking here.

πŸ“œ Contributing

Thank you for your interest in contributing to Lavamusic! Here are some guidelines to follow when contributing:

  1. Fork the repository and create a new branch for your feature or bug fix.
  2. Write clean and concise code that follows the established coding style.
  3. Create detailed and thorough documentation for any new features or changes.
  4. Write and run tests for your code.
  5. Submit a pull request with your changes. Your contribution will be reviewed by the project maintainers, and any necessary feedback or changes will be discussed with you. We appreciate your help in making Lavamusic better!

πŸ” License

Distributed under the GPL-3.0 license. See LICENSE for more information.

β˜• Donate

Do you like this project? Support it by donating! ko-fi

πŸ‘₯ Contributors

Thanks go to these wonderful people:

lavamusic's People

Contributors

aikoonee avatar anonymous4078 avatar appujet avatar chethanyadav456 avatar chokunplayz avatar gremagol avatar hatry4 avatar hwangsihu avatar hypwreck avatar infnibor avatar kaydafox avatar legoman99573 avatar loukious avatar lucasb25 avatar macleykun avatar nfsmaniac avatar oyejateen avatar pandain95 avatar rafeygx avatar renovate[bot] avatar shibainu0413 avatar stefanlobbenmeier avatar stranger165 avatar unpoeticnad avatar uwuscutely avatar vidulhb avatar vretu-dev avatar wtfsxhil avatar xenofic avatar zebz213 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lavamusic's Issues

Bot disconnect if moved to another channel

If u try to move the bot to another channel the socket close and throw message in console that has been close and automatically leave channel. I have try this into socketClosed.js :

module.exports = async (client,player,payload ) => {

if (payload.byRemote == true) {
    

    player.state == "CONNECTED"
    player.pause(false);
    return;
}

client.logger.log(`Socket has been closed because ${payload.reason} in [${player.guild}]  ${payload.code} ` , "error");

}

So now if u move the bot the music continue but the other command doesnt work ( throw the message " You arent in the same channel as the bot") . any idea how to fix?

Error

Error: Cannot find module 'node:events'
Require stack:

  • /home/runner/lavamusic/node_modules/discord.js/src/client/BaseClient.js
  • /home/runner/lavamusic/node_modules/discord.js/src/index.js
  • /home/runner/lavamusic/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object. (/home/runner/lavamusic/node_modules/discord.js/src/client/BaseClient.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/home/runner/lavamusic/node_modules/discord.js/src/client/BaseClient.js',
    '/home/runner/lavamusic/node_modules/discord.js/src/index.js',
    '/home/runner/lavamusic/index.js'
    ]
    }

im getting this error i have the index.js file but its sayin this

Add Heroku Support

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
Please add heroku support for this bot,it'll easy to maintain the server

Not playing music directly from spotify

in the latest changes it should play music directly from spotify... but it doesn't work, it always plays music from youtube modifying the message sent with the spotify metadata

/help does not work in direct messages - An unexcepted error occured.

Describe the bug
/help does not work in direct messages

To Reproduce
Steps to reproduce the behavior:

  1. Send the bot a direct message /help
  2. It responds with An unexcepted error occured.

Expected behavior
Help is printed :)

Desktop (please complete the following information):

  • OS: Manjaro
  • Browser Discord Client
  • Version Stable 106905 (1eb8c0f) Host 0.0.16

Additional context
TypeError: Cannot read properties of null (reading 'user') at Object.run (/home/stefan/musicbot-lavalink/lavamusic/src/slashCommands/Information/help.js:19:54) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async module.exports (/home/stefan/musicbot-lavalink/lavamusic/src/events/Client/interactionCreate.js:41:13) {stack: "TypeError: Cannot read properties of null (reading…sic/src/events/Client/interactionCreate.js:41:13)", message: "Cannot read properties of null (reading 'user')"}

The issue seems to be interaction.member being null in https://github.com/brblacky/lavamusic/blob/f8641cc06f4301545c491f4a03e8e5a249599b75/src/slashCommands/Information/help.js#L17

Sir can you add autoconnect and textchannel configuration

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

mongoose

problem 1

MongooseError: Operation prefixes.findOne() buffering timed out after 10000ms
at Timeout. (C:\Users\abelp\Desktop\lavamusic-main\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:149:23)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)

Erela.js "No Avaliable Nodes." RangeError

I've transfer the files to my bot as I forked this, and configure the event handler and error comes out:

/workspace/node_modules/erela.js/dist/structures/Player.js:82
            throw new RangeError("No available nodes.");
                  ^

RangeError: No available nodes.
    at new Player (/workspace/node_modules/erela.js/dist/structures/Player.js:82:19)
    at Manager.create (/workspace/node_modules/erela.js/dist/structures/Manager.js:205:16)
    at Object.run (/workspace/commands/music/play.js:23:49)

Any way to fix this?

Syntax Error on Start

Describe the bug
Bot Won't Start

To Reproduce
Steps to reproduce the behavior:
N/A

Expected behavior
The bot would start without a syntax error.

Screenshots
Screen Shot 2021-11-28 at 1 36 38 pm

Additional context
It may be worth noting that several commands have been disabled by the use of appending the files with .off

mongo

}
MongoParseError: Invalid connection string ""
    at new ConnectionString (C:\Users\abelp\Desktop\lavamusic-main\node_modules\mongodb-connection-string-url\lib\index.js:66:19)
    at parseOptions (C:\Users\abelp\Desktop\lavamusic-main\node_modules\mongodb\lib\connection_string.js:210:17)
    at new MongoClient (C:\Users\abelp\Desktop\lavamusic-main\node_modules\mongodb\lib\mongo_client.js:62:63)
    at C:\Users\abelp\Desktop\lavamusic-main\node_modules\mongoose\lib\connection.js:779:16
    at new Promise (<anonymous>)
    at NativeConnection.Connection.openUri (C:\Users\abelp\Desktop\lavamusic-main\node_modules\mongoose\lib\connection.js:776:19)
    at C:\Users\abelp\Desktop\lavamusic-main\node_modules\mongoose\lib\index.js:332:10
    at C:\Users\abelp\Desktop\lavamusic-main\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (C:\Users\abelp\Desktop\lavamusic-main\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10)

Question/Suggestion

Are you looking forward into changing Ksoft.Si API for lyrics to something else. Beacause not only you can not make an new API but their lyrics endpoints are gone and they are not looking forward into re-using them.
That means that the lyrics command will be useless with Ksoft.Si API.

cannot read property of null (reading 'title')

TypeError: Cannot read properties of null (reading 'title')
at Object.execute (/var/lib/pufferpanel/servers/6a3aa38e/src/commands/Music/queue.js:28:70)
at module.exports (/var/lib/pufferpanel/servers/6a3aa38e/src/events/Client/messageCreate.js:89:17)
at MusicBot.emit (node:events:390:28)
at MessageCreateAction.handle (/var/lib/pufferpanel/servers/6a3aa38e/node_modules/discord.js/src/client/actions/MessageCreate.js:25:14)
at Object.module.exports [as MESSAGE_CREATE] (/var/lib/pufferpanel/servers/6a3aa38e/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/var/lib/pufferpanel/servers/6a3aa38e/node_modules/discord.js/src/client/websocket/WebSocketManager.js:350:31)
at WebSocketShard.onPacket (/var/lib/pufferpanel/servers/6a3aa38e/node_modules/discord.js/src/client/websocket/WebSocketShard.js:443:22)
at WebSocketShard.onMessage (/var/lib/pufferpanel/servers/6a3aa38e/node_modules/discord.js/src/client/websocket/WebSocketShard.js:300:10)
at WebSocket.onMessage (/var/lib/pufferpanel/servers/6a3aa38e/node_modules/ws/lib/event-target.js:199:18)
at WebSocket.emit (node:events:390:28)

Fix Socket has been closed because Session is no longer valid.

Go to : events/Lavalink/socketClosed.js
Old :
`module.exports = async (client, player, payload) => {

if (payload.byRemote == true) {
    player.destroy();
}

client.logger.log(`Socket has been closed because ${payload.reason} in [${player.guild}]`, "error");

}
`

Edit :

`module.exports = async (client, player, payload) => {

console.error();

}
`

Make nowplaying embeds pop up in recent channel you sent a play command in

Is your feature request related to a problem? Please describe.
Not a problem just a bit helpful

Describe the solution you'd like
The now playing embeds are locked to the player channel. It should switch to the last channel a play command was sent in

Describe alternatives you've considered
Tried adding player.setTextChannel(message.channel.id) before the message is sent for nowplaying in trackStart.js. didn't work for me though

GUM7EDklIf.mp4

Bot Disconnects instantly, No playing song

[LOG] Player has been created in 833731920944824341
[LOG] Player has been destroyed in 833731920944824341
[ERROR] Socket has been closed because Session is no longer valid. in [833731920944824341]

GuildDelete error

DiscordAPIError: Missing Access
at RequestHandler.execute (/var/lib/pufferpanel/servers/6a3aa38e/node_modules/discord.js/src/rest/RequestHandler.js:349:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (/var/lib/pufferpanel/servers/6a3aa38e/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
at async GuildMemberManager._fetchSingle (/var/lib/pufferpanel/servers/6a3aa38e/node_modules/discord.js/src/managers/GuildMemberManager.js:388:18)
at async module.exports (/var/lib/pufferpanel/servers/6a3aa38e/src/events/Client/guildDelete.js:7:13) {
method: 'get',
path: '/guilds/860203790426570812/members/809213892857167942',
code: 50001,
httpStatus: 403,
requestData: { json: undefined, files: [] }

Typo

src/events/Lavalink/trackStart.js
line 75

if(amount >= 110)
if you keep that 200 the vup button will increase the volume till 200
and if you keep 100 it wont go above 90 so change it to 110

error in playerMove.js

Describe the bug
data: index.js:16886 - [29-11-2021 06:46:47]: [LOG] Player has been destroyed in 890983793622667274
data: index.js:16886 - ReferenceError: message is not defined
data: index.js:16886 - at module.exports (/root/og/src/events/Lavalink/playerMove.js:6:9)
data: index.js:16886 - at processTicksAndRejections (node:internal/process/task_queues:96:5)

To Reproduce
Steps to reproduce the behavior:
1.Play a song
2. Manually disconnect bot

Expected behavior
Send "Music stopped as I have been disconnected from the voice channel." message in player channel.

play command using ! does not work

Describe the bug
No response in discord, log gives an error:

[06-12-2021 06:46:19]: [CMD] Client Application (/) Registered.
DiscordAPIError: Invalid Form Body
embeds[0].description: This field is required
    at RequestHandler.execute (/home/stefan/musicbot-lavalink/lavamusic/node_modules/discord.js/src/rest/RequestHandler.js:349:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/stefan/musicbot-lavalink/lavamusic/node_modules/discord.js/src/rest/RequestHandler.js:50:14)
    at async TextChannel.send (/home/stefan/musicbot-lavalink/lavamusic/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:172:15) {
  method: 'post',
  path: '/channels/466673053208674315/messages',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [Array],
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}

To Reproduce
Steps to reproduce the behavior:

  1. Setup the bot
  2. Type !join (-> the bot joins your voice channel)
  3. Type !play a (the issue appears)

Expected behavior
Some audio starts playing, no error

Additional context
The culprit looks to me like missing curly braces around the 2 statements

Bot stop working after update 1.0.3 ...

1#
after update bot don't use prefix.. only slashcommand.

2#
Spotify stop to working.

3#
When I move the bot from a channel without any... (so with the music stopped but with the queue active) in my channel... it doesn't automatically resume playing

Some Features

Add some features like :

Lyrics Command πŸ‘
Search Command πŸ‘

Add multiple lavalink

β€’ add multiple lavalink server support
β€’ add more command
β€’ add dropdown help menu

Spotify [ Track & Playlist ]

Describe the bug
When i add the duration of spotify track or playlist, the duration in the playing message appear NaN:NaN:NaN.

Screenshots
Capture

32 bit integer

node:19054) TimeoutOverflowWarning: 9223372036854776000 does not fit into a 32-bit signed integer.
Timeout duration was set to 1.
(Use node --trace-warnings ... to show where the warning was created)

24/7?

how bot kept running on replit?

Bot doesn't check whether it can actually join a vc

Describe the bug
Bot doesn't check whether it's in a vc / can actually join a vc

To Reproduce
Steps to reproduce the behavior:

  1. Play music in a vc where the bot has permission to join
  2. Leave the vc
  3. Manually disconnect bot or delete the channel
  4. Join a vc the bot doesn't have permission to join
    image
  5. Type join command
  6. The bot says
    image
    but doesn't join vc. It still shows now playing and lets you queue songs.

Expected behavior
Bot should say it is unable to join the vc and not start a player

Note
When this errror occurs the only way to fix is restart entire bot

cEU81f2c3X.mp4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.