-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
152c3a1
commit ba49604
Showing
27 changed files
with
2,638 additions
and
1,214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"semi": true, | ||
"printWidth": 160, | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"arrowParens": "always", | ||
"bracketSameLine": false, | ||
"htmlWhitespaceSensitivity": "css", | ||
"vueIndentScriptAndStyle": true, | ||
"embeddedLanguageFormatting": "auto", | ||
"singleAttributePerLine": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,30 @@ | ||
require('dotenv').config(); | ||
import { CronJob } from 'cron'; | ||
import { processClanData } from './app/processClanData'; | ||
import { Discord } from './app/utils/discord'; | ||
import schedule from './app/utils/schedule'; | ||
import { Client } from 'discord.js'; | ||
import log from './app/utils/log'; | ||
import config from './app/config/config'; | ||
import { intents } from './app/utils/discordIntents'; | ||
import { clientReadyEvent } from './app/events/clientReady'; | ||
import { errorEvent } from './app/events/error'; | ||
import { messageCreateEvent } from './app/events/messageCreate'; | ||
import { config } from './app/config/index.config'; | ||
|
||
log.info(`Starting clash of clans app on ${config.get('env')} environment`); | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
(async (): Promise<void> => { | ||
try { | ||
log.info(`Starting ${config.get('app.name')} on ${config.get('app.env')} environment`); | ||
|
||
const job = new CronJob(schedule.everyFiveMinutes, processClanData); | ||
const discordClient = new Client({ intents }); | ||
|
||
new Discord(true); | ||
clientReadyEvent(discordClient); | ||
|
||
job.start(); | ||
messageCreateEvent(discordClient); | ||
|
||
errorEvent(discordClient); | ||
|
||
log.info(config.get('discord.token')); | ||
|
||
await discordClient.login(config.get('discord.token')); | ||
|
||
// New Discord(true); | ||
} catch (error) { | ||
log.error('Error:', error); | ||
} | ||
})(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export const database = { | ||
user: { | ||
doc: 'The database user.', | ||
format: String, | ||
default: 'app', | ||
env: 'DATABASE_USER', | ||
sensitive: true, | ||
}, | ||
password: { | ||
doc: 'The database password.', | ||
format: String, | ||
default: 'password', | ||
env: 'DATABASE_PASSWORD', | ||
sensitive: true, | ||
}, | ||
name: { | ||
doc: 'The database name.', | ||
format: String, | ||
default: 'zerowars', | ||
env: 'CLASH_OF_CLANS_DATABASE_NAME', | ||
}, | ||
port: { | ||
doc: 'The database port.', | ||
format: 'port', | ||
default: 3306, | ||
env: 'DATABASE_PORT', | ||
sensitive: true, | ||
}, | ||
host: { | ||
doc: 'The database host.', | ||
format: String, | ||
env: 'DATABASE_HOST', | ||
default: 'localhost', | ||
sensitive: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import convict from 'convict'; | ||
import { log } from './log.config'; | ||
import { database } from './database.config'; | ||
import 'dotenv/config'; | ||
|
||
const config = convict({ | ||
app: { | ||
env: { | ||
doc: 'The application environment.', | ||
format: ['production', 'development', 'test'], | ||
default: 'development', | ||
env: 'NODE_ENV', | ||
}, | ||
name: { | ||
doc: 'The application name.', | ||
format: String, | ||
default: 'Clash of Clans Bot', | ||
env: 'APP_NAME', | ||
}, | ||
}, | ||
log, | ||
database, | ||
clashOfClans: { | ||
apiKey: { | ||
doc: 'The Clash of Clans API key.', | ||
format: String, | ||
default: '', | ||
env: 'CLASH_OF_CLANS_API_KEY', | ||
sensitive: true, | ||
}, | ||
}, | ||
discord: { | ||
token: { | ||
doc: 'The Discord bot token.', | ||
format: String, | ||
default: '', | ||
env: 'CLASH_OF_CLANS_DISCORD_TOKEN', | ||
sensitive: true, | ||
}, | ||
}, | ||
}); | ||
|
||
config.validate({ allowed: 'strict' }); | ||
|
||
export { config }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import path from 'path'; | ||
|
||
export const log = { | ||
level: { | ||
doc: 'The log level to use. This only applies to when the environment is set to production or development', | ||
format: ['info', 'warn', 'error', 'critical'], | ||
default: 'info', | ||
env: 'LOG_LEVEL', | ||
}, | ||
transports: { | ||
doc: 'The transports to use for logging. This only applies to when the environment is set to production or development', | ||
format: String, | ||
default: "'console', 'file'", | ||
env: 'LOG_TRANSPORTS', | ||
}, | ||
file: { | ||
doc: 'The file name to use for logging. This only applies to when the environment is set to production or development, and the file transport is enabled', | ||
format: String, | ||
default: path.join(__dirname, '../../storage/logs/info.log'), | ||
env: 'LOG_FILE', | ||
}, | ||
datadog: { | ||
apiKey: { | ||
doc: 'The api key to use for datadog logging. This only applies to when the environment is set to production or development, and the datadog transport is enabled', | ||
format: String, | ||
default: 'secret', | ||
env: 'LOG_DATADOG_API_KEY', | ||
sensitive: true, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.