Skip to content

Latest commit

 

History

History
96 lines (59 loc) · 2.5 KB

README.md

File metadata and controls

96 lines (59 loc) · 2.5 KB

BOT

Usage

⚠️ must have spotify open before attempting to play music

🔧 Installation

Clone this repo at git clone https://github.com/forky01/SOMEHOWDEADBOT.git

npm install

NOTE: discord.js-v13 requires >= Node 16.6

📝 .env file

Create a .env file with the following variables:

  • DISCORD_TOKEN

  • SPOTIFY_CLIENT_ID

  • SPOTIFY_CLIENT_SECRET

How to get each value is explained in Bot and Spotify Setup

🤖 Bot setup

Create an application at https://discord.com/developers/applications.

Then add a bot -> in the side nav bar under settings -> Bot: The click the Add Bot Button

Grab DISCORD_TOKEN value:

  • Under settings -> Bot: copy the TOKEN and store as DISCORD_TOKEN in your .env file

To add the bot to a server:

  • Under settings -> OAuth2 tab -> URL generator: select the following scopes bot, application.commands and any relevant bot permissions.

🎸 Spotify Setup

Create an app at https://developer.spotify.com/dashboard.

Settings to Modify:

  • Go to Edit settings: add the redirect uri for the auth process (e.g. http://localhost:5000/auth/callback)

  • Note: If App Status is in development mode: Up to 25 Spotify users can install and use your app. These users must be explicitly added under the section "Users and Access" before they can authenticate with your app.

Grab SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET values:

  • Under the app name and description, copy the Client ID and Client Secret and store as SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET in your .env file

📣 commands

When updating commands run: node deploy-commands.js

Global commands are cached for one hour. New global commands will fan out slowly across all guilds and will only be guaranteed to be updated after an hour. Guild commands update instantly. As such, we recommend you use guild-based commands during development and publish them to global commands when they're ready for public use.


🔐 Spotify auth process

https://developer.spotify.com/documentation/general/guides/authorization/code-flow/

UserInfo/currentListeners data structures

user = {
  discordName: {
    state: (temp) used in auth process to identify the user when callback occurs
    msg: (temp) stores the msg which triggered the auth process

    accessToken
    tokenType
    scope
    expiresIn
    refreshToken
    expiresAt
    deviceId
  }
}
currentListeners = {
  voiceChannelId: {
    discordName: [tokenAuth, deviceId]
  }
}