diff --git a/.env.example b/.env.example index b7b3d71..9d757da 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,4 @@ DISCORD_TOKEN= -DISCORD_CLIENT_ID= DATA_DIR= YOUTUBE_API_KEY= SPOTIFY_CLIENT_ID= diff --git a/README.md b/README.md index 20c74dd..b0fe364 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ I believe it makes much more sense to let Discord handle user permissions (whene Muse is written in TypeScript. You can either run Muse with Docker (recommended) or directly with Node.js. Both methods require API keys passed in as environment variables: -- `DISCORD_TOKEN` and `DISCORD_CLIENT_ID` can be acquired [here](https://discordapp.com/developers/applications) by creating a 'New Application', then going to 'Bot'. +- `DISCORD_TOKEN` can be acquired [here](https://discordapp.com/developers/applications) by creating a 'New Application', then going to 'Bot'. - `SPOTIFY_CLIENT_ID` and `SPOTIFY_CLIENT_SECRET` can be acquired [here](https://developer.spotify.com/dashboard/applications) with 'Create a Client ID'. - `YOUTUBE_API_KEY` can be acquired by [creating a new project](https://console.developers.google.com) in Google's Developer Console, enabling the YouTube API, and creating an API key under credentials. @@ -35,7 +35,7 @@ Muse will log a URL when run. Open this URL in a browser to invite Muse to your (Replace empty config strings with correct values.) ```bash -docker run -it -v "$(pwd)/data":/data -e DISCORD_TOKEN='' -e DISCORD_CLIENT_ID='' -e SPOTIFY_CLIENT_ID='' -e SPOTIFY_CLIENT_SECRET='' -e YOUTUBE_API_KEY='' codetheweb/muse +docker run -it -v "$(pwd)/data":/data -e DISCORD_TOKEN='' -e SPOTIFY_CLIENT_ID='' -e SPOTIFY_CLIENT_SECRET='' -e YOUTUBE_API_KEY='' codetheweb/muse ``` This starts Muse and creates a data directory in your current directory. @@ -53,7 +53,6 @@ services: - ./muse:/data environment: - DISCORD_TOKEN= - - DISCORD_CLIENT_ID= - YOUTUBE_API_KEY= - SPOTIFY_CLIENT_ID= - SPOTIFY_CLIENT_SECRET= diff --git a/src/bot.ts b/src/bot.ts index 1b8f8dd..16bdba0 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -16,14 +16,12 @@ export default class { private readonly client: Client; private readonly naturalLanguage: NaturalLanguage; private readonly token: string; - private readonly clientId: string; private readonly commands!: Collection; - constructor(@inject(TYPES.Client) client: Client, @inject(TYPES.Services.NaturalLanguage) naturalLanguage: NaturalLanguage, @inject(TYPES.Config.DISCORD_TOKEN) token: string, @inject(TYPES.Config.DISCORD_CLIENT_ID) clientId: string) { + constructor(@inject(TYPES.Client) client: Client, @inject(TYPES.Services.NaturalLanguage) naturalLanguage: NaturalLanguage, @inject(TYPES.Config.DISCORD_TOKEN) token: string) { this.client = client; this.naturalLanguage = naturalLanguage; this.token = token; - this.clientId = clientId; this.commands = new Collection(); } @@ -96,7 +94,7 @@ export default class { }); this.client.on('ready', async () => { - console.log(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.clientId}&scope=bot&permissions=36752448`); + console.log(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''}&scope=bot&permissions=36752448`); }); this.client.on('error', console.error); diff --git a/src/inversify.config.ts b/src/inversify.config.ts index 6c1553e..f211083 100644 --- a/src/inversify.config.ts +++ b/src/inversify.config.ts @@ -7,7 +7,6 @@ import YouTube from 'youtube.ts'; import Spotify from 'spotify-web-api-node'; import { DISCORD_TOKEN, - DISCORD_CLIENT_ID, YOUTUBE_API_KEY, SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, @@ -72,7 +71,6 @@ container.bind(TYPES.Services.NaturalLanguage).to(NaturalLangua // Config values container.bind(TYPES.Config.DISCORD_TOKEN).toConstantValue(DISCORD_TOKEN); -container.bind(TYPES.Config.DISCORD_CLIENT_ID).toConstantValue(DISCORD_CLIENT_ID); container.bind(TYPES.Config.YOUTUBE_API_KEY).toConstantValue(YOUTUBE_API_KEY); container.bind(TYPES.Config.DATA_DIR).toConstantValue(DATA_DIR); container.bind(TYPES.Config.CACHE_DIR).toConstantValue(CACHE_DIR); diff --git a/src/types.ts b/src/types.ts index 7ed076d..8202b2f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,7 +3,6 @@ export const TYPES = { Client: Symbol('Client'), Config: { DISCORD_TOKEN: Symbol('DISCORD_TOKEN'), - DISCORD_CLIENT_ID: Symbol('DISCORD_CLIENT_ID'), YOUTUBE_API_KEY: Symbol('YOUTUBE_API_KEY'), DATA_DIR: Symbol('DATA_DIR'), CACHE_DIR: Symbol('CACHE_DIR') diff --git a/src/utils/config.ts b/src/utils/config.ts index fe41649..2e72677 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -3,7 +3,6 @@ import path from 'path'; dotenv.config(); export const DISCORD_TOKEN: string = process.env.DISCORD_TOKEN ? process.env.DISCORD_TOKEN : ''; -export const DISCORD_CLIENT_ID: string = process.env.DISCORD_CLIENT_ID ? process.env.DISCORD_CLIENT_ID : ''; export const YOUTUBE_API_KEY: string = process.env.YOUTUBE_API_KEY ? process.env.YOUTUBE_API_KEY : ''; export const SPOTIFY_CLIENT_ID: string = process.env.SPOTIFY_CLIENT_ID ? process.env.SPOTIFY_CLIENT_ID : ''; export const SPOTIFY_CLIENT_SECRET: string = process.env.SPOTIFY_CLIENT_SECRET ? process.env.SPOTIFY_CLIENT_SECRET : '';