#lost values
1 messages · Page 1 of 1 (latest)
It says undefined in console when I get to the moved part
well, yes, what else would it be?
well I want it to save the value of the channel id the user firsst joined
I'm sorry, where should I define it then? I've tried putting it higher ``` let tmp;
// if (newState.channel && newState.channel.members.size > 1) {
if (newState.member.id == prvi.id || newState.member.id == drugi.id) {
if (newState.channelId == null) //left
{
console.log("ovo radi");
rls1.forEach((r1) => prvi.roles.add(r1));
rls2.forEach((r2) => drugi.roles.add(r2));
} else if (oldState.channelId == null) { //joined
tmp = newState.channelId;
console.log("Tmp: ", tmp);
if (prvi.voice.channel.id == drugi.voice.channel.id) {
// newState.member.roles.cache.forEach(async (x) => await newState.member.roles.remove(x).catch(err => {}));
console.log("Newstate ", newState.channelId);
console.log("Oldstate", oldState.channelId);
var rls1 = [];
var rls2 = [];
prvi.roles.cache.forEach((r1) => rls1.push(r1.id));
drugi.roles.cache.forEach((r2) => rls2.push(r2.id));
console.log("Rls 1:");
console.log(rls1);
console.log("Rls 2:");
console.log(rls2);
}
} else { // moved
console.log('user moved channels');
console.log(tmp);
newState.member.voice.setChannel(tmp);
}
}
//}```
?
if () {
// scope 1
// has no access to variables from 2
} else if () {
// scope 2
const temp = 0;
if () {
// scope 2.1
// has access to variables from 2
}
} else {
// scope 3
// has no access to variables from 2
}
#resources has some general js resources
scope has nothing to do with discord.js, and is part of the things you should learn before trying to write a bot