「Discord bot」の版間の差分
Notion-MW |
Notion-MW |
||
98行目: | 98行目: | ||
[https://zenn.dev/azechi/scraps/a98add131e8410 DiscordのSlash Commandをwebhookで受信する方式で作ってみる]にある[https://github.com/discord/discord-interactions-js https://github.com/discord/discord-interactions-js]を使うとよさそう。これをNetlify(AWS Lambda)向けに書き換えて、以下のようになる(前述サイトの内容に加えて、使用された対象のメッセージリンクを送るようにしている)。これが動作するかどうか、まずはテストしてみよう。 | [https://zenn.dev/azechi/scraps/a98add131e8410 DiscordのSlash Commandをwebhookで受信する方式で作ってみる]にある[https://github.com/discord/discord-interactions-js https://github.com/discord/discord-interactions-js]を使うとよさそう。これをNetlify(AWS Lambda)向けに書き換えて、以下のようになる(前述サイトの内容に加えて、使用された対象のメッセージリンクを送るようにしている)。これが動作するかどうか、まずはテストしてみよう。 | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="vb.net">const { InteractionResponseType, InteractionType, verifyKey } = require('discord-interactions') | ||
vb.net | |||
const { InteractionResponseType, InteractionType, verifyKey } = require('discord-interactions') | |||
const CLIENT_PUBLIC_KEY = process.env.CLIENT_PUBLIC_KEY; | const CLIENT_PUBLIC_KEY = process.env.CLIENT_PUBLIC_KEY; | ||
140行目: | 137行目: | ||
<ul> | <ul> | ||
<li><p>最初試していたとき、Netlify上では応答を返すところまで上手くいっているのに「インタラクションに失敗しました」interaction failed(一旦画面移動してから見ると「アプリケーションが応答しませんでした」application did not respondに変わっている)と出続けていたが、応答に</p> | <li><p>最初試していたとき、Netlify上では応答を返すところまで上手くいっているのに「インタラクションに失敗しました」interaction failed(一旦画面移動してから見ると「アプリケーションが応答しませんでした」application did not respondに変わっている)と出続けていたが、応答に</p> | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="vb.net">'headers': { | ||
vb.net | |||
'headers': { | |||
'Content-Type': 'application/json', | 'Content-Type': 'application/json', | ||
},</syntaxhighlight> | },</syntaxhighlight> | ||
191行目: | 186行目: | ||
==== pininit.js ==== | ==== pininit.js ==== | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="javascript">const { InteractionResponseType, InteractionType, verifyKey } = require('discord-interactions') | ||
const { InteractionResponseType, InteractionType, verifyKey } = require('discord-interactions') | |||
const fetch = require("node-fetch-commonjs"); | const fetch = require("node-fetch-commonjs"); | ||
246行目: | 238行目: | ||
==== pin.js ==== | ==== pin.js ==== | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="javascript">const { InteractionResponseType, InteractionType, verifyKey } = require('discord-interactions') | ||
const { InteractionResponseType, InteractionType, verifyKey } = require('discord-interactions') | |||
const fetch = require("node-fetch-commonjs"); | const fetch = require("node-fetch-commonjs"); | ||