Answer the question
In order to leave comments, you need to log in
How to give a role in a discord.js bot? How to issue a role knowing only role id and member id? And not having a message?
There is this code:
let timerId = setInterval(function tick() {
fs.readFile('doebator.json', (err, data) => {
if (err){
// Обработка ошибок
return console.log(err);
}
var userData = JSON.parse(data);
var d = new Date,
dformat = [d.getDate(),
d.getMonth()+1,
d.getFullYear()].join('.')+'-'+
[d.getHours(),
d.getMinutes()].join('.');
if(userData.length != null){
if(dformat>=userData[0].time){
// robot.channels.cache.get(userData[0].channel).send(`<@${userData[0].user}> вы размучены`)
userData.splice(0);
}
}
});
}, 5000);
Answer the question
In order to leave comments, you need to log in
you need to have at least the ID of the server on which you want to give the user a role.
based
// robot.channels.cache.get(userData[0].channel).send(`<@${userData[0].user}> вы размучены`)
/* для добавления роли */
robot.guilds.cache.get(robot.channels.cache.get(userData[0].channel).guild.id).members.cache.get("id_пользователя").roles.add("id_роли")
/* для удаления роли*/
robot.guilds.cache.get(robot.channels.cache.get(userData[0].channel).guild.id).members.cache.get("id_пользователя").roles.remove("id_роли")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question