Remove requirement for DISCORD_CLIENT_ID

Closes #336
This commit is contained in:
Max Isom 2021-09-18 17:04:04 -04:00
parent 9a2ef876d3
commit 79e7e88fab
No known key found for this signature in database
GPG key ID: 25C9B1A7F6798880
6 changed files with 4 additions and 12 deletions

View file

@ -1,5 +1,4 @@
DISCORD_TOKEN= DISCORD_TOKEN=
DISCORD_CLIENT_ID=
DATA_DIR= DATA_DIR=
YOUTUBE_API_KEY= YOUTUBE_API_KEY=
SPOTIFY_CLIENT_ID= SPOTIFY_CLIENT_ID=

View file

@ -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: 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'. - `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. - `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.) (Replace empty config strings with correct values.)
```bash ```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. This starts Muse and creates a data directory in your current directory.
@ -53,7 +53,6 @@ services:
- ./muse:/data - ./muse:/data
environment: environment:
- DISCORD_TOKEN= - DISCORD_TOKEN=
- DISCORD_CLIENT_ID=
- YOUTUBE_API_KEY= - YOUTUBE_API_KEY=
- SPOTIFY_CLIENT_ID= - SPOTIFY_CLIENT_ID=
- SPOTIFY_CLIENT_SECRET= - SPOTIFY_CLIENT_SECRET=

View file

@ -16,14 +16,12 @@ export default class {
private readonly client: Client; private readonly client: Client;
private readonly naturalLanguage: NaturalLanguage; private readonly naturalLanguage: NaturalLanguage;
private readonly token: string; private readonly token: string;
private readonly clientId: string;
private readonly commands!: Collection<string, Command>; private readonly commands!: Collection<string, Command>;
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.client = client;
this.naturalLanguage = naturalLanguage; this.naturalLanguage = naturalLanguage;
this.token = token; this.token = token;
this.clientId = clientId;
this.commands = new Collection(); this.commands = new Collection();
} }
@ -96,7 +94,7 @@ export default class {
}); });
this.client.on('ready', async () => { 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); this.client.on('error', console.error);

View file

@ -7,7 +7,6 @@ import YouTube from 'youtube.ts';
import Spotify from 'spotify-web-api-node'; import Spotify from 'spotify-web-api-node';
import { import {
DISCORD_TOKEN, DISCORD_TOKEN,
DISCORD_CLIENT_ID,
YOUTUBE_API_KEY, YOUTUBE_API_KEY,
SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_ID,
SPOTIFY_CLIENT_SECRET, SPOTIFY_CLIENT_SECRET,
@ -72,7 +71,6 @@ container.bind<NaturalLanguage>(TYPES.Services.NaturalLanguage).to(NaturalLangua
// Config values // Config values
container.bind<string>(TYPES.Config.DISCORD_TOKEN).toConstantValue(DISCORD_TOKEN); container.bind<string>(TYPES.Config.DISCORD_TOKEN).toConstantValue(DISCORD_TOKEN);
container.bind<string>(TYPES.Config.DISCORD_CLIENT_ID).toConstantValue(DISCORD_CLIENT_ID);
container.bind<string>(TYPES.Config.YOUTUBE_API_KEY).toConstantValue(YOUTUBE_API_KEY); container.bind<string>(TYPES.Config.YOUTUBE_API_KEY).toConstantValue(YOUTUBE_API_KEY);
container.bind<string>(TYPES.Config.DATA_DIR).toConstantValue(DATA_DIR); container.bind<string>(TYPES.Config.DATA_DIR).toConstantValue(DATA_DIR);
container.bind<string>(TYPES.Config.CACHE_DIR).toConstantValue(CACHE_DIR); container.bind<string>(TYPES.Config.CACHE_DIR).toConstantValue(CACHE_DIR);

View file

@ -3,7 +3,6 @@ export const TYPES = {
Client: Symbol('Client'), Client: Symbol('Client'),
Config: { Config: {
DISCORD_TOKEN: Symbol('DISCORD_TOKEN'), DISCORD_TOKEN: Symbol('DISCORD_TOKEN'),
DISCORD_CLIENT_ID: Symbol('DISCORD_CLIENT_ID'),
YOUTUBE_API_KEY: Symbol('YOUTUBE_API_KEY'), YOUTUBE_API_KEY: Symbol('YOUTUBE_API_KEY'),
DATA_DIR: Symbol('DATA_DIR'), DATA_DIR: Symbol('DATA_DIR'),
CACHE_DIR: Symbol('CACHE_DIR') CACHE_DIR: Symbol('CACHE_DIR')

View file

@ -3,7 +3,6 @@ import path from 'path';
dotenv.config(); dotenv.config();
export const DISCORD_TOKEN: string = process.env.DISCORD_TOKEN ? process.env.DISCORD_TOKEN : ''; 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 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_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 : ''; export const SPOTIFY_CLIENT_SECRET: string = process.env.SPOTIFY_CLIENT_SECRET ? process.env.SPOTIFY_CLIENT_SECRET : '';