[英]timeout.js discord.js v13 command not working
我遇到了这个问题,当我想使用我的超时命令中嵌入的消息时,我收到一条错误消息! 我将所有命令/文件发送到那里! 感谢您的帮助!
这里的错误信息:
TypeError: command.run is not a function
at module.exports (/home/runner/Bolt-Utilities/events/guild/command.js:132:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
这里的 Timeout.js 命令:
const MessageEmbed = require("discord.js");
module.exports = {
name: 'timeout',
aliases: ["tmute", "tm"],
utilisation: '{prefix}timeout',
async execute(client, message, args) {
const fetch = require('node-fetch');
const ms = require('ms');
if (!message.member.permissions.has('TIMEOUT_MEMBERS')) {
message.delete()
} else {
const user = message.mentions.users.first();
const embed1 = new MessageEmbed()
.setDescription("Please provide the user.")
.setColor("RED");
const embed2 = new MessageEmbed()
.setDescription("Please specify the time.")
.setColor("RED");
const embed3 = new MessageEmbed()
.setDescription("Please specify the time between **10 seconds** (10s) and **28 days** (28d).")
.setColor("RED");
if(!user) return message.reply({ embeds: [embed1] });
const time = args.slice(1).join(' ');
if(!time) return message.reply({ embeds: [embed2] });
const milliseconds = ms(time);
if(!milliseconds || milliseconds < 10000 || milliseconds > 2419200000) return message.reply({ embeds: [embed3] });
const iosTime = new Date(Date.now() + milliseconds).toISOString();
await fetch(`https://discord.com/api/guilds/${message.guild.id}/members/${user.id}`, {
method: 'PATCH',
body: JSON.stringify({ communication_disabled_until: iosTime }),
headers: {
'Content-Type': 'application/json',
'Authorization': `Bot ${client.token}`,
},
});
const embed4 = new MessageEmbed()
.setDescription(`${user} has been **Timeout.** | \`${user.id}\``)
.setColor("YELLOW");
message.channel.send({ embeds: [embed4] })
}
},
};
这里是 command.js 文件:
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = (command.cooldown || 1) * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
return message.reply(
`please wait ${timeLeft.toFixed(
1
)} more second(s) before reusing the \`${command.name}\` command.`
);
}
}
timestamps.set(message.author.id, now);
setTimeout(() => timestamps.delete(message.author.id), cooldownAmount);
try {
command.run(client, message, args, p, cooldowns);
} catch (error) {
console.error(error);
let embed2000 = new MessageEmbed()
.setDescription("There was an error executing that command.")
.setColor("BLUE");
message.channel.send({ embeds: [embed2000] }).catch(console.error);
}
};
那就是所有文件! 我希望有人能帮助我,我不知道那里出了什么问题!
打字错误:您的命令文件中实际上没有command.run
function ,而是有execute
。 将其中一个更改为与另一个相同即可解决问题。
注意:如果将async execute
更改为async run
,则更改如下:
async run(client, message, args) => {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.