所以基本上,我试图让我的代码让我的机器人看到当用户在任何文本频道中键入“t!say #channel“消息””时,机器人将转到指定的频道并说“消息”
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();
}
}
},
};
当我尝试使用该命令时,我在控制台中收到一条错误消息,提示“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!');
}
});
有人知道我做错了什么吗?
阿晨1998
相关分类