原本是把Discord bot放到Replit上跑, 不過最近常遇到Replit上還在跑但bot已經下線的情況, 即使重新執行了、也沒報錯, bot還是沒有上線的奇怪情況
經過友人的指點, 才知道這是類似429 too many requests的問題, 是由於共享ip被用太多而造成的, 只能透過kill 1之後重新執行來換ip解決
後來實在太頻繁發生了, 於是就有了把bot搬到其它雲端的想法, 後來就決定試試搬到Azure
不過畢竟對server不熟, 花了好多時間採坑才弄好, 特此紀錄
原本是把Discord bot放到Replit上跑, 不過最近常遇到Replit上還在跑但bot已經下線的情況, 即使重新執行了、也沒報錯, bot還是沒有上線的奇怪情況
最近又開始寫起Discord機器人, 用的discord.js是14.3的版本, 跟上次寫的時候用的12.3版有一些差異, 於此記錄一下
const { Client } = require('discord.js'); const client = new Client({ partials: [/*需要的partial字串, ex:'CHANNEL'*/] }); client.login(/*機器人的token*/);
const { Client, GatewayIntentBits, Partials } = require('discord.js'); const client = new Client({ intents: [/*需要的GatewayIntentBits列舉, ex:GatewayIntentBits.Guilds*/], partials: [/*需要的Partials列舉, ex: Partials.Channel*/] }); client.login(/*機器人的token*/);