エラーを吐いたコード
node.js
1const http = require("http"); 2const querystring = require("querystring"); 3const discord = require("discord.js"); 4const client = new discord.Client(); 5const prefix = process.env.prefix; 6try { 7 // GAS(Google Apps Script)からの受信(botの常時起動) 8 http.createServer(function(req, res){ 9 res.write("OK"); 10 res.end(); 11 }).listen(8080); 12 client.on("ready", message => { 13 console.log("Bot準備完了~"); 14 client.user.setActivity(process.env.activity, { type: process.env.acttype }); 15 }); 16client.on("message", async message => { 17 if (message.author.id == client.user.id || message.author.bot) return; 18 if (message.mentions.has(client.user)) { 19 message.reply("呼びましたか?"); 20 } 21 if (!message.content.startsWith(prefix)) return; //ボットのプレフィックスからメッセージが始まっているか確認 22 const args = message.content.slice(prefix.length).trim().split(/ +/g); 23 const command = args.shift().toLowerCase(); 24 if (command === "help") { //コマンド名 25 message.channel.send({ 26 embed: { 27 title: "ヘルプ", 28 description: "全てのコマンドの初めに`" + prefix + "`をつける必要があります。", 29 fields: [ 30 { 31 name: "ヘルプ", 32 value: "`help`" 33 } 34 ] 35 } 36 }); 37 } 38}); 39 const command = args.shift().toLowerCase(); 40 if (command === "mai") { //コマンド名 41 message.channel.send({ 42 embed: { 43 title: "mai", 44 description: "まいchはミルダム配信者,ですいーたーリスナー", 45 46 fields: [ 47 { 48 name: "mai", 49 value: "`b!`" 50 } 51 ] 52 } 53 }); 54 } 55 56 if (process.env.DISCORD_BOT_TOKEN == undefined) { 57 console.log("DISCORD_BOT_TOKENが設定されていません。"); 58 process.exit(0); 59 } 60 client.login(process.env.DISCORD_BOT_TOKEN); 61} catch (e) { 62 console.log(e); 63}
はいたエラー
error
1ReferenceError: args is not defined
前にも質問してエラーが起きたところを修正して起動させたら違うエラーが起こりました

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。