Skip to content

Commit 052f194

Browse files
committed
some flags to make local dev only answer to the test channel and vice versa
1 parent 2b77315 commit 052f194

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

tooling/sparta/.env.example

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
ENVIRONMENT=
2-
32
DEV_CHANNEL_ID=
4-
DEV_CHANNEL_NAME=
5-
6-
PRODUCTION_CHANNEL_ID=
7-
PRODUCTION_CHANNEL_NAME=
3+
PROD_CHANNEL_ID=
84

95
BOT_TOKEN=
106
BOT_CLIENT_ID=

tooling/sparta/src/env.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ export const {
55
TOKEN,
66
CLIENT_ID,
77
GUILD_ID,
8-
PRODUCTION_CHANNEL_NAME,
9-
DEV_CHANNEL_NAME,
10-
PRODUCTION_CHANNEL_ID,
8+
PROD_CHANNEL_ID,
119
DEV_CHANNEL_ID,
1210
ETHEREUM_HOST,
1311
ETHEREUM_ROLLUP_ADDRESS,
@@ -23,8 +21,8 @@ export const {
2321
TOKEN: string;
2422
CLIENT_ID: string;
2523
GUILD_ID: string;
26-
PRODUCTION_CHANNEL_NAME: string;
27-
DEV_CHANNEL_NAME: string;
24+
PROD_CHANNEL_ID: string;
25+
DEV_CHANNEL_ID: string;
2826
ETHEREUM_HOST: string;
2927
ETHEREUM_ROLLUP_ADDRESS: string;
3028
ETHEREUM_ADMIN_ADDRESS: string;
@@ -34,7 +32,6 @@ export const {
3432
ETHEREUM_VALUE: string;
3533
BOT_TOKEN: string;
3634
PRODUCTION_CHANNEL_ID: string;
37-
DEV_CHANNEL_ID: string;
3835
BOT_CLIENT_ID: string;
3936
ENVIRONMENT: string;
4037
};

tooling/sparta/src/index.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ import { deployCommands } from "./deploy-commands.js";
99
import commands from "./commands/index.js";
1010
import {
1111
BOT_TOKEN,
12-
PRODUCTION_CHANNEL_ID,
1312
DEV_CHANNEL_ID,
1413
ENVIRONMENT,
15-
PRODUCTION_CHANNEL_NAME,
16-
DEV_CHANNEL_NAME,
14+
PROD_CHANNEL_ID,
1715
} from "./env.js";
1816

1917
// Extend the Client class to include the commands property
@@ -39,23 +37,18 @@ client.once("ready", () => {
3937
client.on("interactionCreate", async (interaction: Interaction) => {
4038
if (!interaction.isChatInputCommand()) return;
4139

42-
if (
43-
ENVIRONMENT === "development" &&
44-
interaction.channelId === PRODUCTION_CHANNEL_ID
45-
) {
46-
console.log(
47-
"Can't use this command in production if ENVIRONMENT is set to development"
48-
);
40+
const { channelId } = interaction;
41+
if (ENVIRONMENT === "production" && channelId !== PROD_CHANNEL_ID) {
42+
await interaction.reply({
43+
content: "This command can only be used in the production channel",
44+
flags: MessageFlags.Ephemeral,
45+
});
4946
return;
50-
}
51-
52-
if (
53-
ENVIRONMENT === "production" &&
54-
interaction.channelId !== DEV_CHANNEL_ID
55-
) {
56-
console.log(
57-
"Can't use this command in development if ENVIRONMENT is set to production"
58-
);
47+
} else if (ENVIRONMENT === "development" && channelId !== DEV_CHANNEL_ID) {
48+
await interaction.reply({
49+
content: "This command can only be used in the development channel",
50+
flags: MessageFlags.Ephemeral,
51+
});
5952
return;
6053
}
6154

0 commit comments

Comments
 (0)