Skip to content

Commit fe271ba

Browse files
committed
feat:申請フォームのリンク表示を行えるように
1 parent 35da0aa commit fe271ba

File tree

4 files changed

+41
-22
lines changed

4 files changed

+41
-22
lines changed

SETUP.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ GASエディタで環境変数を設定します。
1111
3. 左メニューの「プロジェクトの設定」(⚙️アイコン)をクリック
1212
4. 下部の「スクリプト プロパティ」セクションまでスクロール
1313
5. 「スクリプト プロパティを追加」をクリック
14-
6. 以下の2つのプロパティを追加
14+
6. 以下の3つのプロパティを追加
1515

1616
| プロパティ || 説明 |
1717
|---------|-----|------|
1818
| `DISCORD_WEBHOOK_URL` | `https://discord.com/api/webhooks/...` | Discord Webhook URL |
1919
| `DISCORD_MENTION_ID` | `755410747042955294` | メンションするユーザーID |
20+
| `APPLICATION_FORM_URL` | `https://forms.gle/...` | 申請フォームのURL |
2021

2122
### Discord Webhook URLの取得方法
2223

@@ -79,6 +80,7 @@ function checkConfig() {
7980
const props = PropertiesService.getScriptProperties();
8081
Logger.log('DISCORD_WEBHOOK_URL: ' + props.getProperty('DISCORD_WEBHOOK_URL'));
8182
Logger.log('DISCORD_MENTION_ID: ' + props.getProperty('DISCORD_MENTION_ID'));
83+
Logger.log('APPLICATION_FORM_URL: ' + props.getProperty('APPLICATION_FORM_URL'));
8284
}
8385
```
8486

src/config.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,35 @@
22
* 環境変数の型定義
33
*/
44
export interface Config {
5-
DISCORD_WEBHOOK_URL: string;
6-
DISCORD_MENTION_ID: string;
5+
DISCORD_WEBHOOK_URL: string;
6+
DISCORD_MENTION_ID: string;
7+
APPLICATION_FORM_URL: string;
78
}
89

910
/**
1011
* スクリプトプロパティから設定を取得
1112
*/
1213
export function getConfig(): Config {
13-
const props = PropertiesService.getScriptProperties();
14-
const webhookUrl = props.getProperty('DISCORD_WEBHOOK_URL');
15-
const mentionId = props.getProperty('DISCORD_MENTION_ID');
14+
const props = PropertiesService.getScriptProperties();
15+
const webhookUrl = props.getProperty('DISCORD_WEBHOOK_URL');
16+
const mentionId = props.getProperty('DISCORD_MENTION_ID');
17+
const formUrl = props.getProperty('APPLICATION_FORM_URL');
1618

17-
if (!webhookUrl) {
18-
throw new Error('DISCORD_WEBHOOK_URL が設定されていません');
19-
}
19+
if (!webhookUrl) {
20+
throw new Error('DISCORD_WEBHOOK_URL が設定されていません');
21+
}
2022

21-
if (!mentionId) {
22-
throw new Error('DISCORD_MENTION_ID が設定されていません');
23-
}
23+
if (!mentionId) {
24+
throw new Error('DISCORD_MENTION_ID が設定されていません');
25+
}
2426

25-
return {
26-
DISCORD_WEBHOOK_URL: webhookUrl,
27-
DISCORD_MENTION_ID: mentionId,
28-
};
27+
if (!formUrl) {
28+
throw new Error('APPLICATION_FORM_URL が設定されていません');
29+
}
30+
31+
return {
32+
DISCORD_WEBHOOK_URL: webhookUrl,
33+
DISCORD_MENTION_ID: mentionId,
34+
APPLICATION_FORM_URL: formUrl,
35+
};
2936
}

src/discord.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export function sendDiscordNotification(application: Application): void {
1717
const config = getConfig();
1818

1919
// メッセージ内容を構築
20-
const message = createNotificationMessage(config.DISCORD_MENTION_ID, application);
20+
const message = createNotificationMessage(
21+
config.DISCORD_MENTION_ID,
22+
config.APPLICATION_FORM_URL,
23+
application
24+
);
2125

2226
const payload: DiscordWebhookPayload = {
2327
content: message,
@@ -49,12 +53,18 @@ export function sendDiscordNotification(application: Application): void {
4953
/**
5054
* 通知メッセージを作成
5155
*/
52-
function createNotificationMessage(mentionId: string, application: Application): string {
56+
function createNotificationMessage(
57+
mentionId: string,
58+
formUrl: string,
59+
application: Application
60+
): string {
5361
return `<@${mentionId}>
5462
5563
📝 **新しいエクスプレッション申請が追加されました**
5664
5765
**申請種類:** ${application.applicationType}
58-
**申請者 :** ${application.applicantName}
59-
**行番号 :** ${application.rowNumber}`;
66+
**申請者:** ${application.applicantName}
67+
**行番号:** ${application.rowNumber}
68+
69+
🔗 **【Discord】絵文字/スタンプ/サウンドボード申請フォーム:** ${formUrl}`;
6070
}

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { onEdit, testNotification } from './App';
22

33
interface Global {
4-
onEdit: typeof onEdit;
5-
testNotification: typeof testNotification;
4+
onEdit: typeof onEdit;
5+
testNotification: typeof testNotification;
66
}
77
declare const global: Global;
88

0 commit comments

Comments
 (0)