嗨,伙计们在使用!Tempmute(用户)(时间)(原因)命令后,一个人通常会静音,但是当他的时间用完时,机器人就会崩溃。在此先感谢您的修复帮助。
崩溃:
tomute.id.removeRole(muterole.id);
^
TypeError: tomute.id.removeRole is not a function
at Timeout._onTimeout (C:\Users\pr0mo\OneDrive\Pulpit\Discord Rust Bot\bot.js:245:17)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
代码:
if (command === `${prefix}tempmute`) {
let tomute = message.guild.member(message.mentions.members.first() || message.guild.members.get((args[0])));
if(!tomute) return message.reply("Nie moge znaleźć określonego użytkownika");
if(tomute.hasPermission("ADMINISTRATOR")) return message.reply("Ta osoba ma zbyt wysoką rangę lub nie masz permisji!");
let muterole = message.guild.roles.find(r => r.name === "muted");
if(!muterole){
try {
muterole = message.guild.createRole({
name: "muted",
color: "#0000000",
permissions: []
})
message.guild.channels.forEach(async (channel, id) => {
channel.overwritePermissions(muterole,{
SEND_MESSAGES: false,
ADD_REACTIONS: false
});
});
} catch(e) {
console.log(e.stack);
}
}
let mutetime = args[1];
if(!mutetime) return message.reply("Wprowadź czas na jaki ma byc zmutowana osoba")
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
mutetime);
if(!match)return;
tomute.addRole(muterole.id);
message.reply(`<@${tomute.id}> został zmutowany na ${ms(ms(mutetime))}`);
setTimeout(function(){
tomute.id.removeRole(muterole.id);
message.channel.send(`<@${tomute.id}> został odmutowany!`);
}, ms(mutetime));
}
}
答案 0 :(得分:0)
从静音中删除ID。 tomute.id只是一个字符串