所以基本上,我試圖讓我的代碼讓我的機(jī)器人看到當(dāng)用戶在任何文本頻道中鍵入“t!say #channel“消息””時(shí),機(jī)器人將轉(zhuǎn)到指定的頻道并說“消息”const { MessageEmbed } = require('discord.js');module.exports = { name: 'say', aliases: ['bc', 'broadcast'], description: 'Says your input via the bot', usage: '<input>', run: async (bot, message, args) => { if (!message.member.hasPermission(['MANAGE_MESSAGES'])) { if (message.mentions.channels.size == 0) { message.reply('please mention a channel first.'); } else if (!message.member.hasPermission(['MANAGE_MESSAGES'])) { let targetChannel = message.mentions.channels.first(); // Get the message to print const args = message.content.split(' ').slice(2); let saytext = args.join(' '); targetChannel.send(saytext); message.delete(); } } },};當(dāng)我嘗試使用該命令時(shí),我在控制臺(tái)中收到一條錯(cuò)誤消息,提示“TypeError: client.commands.get(...).execute is not a function”這是我的 index.js 文件中的代碼片段,命令提示符顯示它位于client.on('message', (message) => { if (!message.content.startsWith(prefix) || message.author.bot) return; const args = message.content .slice(prefix.length) .trim() .split(/ +/); const command = args.shift().toLowerCase(); if (!client.commands.has(command)) return; try { client.commands.get(command).execute(message, args); } catch (error) { console.error(error); message.reply('there was an error trying to execute that command!'); }});有人知道我做錯(cuò)了什么嗎?
一個(gè)說用戶輸入的機(jī)器人
FFIVE
2023-04-20 16:29:54