Skip to content

Commit ccfed3c

Browse files
Merge pull request #9 from Mine-Code/feat/pinboard
feat: reaction-forwarder を追加
2 parents a5522ab + 305fa96 commit ccfed3c

8 files changed

Lines changed: 365 additions & 3 deletions

File tree

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ BOT_TOKEN=""
22
BOT_ID=""
33
GUILD_ID=""
44
OBSERVER_CHANNEL_ID=""
5+
REACTION_FORWARDER_CHANNEL_ID=""
6+
REACTION_FORWARDER_REACTIONS=""
7+
REACTION_FORWARDER_THRESHOLD="3"

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ MineCode Discord Bot for general purpose use.
77
- **TeX Renderer**: LaTeX math rendering using KaTeX + Sharp
88
- **VC Observer**: Voice channel activity monitoring
99
- **System Controller**: Server management commands
10+
- **Reaction Forwarder**: Forward messages with specific reactions to designated channels
1011

1112
## Development
1213

@@ -63,6 +64,9 @@ BOT_TOKEN="your_discord_bot_token"
6364
BOT_ID="your_bot_id"
6465
GUILD_ID="your_guild_id"
6566
OBSERVER_CHANNEL_ID="your_channel_id"
67+
REACTION_FORWARDER_CHANNEL_ID="your_reaction_forwarder_channel_id"
68+
REACTION_FORWARDER_REACTIONS="emoji_id_1,emoji_id_2,emoji_id_3"
69+
REACTION_FORWARDER_THRESHOLD="3"
6670
```
6771

6872
#### How to Get Each Environment Variable
@@ -83,3 +87,18 @@ OBSERVER_CHANNEL_ID="your_channel_id"
8387
**OBSERVER_CHANNEL_ID**:
8488

8589
- Right-click the channel where vc-observer notification should be sent → Copy Channel ID
90+
91+
**REACTION_FORWARDER_CHANNEL_ID**:
92+
93+
- Right-click the channel where reaction-forwarder should send forwarded messages → Copy Channel ID
94+
95+
**REACTION_FORWARDER_REACTIONS**:
96+
97+
- Right-click the custom emoji you want to monitor → Copy ID
98+
- For multiple emojis, separate with commas: `emoji_id_1,emoji_id_2,emoji_id_3`
99+
- Example: `1183455310992638113,1392815819540533400`
100+
101+
**REACTION_FORWARDER_THRESHOLD**:
102+
103+
- Number of reactions required to forward a message (excluding message author and bots)
104+
- Example: `3` (requires 3 or more reactions to forward)

main.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Client, REST, Routes } from "discord.js";
1+
import { Client, REST, Routes, Partials } from "discord.js";
22
import * as v from "valibot";
33
import * as modules from "./modules";
44
import { config } from "dotenv";
@@ -8,17 +8,28 @@ const envSchema = v.object({
88
BOT_ID: v.string(),
99
GUILD_ID: v.string(),
1010
OBSERVER_CHANNEL_ID: v.string(),
11+
REACTION_FORWARDER_CHANNEL_ID: v.string(),
12+
REACTION_FORWARDER_REACTIONS: v.string(),
13+
REACTION_FORWARDER_THRESHOLD: v.pipe(v.string(), v.transform(Number), v.integer()),
1114
});
1215

1316
config();
1417

15-
export type Env = v.InferInput<typeof envSchema>;
18+
export type Env = v.InferOutput<typeof envSchema>;
1619

1720
const env = v.parse(envSchema, process.env);
1821
process.env.TZ = "Asia/Tokyo";
1922

2023
const client = new Client({
21-
intents: ["Guilds", "GuildVoiceStates", "GuildMessages", "GuildMembers", "MessageContent"],
24+
intents: [
25+
"Guilds",
26+
"GuildVoiceStates",
27+
"GuildMessages",
28+
"GuildMembers",
29+
"MessageContent",
30+
"GuildMessageReactions",
31+
],
32+
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
2233
});
2334

2435
client.once("ready", () => {

modules/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from "./system-controller";
22
export * from "./tex-renderer";
33
export * from "./vc-observer";
4+
export * from "./reaction-forwarder";
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const BASE_COMMAND = "reaction-forwarder";
2+
3+
export const SUB_COMMAND_HELP = "help";
4+
export const SUB_COMMAND_INFO = "info";
5+
export const SUB_COMMAND_ENABLE = "enable";
6+
export const SUB_COMMAND_DISABLE = "disable";
7+
8+
export const SUB_COMMANDS = {
9+
[SUB_COMMAND_HELP]: "リアクション転送システムのヘルプを表示する",
10+
[SUB_COMMAND_INFO]: "リアクション転送システムの情報を表示する",
11+
[SUB_COMMAND_ENABLE]: "リアクション転送を有効にする",
12+
[SUB_COMMAND_DISABLE]: "リアクション転送を無効にする",
13+
};
14+
15+
export interface ReactionForwarderConfig {
16+
enabled: boolean;
17+
forwardTo: string;
18+
threshold: number;
19+
reactions: string[];
20+
}
21+
22+
// UI設定
23+
export const EMBED_COLOR = 0x93a5a6; // #93a5a6
24+
export const EMBED_FALLBACK_MESSAGE = "(コメント無し)";
25+
export const EMBED_UNKNOWN_USER = "Unknown User";
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export const BASE_COMMAND = "reaction-forwarder";
2+
3+
export const SUB_COMMAND_HELP = "help";
4+
export const SUB_COMMAND_INFO = "info";
5+
export const SUB_COMMAND_ENABLE = "enable";
6+
export const SUB_COMMAND_DISABLE = "disable";
7+
8+
export const SUB_COMMANDS = {
9+
[SUB_COMMAND_HELP]: "リアクション転送システムのヘルプを表示する",
10+
[SUB_COMMAND_INFO]: "リアクション転送システムの情報を表示する",
11+
[SUB_COMMAND_ENABLE]: "リアクション転送を有効にする",
12+
[SUB_COMMAND_DISABLE]: "リアクション転送を無効にする",
13+
};
14+
15+
export interface ReactionForwarderConfig {
16+
enabled: boolean;
17+
forwardTo: string;
18+
threshold: number;
19+
reactions: string[];
20+
}
21+
22+
// UI設定
23+
export const EMBED_COLOR = 0x93a5a6;
24+
export const EMBED_FALLBACK_MESSAGE = "(コメント無し)";
25+
export const EMBED_UNKNOWN_USER = "Unknown User";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./reaction-forwarder";

0 commit comments

Comments
 (0)