mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
Added an env var to specify which types of files are loaded
This commit is contained in:
committed by
Alec LaLonde
parent
b845e7d162
commit
f653d0879e
7
packages/discord-bot/README.md
Normal file
7
packages/discord-bot/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# MetaGame Discord Bot
|
||||
|
||||
## Docker commands / testing
|
||||
|
||||
To build: `docker build -f docker/discord-bot/Dockerfile -t discord-bot .`
|
||||
|
||||
To run: `docker run discord-bot`
|
||||
@@ -1,12 +1,15 @@
|
||||
import { Discord } from '@typeit/discord';
|
||||
import * as Path from 'path';
|
||||
|
||||
|
||||
// Within a docker container: We are using tsc, so we want to load the compiled files.
|
||||
// For local dev, we are transpiling: Load the .ts files.
|
||||
const glob = process.env.RUNTIME_ENV === 'docker' ?
|
||||
Path.join(__dirname, 'commands', '*.js') :
|
||||
Path.join(__dirname, 'commands', '*.ts')
|
||||
|
||||
@Discord('', {
|
||||
import: [
|
||||
// We are using tsc, so we want to load the compiled files
|
||||
Path.join(__dirname, 'commands', '*.ts'),
|
||||
Path.join(__dirname, 'commands', '*.js'),
|
||||
],
|
||||
import: [glob],
|
||||
})
|
||||
export abstract class AppDiscord {
|
||||
// This is triggered when a particular command doesn't exist
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
import { getDiscordId, replyWithUnexpectedError } from '../../utils';
|
||||
|
||||
export class GetXpCommand {
|
||||
// todo rename to xp once previous bot is disabled
|
||||
@Command('!xp :discordUser')
|
||||
async getXp(message: CommandMessage) {
|
||||
let targetUserDiscordId = '';
|
||||
|
||||
@@ -3,13 +3,15 @@ import { Client } from '@typeit/discord';
|
||||
|
||||
import { CONFIG } from './config';
|
||||
|
||||
// Within a docker container: We are using tsc, so we want to load the compiled files.
|
||||
// For local dev, we are transpiling: Load the .ts files.
|
||||
const glob = process.env.RUNTIME_ENV === 'docker' ?
|
||||
`${__dirname}/discord/**/*.js` :
|
||||
`${__dirname}/discord/**/*.ts`
|
||||
|
||||
async function createDiscordClient(): Promise<Client> {
|
||||
const client = new Client({
|
||||
classes: [
|
||||
// We are using tsc, so we want to load the compiled files
|
||||
`${__dirname}/discord/**/*.ts`, // glob string to load the classes
|
||||
`${__dirname}/discord/**/*.js`, // glob string to load the classes
|
||||
],
|
||||
classes: [glob],
|
||||
silent: false,
|
||||
variablesChar: ':',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user