Skip to content

Commit

Permalink
feat: PREFIX 環境変数でボットの接頭辞を変えられるように (#355)
Browse files Browse the repository at this point in the history
* feat: Make command prefix configurable

* doc: Add PREFIX in envs

* fix: Fix keys to extract
  • Loading branch information
MikuroXina authored Jul 28, 2022
1 parent a8a5dc3 commit ec834ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ yarn start
| `DISCORD_TOKEN` | BOT のトークン |
| `MAIN_CHANNEL_ID` | VoiceDiff(VC 入退室ログ)を送信する **テキスト** チャンネルの ID |
| `GUILD_ID` | 限界開発鯖の ID |
| `PREFIX` | コマンドの接頭辞、デフォルト値は `"!"` |
9 changes: 6 additions & 3 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ dotenv.config();
const {
DISCORD_TOKEN: token,
MAIN_CHANNEL_ID: mainChannelId,
GUILD_ID
} = extractEnv(['DISCORD_TOKEN', 'MAIN_CHANNEL_ID', 'GUILD_ID']);
GUILD_ID,
PREFIX
} = extractEnv(['DISCORD_TOKEN', 'MAIN_CHANNEL_ID', 'GUILD_ID', 'PREFIX'], {
PREFIX: '!'
});

const intents = [
GatewayIntentBits.Guilds, // GUILD_CREATE による初期化
Expand Down Expand Up @@ -110,7 +113,7 @@ const scheduleRunner = new ScheduleRunner(clock);

const commandRunner: MessageResponseRunner<CommandMessage, CommandResponder> =
new MessageResponseRunner(
new MessageProxy(client, transformerForCommand('!'))
new MessageProxy(client, transformerForCommand(PREFIX))
);
const stats = new DiscordMemberStats(client, GUILD_ID as Snowflake);
registerAllCommandResponder({
Expand Down

0 comments on commit ec834ce

Please sign in to comment.