我创建的discord.js依赖函数出现错误:
async function timeoutUser(guildMember, exp, reason) {
try {
const now = Math.floor(Date.now() / 1000);
const timeoutDuration = (exp - now) * 1000;
console.log(`Timing out ${guildMember} in ${timeoutDuration} milliseconds for reason: ${reason}`);
await guildMember.timeout({timeoutDuration, reason});
console.log(`Successfully timed out ${guildMember} for ${timeoutDuration / 1000} seconds. Reason: ${reason}`);
} catch (error) {
console.error(`Failed to timeout user with Discord ID ${guildMember}: ${error}`);
}
}
我得到的错误如下:
Error: Failed to remove timeout for user with Discord ID 785346463915311176: TypeError: guildMember.timeout is not a function
完整的错误显示在上面。据我所知,我使用的是discord.js文档中的记录。
1条答案
按热度按时间iklwldmw1#
已进行更新,guildMember不是GuildMember的示例: