GithubHelp home page GithubHelp logo

leinstay / discobot Goto Github PK

View Code? Open in Web Editor NEW
18.0 5.0 12.0 26 KB

Discord bot for 24/7 streaming of internet radio stations (e.g. SHOUTcast).

License: MIT License

JavaScript 88.31% Dockerfile 5.37% Makefile 6.32%
discord discordbot nodejs radio

discobot's Introduction

Discobot

A simple commandless discord bot for 24/7 streaming of internet radio stations (e.g. SHOUTcast).

Discobot

Requirements

Getting started

First make sure you have all the required tools installed on your machine then continue with these steps.

Installation using Docker

# Clone the repository
git clone https://github.com/leinstay/discobot.git

# Build the image
make build

# Start the image
make start

Installation using npm

# Clone the repository
git clone https://github.com/leinstay/discobot.git

# Enter into the directory
cd dmbot/

# Install the dependencies
npm install

Configuration

After cloning the project and installing all dependencies provide proper Discord API token, default voice channel ID, default text channel ID (for now playing notifications), and url for one or more music stream in config.json file. To acquire channel ID, enable developer mode in Discord and right-click any channel.

Example configuration for radio station:

{
  "prefix": "!a",
  "token": "{BOT TOKEN}",
  "voicechannel": "{VOICE CHANNEL ID}",
  "logchannel": "{TEXT CHANNEL ID}",
  "activity": "Anime Radio",
  "list": [
    {
      "name": "Anime Radio",
      "url": "https://pool.anison.fm/AniSonFM(320)?nocache=0.05"
    }
  ]
}

Example configuration for custom playlist:

{
  "prefix": "!d",
  "token": "{BOT TOKEN}",
  "voicechannel": "{VOICE CHANNEL ID}",
  "logchannel": "{TEXT CHANNEL ID}",
  "activity": "Ranobe Radio",
  "list": [
    {
      "name": "Shinkai Makoto - Five centimeters per second.",
      "url": "https://m17.akniga.club/b/54644/bIoDhyKuJ5rGPM_IFqIC3A,,/01.%20%D0%A1%D0%B8%D0%BD%D0%BA%D0%B0%D0%B9%20%D0%9C%D0%B0%D0%BA%D0%BE%D1%82%D0%BE%20-%20%D0%9F%D1%8F%D1%82%D1%8C%20%D1%81%D0%B0%D0%BD%D1%82%D0%B8%D0%BC%D0%B5%D1%82%D1%80%D0%BE%D0%B2%20%D0%B2%20%D1%81%D0%B5%D0%BA%D1%83%D0%BD%D0%B4%D1%83.mp3"
    },
    {
      "name": "Aya Hazuki - And again, I say hello.",
      "url": "https://m17.akniga.club/b/55024/bIoDhyKuJ5rGPM_IFqIC3A,,/01.%20%D0%90%D1%8F%20%D0%A5%D0%B0%D0%B7%D1%83%D0%BA%D0%B8%20-%20%D0%98%20%D1%81%D0%BD%D0%BE%D0%B2%D0%B0%20%D0%B3%D0%BE%D0%B2%D0%BE%D1%80%D1%8E%20%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82.mp3"
    },
    {
      "name": "Natsume Akatsky - The Goddess blesses this beautiful world.",
      "url": "https://m17.akniga.club/b/54240/bIoDhyKuJ5rGPM_IFqIC3A,,/01.%20%D0%9D%D0%B0%D1%86%D1%83%D0%BC%D1%8D%20%D0%90%D0%BA%D0%B0%D1%86%D0%BA%D0%B8%20-%20%D0%90%D1%85,%20%D0%BC%D0%BE%D1%8F%20%D0%B1%D0%B5%D1%81%D0%BF%D0%BE%D0%BB%D0%B5%D0%B7%D0%BD%D0%B0%D1%8F%20%D0%B1%D0%BE%D0%B3%D0%B8%D0%BD%D1%8F.mp3"
    },
    {
      "name": "Nagatsuki Tappei - Re:Zero. Living in an alternative world from scratch.",
      "url": "https://m17.akniga.club/b/55324/Od3Ak6Dt6YnLfHZMTZNTsg,,/01.%20%D0%9D%D0%B0%D0%B3%D0%B0%D1%86%D1%83%D0%BA%D0%B8%20%D0%A2%D0%B0%D0%BF%D0%BF%D1%8D%D0%B9%20-%20%D0%96%D0%B8%D0%B7%D0%BD%D1%8C%20%D0%B2%20%D0%B0%D0%BB%D1%8C%D1%82%D0%B5%D1%80%D0%BD%D0%B0%D1%82%D0%B8%D0%B2%D0%BD%D0%BE%D0%BC%20%D0%BC%D0%B8%D1%80%D0%B5%20%D1%81%20%D0%BD%D1%83%D0%BB%D1%8F.mp3"
    },
    {
      "name": "Jumpei Inuzuka - Café from another world",
      "url": "https://m17.akniga.club/b/55175/Od3Ak6Dt6YnLfHZMTZNTsg,,/01.%20Inuzuka%20Junpei%20-%20%D0%9A%D0%B0%D1%84%D0%B5%20%D0%B8%D0%B7%20%D0%B4%D1%80%D1%83%D0%B3%D0%BE%D0%B3%D0%BE%20%D0%BC%D0%B8%D1%80%D0%B0.mp3"
    }
  ]
}

