#前提・実現したいこと
Discord.jsのフリーチャンネルのコードのエラーを解決したい
#エラー
Javascript
1Promise { 2 <rejected> Error [TOKEN_INVALID]: An invalid token was provided. 3 at Client.login (/home/runner/Nodejstest/node_modules/discord.js/src/client/Client.js:206:52) 4 at /home/runner/Nodejstest/index.js:12:12 5 at Script.runInContext (vm.js:130:18) 6Promise { 7 <rejected> Error [TOKEN_INVALID]: An invalid token was provided. 8 at Client.login (/home/runner/Nodejstest/node_modules/discord.js/src/client/Client.js:206:52) 9 at /home/runner/Nodejstest/index.js:15:12 10 at Script.runInContext (vm.js:130:18) 11Promise { 12 <rejected> Error [TOKEN_INVALID]: An invalid token was provided. 13 at Client.login (/home/runner/Nodejstest/node_modules/discord.js/src/client/Client.js:206:52) 14 at /home/runner/Nodejstest/index.js:14:12 15 at Script.runInContext (vm.js:130:18) 16Promise { 17 <rejected> Error [TOKEN_INVALID]: An invalid token was provided. 18 at Client.login (/home/runner/Nodejstest/node_modules/discord.js/src/client/Client.js:206:52) 19 at /home/runner/Nodejstest/index.js:14:12 20 at Script.runInContext (vm.js:130:18) 21Promise { 22 <rejected> Error [TOKEN_INVALID]: An invalid token was provided. 23 at Client.login (/home/runner/Nodejstest/node_modules/discord.js/src/client/Client.js:206:52) 24 at /home/runner/Nodejstest/index.js:14:12 25 at Script.runInContext (vm.js:130:18) 26Promise { 27 <rejected> Error [TOKEN_INVALID]: An invalid token was provided. 28 at Client.login (/home/runner/Nodejstest/node_modules/discord.js/src/client/Client.js:206:52) 29 at /home/runner/Nodejstest/index.js:14:12 30 at Script.runInContext (vm.js:130:18) 31Promise { 32 <rejected> Error [TOKEN_INVALID]: An invalid token was provided. 33 at Client.login (/home/runner/Nodejstest/node_modules/discord.js/src/client/Client.js:206:52) 34 at /home/runner/Nodejstest/index.js:16:12 35 at Script.runInContext (vm.js:130:18) 36 at Object.<anonymous> (/run_dir/interp.js:209:20) 37 at Module._compile (internal/modules/cjs/loader.js:999:30) 38 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) 39 at Module.load (internal/modules/cjs/loader.js:863:32) 40 at Function.Module._load (internal/modules/cjs/loader.js:708:14) 41 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) 42 at internal/main/run_main_module.js:17:47 { 43 [Symbol(code)]: 'TOKEN_INVALID' 44 } 45} 46 47(node:263) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided. 48 at Client.login (/home/runner/Nodejstest/node_modules/discord.js/src/client/Client.js:206:52) 49 at /home/runner/Nodejstest/index.js:16:12 50 at Script.runInContext (vm.js:130:18) 51 at Object.<anonymous> (/run_dir/interp.js:209:20) 52 at Module._compile (internal/modules/cjs/loader.js:999:30) 53 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10) 54 at Module.load (internal/modules/cjs/loader.js:863:32) 55 at Function.Module._load (internal/modules/cjs/loader.js:708:14) 56 at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) 57 at internal/main/run_main_module.js:17:47 58(node:263) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) 59(node:263) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
#コード
JavaScript
1const querystring = require("querystring"); 2const discord = require("discord.js"); 3const client = new discord.Client(); 4client.on("ready", message => { 5console.log("Bot準備完了~"); 6}); 7client.on('message', async message => { 8 if(message.content === `a`){ 9 const a = message.content.split(" ")[1]; 10 if (!a) return message.channel.send("エラー:チャンネル名が入力されていません"); 11 if(message.author.bot || message.channel.topic !== "freech") return; 12 message.guild.channels.create(`${a}`, { parent: message.channel.parent }) 13 message.channel.send(`フリーチャンネルを作成しました!\n #${a}`); 14 } 15 }); 16 client.login(process.env.DISCORD_BOT_TOKEN);
#補足情報(FW/ツールのバージョンなど)
replit
discord.js 12.5.3
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/07/30 02:15
2021/07/30 02:16
2021/07/30 02:19 編集