1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Discordのbot制作で永遠にエラーが出た話

Posted at

初めに

初めて記事を書くので見ずらい・読みずらいのは許してください

エラーが出るまでの経緯

先日、あるVTuberのファンディスコ鯖用にbotを作っていました。
私は一からコードを書くことが出来ないので、EOiさん制作のBot「MiniPotato」を改変する形で制作していました。

エラー発生とその内容

EOiさんの記事を参考にして、トークンとアプリケーションIDを入力し、いざ動かそうというときにエラーが発生しました。

Logs.txt
/rbd/pnpm-volume/46caa70e-a7c8-4768-905c-69edf7aa9a22/node_modules/@discordjs/ws/dist/index.js:1132
          error: new Error("Used disallowed intents")
                 ^
Error: Used disallowed intents
    at WebSocketShard.onClose (/rbd/pnpm-volume/46caa70e-a7c8-4768-905c-69edf7aa9a22/node_modules/@discordjs/ws/dist/index.js:1132:18)
    at WebSocket.connection.onclose (/rbd/pnpm-volume/46caa70e-a7c8-4768-905c-69edf7aa9a22/node_modules/@discordjs/ws/dist/index.js:676:17)
    at callListener (/rbd/pnpm-volume/46caa70e-a7c8-4768-905c-69edf7aa9a22/node_modules/ws/lib/event-target.js:290:14)
    at WebSocket.onClose (/rbd/pnpm-volume/46caa70e-a7c8-4768-905c-69edf7aa9a22/node_modules/ws/lib/event-target.js:220:9)
    at WebSocket.emit (node:events:526:28)
    at WebSocket.emitClose (/rbd/pnpm-volume/46caa70e-a7c8-4768-905c-69edf7aa9a22/node_modules/ws/lib/websocket.js:260:10)
    at TLSSocket.socketOnClose (/rbd/pnpm-volume/46caa70e-a7c8-4768-905c-69edf7aa9a22/node_modules/ws/lib/websocket.js:1272:15)
    at TLSSocket.emit (node:events:538:35)
    at node:net:687:12
    at TCP.done (node:_tls_wrap:580:7)

初見で原因を見抜ける人はいないと思います。
Used disallowed intents日本語にすると「使用禁止インテント」
意味が分かりません。
エラーの内容もDiscord.jsなどのパッケージのファイルで、参照の仕方が違うのかと確かめてもミスはなく、困り果てていました。

解決

プログラムに対して何をやってもエラーが治らず困り果てていたところ、一つの妙案を思いつきました
Discord側の設定です。
使用禁止って事は何か権限が足りないのかもしれないと。
Discord Developer Portal - Google Chrome 2025_02_27 11_24_24.png

これだ!

この一番下の設定をオンにして再起動したら何事もなかったかのように稼働しました。
めでたしめでたし

参考文献

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?