Starting the application

Since the bot works even when there is no one in the channel, I strongly recommend to use forever or pm2 with cron autorestart for non-stop broadcasting (because of Discord API features the bot has a tendency to transmit silence after 20-30 hours of uptime).

pm2 start index.js --name DiscoBot --log bot.log --time --restart-delay 5000 & pm2 start restart.js --name Restart

Оr you can do it without process managers.

node index.js

discobot's People

Contributors

geekloper avatar leinstay avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

discobot's Issues

ERROR VOICE_CONNECTION_TIMEOUT bot stopped connecting on March 20th, 2023

Getting this error:

Error [VOICE_CONNECTION_TIMEOUT]: Connection not established within 15 seconds.
    at VoiceConnection.authenticateFailed (/home/ubuntu/discobot/node_modules/discord.js/src/client/voice/VoiceConnection.js:304:26)
    at /home/ubuntu/discobot/node_modules/discord.js/src/client/voice/VoiceConnection.js:325:61
    at Timeout.<anonymous> (/home/ubuntu/discobot/node_modules/discord.js/src/client/BaseClient.js:83:7)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7) {
  [Symbol(code)]: 'VOICE_CONNECTION_TIMEOUT'
}

Thoughts?

command to allow bot to join vc in any server?

this shouldn't have been posted as an issue since its a suggestion or question
Is there a way to actually make the bot join any VC in any guild instead of staying in one VC in one server?

No sound after automatic pm2 restart

I start the bot with:

pm2 start index.js --name DiscoBot --time --restart-delay 5000 & pm2 start restart.js --name Restart

about 5 hours after I started my dicobot I saw the following output and as you can see the last entry in the below log seems that it reconnected. I checked on my discord channel and the bot kept connected to the voice channel but no sound was coming out from the bot

Status: Connection warning - [WS] closed
Status: Connection warning - [WS] connect requested
Status: Connection warning - [WS] reset requested
Status: Connection warning - [WS] connecting, 2 attempts, wss://us-east2090.discord.media/?v=4&encoding=json
Status: Connection warning - [WS] opened at gateway us-east2090.discord.media
Status: Connection warning - Selecting the xsalsa20_poly1305_lite mode
Status: Connection warning - [UDP] created socket
Status: Connection warning - Sending IP discovery packet: [0,12,70,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
Status: Connection warning - Successfully sent IP discovery packet
Status: Connection warning - [UDP] message: [100,70,12,0,49,50,57,46,50,49,51,46,49,49,54,46,52,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,216,109] (6.7.8.9)
Status: Connection warning - [UDP] << {"address":"1.2.3.4","port":8000}
Status: Connection warning - Ready with authentication details: {"sessionID":"-90840942jh42h0875h70jv0k3hkjtj90","token":"1f75cdf1220da623","endpoint":"us-east2090.discord.media","streams":[{"type":"video","ssrc":804453,"rtx_ssrc":804454,"rid":"","quality":0,"active":false}],"ssrc":804452,"port":50014,"modes":["aead_aes256_gcm_rtpsize","aead_aes256_gcm","xsalsa20_poly1305_lite_rtpsize","xsalsa20_poly1305_lite","xsalsa20_poly1305_suffix","xsalsa20_poly1305"],"ip":"4.3.2.1","experiments":["bwe_conservative_link_estimate","bwe_remote_locus_client"],"mode":"xsalsa20_poly1305_lite","video_codec":null,"secret_key":{"0":17,"1":201,"2":230,"3":88,"4":17,"5":5,"6":212,"7":72,"8":195,"9":116,"10":145,"11":171,"12":236,"13":141,"14":248,"15":163,"16":228,"17":121,"18":197,"19":64,"20":10,"21":226,"22":193,"23":176,"24":121,"25":178,"26":87,"27":176,"28":173,"29":206,"30":93,"31":205},"media_session_id":"1221323gtrgfgfst544w54w5454","audio_codec":"opus"}
Now Playing: My Shoucast Radio - Track 1

I had to manually run: pm2 restart DiscoBot to restart the bot and that fixed the sound on the Discord app side

no audio

bot is displayed like its sending audio (green circle around avatar) but there is no sound coming from it

Any change you could move that bot token to an env file on repl.it for better security

Hey,

Any chance you could take a look at the code on repl.it ?
I and a few others have Disco Bot ported to repl.it but it throws up a few errors and won't start any more.

Also, for better security, there's an option on repl.it to store the bot token in an env file instead of in the config file which is public.

Appreciate it great little app.

SyntaxError

hello
i was trying to use your project with my discord server but im having some issus right now
i get " SyntaxError Unexpected token { "
which im guessing is a problem with my configuration file and i messed up something

here is the error

/home/user/discobot/node_modules/discord.js/src/client/Client.js:42
} catch {
^

SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object. (/home/user/discobot/node_modules/discord.js/src/index.js:8:11)

here is my configuration file

{
"prefix":"#fm",
"token":"my bots token",
"voicechannel":"some random number",
"logchannel":"some random number",
"activity":"radio",
"list":[
{
"name":"discobot",
"url":"link to my shoutcast stream"
}
]
}

Prefix dsnt work

The prefix dont work when i try to restart the bot when get disconnect error.

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.