Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ BOT_TOKEN=""
BOT_ID=""
GUILD_ID=""
OBSERVER_CHANNEL_ID=""
REACTION_FORWARDER_CHANNEL_ID=""
REACTION_FORWARDER_REACTIONS=""
REACTION_FORWARDER_THRESHOLD="3"
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ MineCode Discord Bot for general purpose use.
- **TeX Renderer**: LaTeX math rendering using KaTeX + Sharp
- **VC Observer**: Voice channel activity monitoring
- **System Controller**: Server management commands
- **Reaction Forwarder**: Forward messages with specific reactions to designated channels

## Development

Expand Down Expand Up @@ -63,6 +64,9 @@ BOT_TOKEN="your_discord_bot_token"
BOT_ID="your_bot_id"
GUILD_ID="your_guild_id"
OBSERVER_CHANNEL_ID="your_channel_id"
REACTION_FORWARDER_CHANNEL_ID="your_reaction_forwarder_channel_id"
REACTION_FORWARDER_REACTIONS="emoji_id_1,emoji_id_2,emoji_id_3"
REACTION_FORWARDER_THRESHOLD="3"
```

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

- Right-click the channel where vc-observer notification should be sent → Copy Channel ID

**REACTION_FORWARDER_CHANNEL_ID**:

- Right-click the channel where reaction-forwarder should send forwarded messages → Copy Channel ID

**REACTION_FORWARDER_REACTIONS**:

- Right-click the custom emoji you want to monitor → Copy ID
- For multiple emojis, separate with commas: `emoji_id_1,emoji_id_2,emoji_id_3`
- Example: `1183455310992638113,1392815819540533400`

**REACTION_FORWARDER_THRESHOLD**:

- Number of reactions required to forward a message (excluding message author and bots)
- Example: `3` (requires 3 or more reactions to forward)
17 changes: 14 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, REST, Routes } from "discord.js";
import { Client, REST, Routes, Partials } from "discord.js";
import * as v from "valibot";
import * as modules from "./modules";
import { config } from "dotenv";
Expand All @@ -8,17 +8,28 @@ const envSchema = v.object({
BOT_ID: v.string(),
GUILD_ID: v.string(),
OBSERVER_CHANNEL_ID: v.string(),
REACTION_FORWARDER_CHANNEL_ID: v.string(),
REACTION_FORWARDER_REACTIONS: v.string(),
REACTION_FORWARDER_THRESHOLD: v.pipe(v.string(), v.transform(Number), v.integer()),
});

config();

export type Env = v.InferInput<typeof envSchema>;
export type Env = v.InferOutput<typeof envSchema>;

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

const client = new Client({
intents: ["Guilds", "GuildVoiceStates", "GuildMessages", "GuildMembers", "MessageContent"],
intents: [
"Guilds",
"GuildVoiceStates",
"GuildMessages",
"GuildMembers",
"MessageContent",
"GuildMessageReactions",
],
partials: [Partials.Message, Partials.Channel, Partials.Reaction],
});

client.once("ready", () => {
Expand Down
1 change: 1 addition & 0 deletions modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./system-controller";
export * from "./tex-renderer";
export * from "./vc-observer";
export * from "./reaction-forwarder";
25 changes: 25 additions & 0 deletions modules/reaction-forwarder/constants-new.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export const BASE_COMMAND = "reaction-forwarder";

export const SUB_COMMAND_HELP = "help";
export const SUB_COMMAND_INFO = "info";
export const SUB_COMMAND_ENABLE = "enable";
export const SUB_COMMAND_DISABLE = "disable";

export const SUB_COMMANDS = {
[SUB_COMMAND_HELP]: "リアクション転送システムのヘルプを表示する",
[SUB_COMMAND_INFO]: "リアクション転送システムの情報を表示する",
[SUB_COMMAND_ENABLE]: "リアクション転送を有効にする",
[SUB_COMMAND_DISABLE]: "リアクション転送を無効にする",
};

export interface ReactionForwarderConfig {
enabled: boolean;
forwardTo: string;
threshold: number;
reactions: string[];
}

// UI設定
export const EMBED_COLOR = 0x93a5a6; // #93a5a6
export const EMBED_FALLBACK_MESSAGE = "(コメント無し)";
export const EMBED_UNKNOWN_USER = "Unknown User";
25 changes: 25 additions & 0 deletions modules/reaction-forwarder/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export const BASE_COMMAND = "reaction-forwarder";

export const SUB_COMMAND_HELP = "help";
export const SUB_COMMAND_INFO = "info";
export const SUB_COMMAND_ENABLE = "enable";
export const SUB_COMMAND_DISABLE = "disable";

export const SUB_COMMANDS = {
[SUB_COMMAND_HELP]: "リアクション転送システムのヘルプを表示する",
[SUB_COMMAND_INFO]: "リアクション転送システムの情報を表示する",
[SUB_COMMAND_ENABLE]: "リアクション転送を有効にする",
[SUB_COMMAND_DISABLE]: "リアクション転送を無効にする",
};

export interface ReactionForwarderConfig {
enabled: boolean;
forwardTo: string;
threshold: number;
reactions: string[];
}

// UI設定
export const EMBED_COLOR = 0x93a5a6;
export const EMBED_FALLBACK_MESSAGE = "(コメント無し)";
export const EMBED_UNKNOWN_USER = "Unknown User";
1 change: 1 addition & 0 deletions modules/reaction-forwarder/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./reaction-forwarder";
Loading