Skip to content

Commit

Permalink
Merge pull request #139 from na2na-p/develop
Browse files Browse the repository at this point in the history
1.2.0.0
  • Loading branch information
2na2-p[bot] authored Nov 4, 2022
2 parents 9deca49 + e8f67d6 commit b70a6a3
Show file tree
Hide file tree
Showing 15 changed files with 217 additions and 206 deletions.
14 changes: 0 additions & 14 deletions .config/example.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# DiscordBot Token
TOKEN="YOUR_TOKEN_HERE"

# DiscordBot Owner
BOT_MASTER_ID="Your Discord ID"

# DiscordBot Prefix
PREFIX="YOUR_BOT_PREFIX_HERE"

# DeepL API Key
DEEPL_API_KEY="YOUR_DEEPL_API_KEY_HERE"

# Commands Install Target Server ID
# e.g. 123456789012345678,123456789012345678,123456789012345678
SET_COMMANDS_TARGET_SERVERS="YOUR_SERVER_ID_HERE"
1 change: 0 additions & 1 deletion .github/workflows/approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
# ghコマンドを利用して自身をreviewerに追加
- name: Approve
run: gh pr review ${{ env.NUMBER }} --approve
env:
Expand Down
6 changes: 2 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"files.eol": "\n",
"cSpell.words": [
"discordjs"
]
"files.eol": "\n",
"cSpell.words": ["discordjs", "divitation"]
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/built ./built
COPY --from=builder /app/package.json ./package.json

ENV NODE_ENV=production
ENV NODE_ENV=container
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["yarn", "start"]
4 changes: 2 additions & 2 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ services:
container_name: app
image: na2na/2na2-discord:main
restart: always
volumes:
- .config:/app/.config
env_file:
- ./.env
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "MIT",
"scripts": {
"start": "node built/index.js --trace-warnings",
"dev": "nodemon",
"dev": "yarn nodemon",
"build": "yarn tsc -p tsconfig.json && yarn tsc-alias -p tsconfig.json",
"lint": "yarn eslint --ext .js,.ts .",
"lint:fix": "yarn eslint --ext .js,.ts . --fix",
Expand All @@ -24,22 +24,21 @@
"deepl-node": "1.7.1",
"discord-api-types": "0.37.16",
"discord.js": "14.6.0",
"js-yaml": "4.1.0",
"dotenv": "^16.0.3",
"libsodium-wrappers": "0.7.10",
"spotify-web-api-node": "5.0.2",
"twemoji-parser": "14.0.0"
},
"devDependencies": {
"@swc/core": "1.3.11",
"@swc/core": "1.3.14",
"@swc/helpers": "0.4.12",
"@types/chai": "4.3.3",
"@types/color": "3.0.3",
"@types/js-yaml": "4.0.5",
"@types/mocha": "10.0.0",
"@types/node": "18.11.8",
"@types/node": "18.11.9",
"@types/twemoji-parser": "13.1.1",
"@typescript-eslint/eslint-plugin": "5.41.0",
"@typescript-eslint/parser": "5.41.0",
"@typescript-eslint/eslint-plugin": "5.42.0",
"@typescript-eslint/parser": "5.42.0",
"chai": "4.3.6",
"eslint": "8.26.0",
"eslint-config-google": "0.14.0",
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable require-jsdoc */
import {CacheType, Client, GatewayIntentBits, Interaction, InteractionType, Message} from 'discord.js';
import {config} from '@/config.js';
import {config} from '@/config/index.js';
import {
commandSetType,
interactionHookType,
Expand Down
12 changes: 0 additions & 12 deletions src/config.ts

This file was deleted.

59 changes: 59 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import _log from '@utils/log.js';
// eslint-disable-next-line require-jsdoc
function log(msg: string): void {
_log(`[Config]: ${msg}`);
}

type configType = {
token: string;
botMasterId: string;
prefix: string;
deeplApiKey: string;
setCommandsTargetServers: string[];
}

if (process.env['NODE_ENV'] !== 'container') {
log('Running in direct deployment mode. .env file loaded.');
const dotenv = await import('dotenv');
dotenv.config();
} else {
log('Running in container mode. using environment variables.');
};

export const config: configType = {
token: (() => {
if (process.env['TOKEN']) {
return process.env['TOKEN'];
} else {
throw new Error('TOKEN is not defined.');
}
})(),
botMasterId: (() => {
if (process.env['BOT_MASTER_ID']) {
return process.env['BOT_MASTER_ID'];
} else {
throw new Error('BOT_MASTER_ID is not defined.');
}
})(),
prefix: (() => {
if (process.env['PREFIX']) {
return process.env['PREFIX'];
} else {
throw new Error('PREFIX is not defined.');
}
})(),
deeplApiKey: (() => {
if (process.env['DEEPL_API_KEY']) {
return process.env['DEEPL_API_KEY'];
} else {
throw new Error('DEEPL_API_KEY is not defined.');
}
})(),
setCommandsTargetServers: (() => {
if (process.env['SET_COMMANDS_TARGET_SERVERS']) {
return process.env['SET_COMMANDS_TARGET_SERVERS'].split(',');
} else {
return [];
}
})(),
};
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function log(msg: string): void {
import {Ping} from '@modules/hooks/ping/index.js';
import {Dice} from '@modules/hooks/dice/index.js';
import {Translate} from '@modules/hooks/translate/index.js';
import {ColorPicker} from '@/modules/hooks/colorpicker/index.js';
import {ColorPicker} from '@/modules/hooks/colorPicker/index.js';
import {Divination} from '@modules/hooks/divination/index.js';
import {Menu} from '@modules/hooks/menu/index.js';
import {Search} from '@modules/hooks/search/index.js';
Expand Down Expand Up @@ -49,4 +49,5 @@ const commands: commandSetType[] = [
];

log('Starting Na2Client...');

new Na2Client(hooks, commands);
File renamed without changes.
2 changes: 1 addition & 1 deletion src/modules/hooks/divination/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable require-jsdoc */
import {boundMethod} from 'autobind-decorator';
import {queryMessage} from '@/types.js';
import {config} from '@/config.js';
import {config} from '@/config/index.js';
import {EmbedBuilder, ColorResolvable, EmbedFooterData, Message} from 'discord.js';
import dayjs from 'dayjs';
import {Translator} from 'deepl-node';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/hooks/translate/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable require-jsdoc */
import {queryMessage} from '@/types.js';
import {config} from '@/config.js';
import {config} from '@/config/index.js';
import {Translator} from 'deepl-node';
import {Message} from 'discord.js';

Expand Down
Loading

0 comments on commit b70a6a3

Please sign in to comment.