const Discord = require("discord.js");
const client = new Discord.Client();
module.exports = {
name: "voiceStateUpdate",
run: async (message, client) => {
client.on("voiceStateUpdate", (oldMember, newMember, newState) => {
if (newMember.channel && !oldMember.channel) {
if (newMember.channelID === "813346805357871154") console.log("dołączono na kanał %s (%s)", newMember.channel.name, newMember.channelID);
} else if (!newMember.channel && oldMember.channel) {
console.log("rozłączono z kanału %s (%s)", oldMember.channel.name, oldMember.channelID);
} else if (newMember.channel && oldMember.channel) {
console.log("rozłączono z kanału %s (%s) i dołączono do kanału %s (%s)", oldMember.channel.name, oldMember.channelID, newMember.channel.name, newMember.channelID);
}
});
},
};
Asked
Active
Viewed 1,547 times
-4
-
6You shouldn't listen to an event within an event. – Jakye Jul 19 '21 at 14:37
-
Why are you initializing a new `client` when you're already passing a client through `run: async(message, client)`? – Elitezen Jul 19 '21 at 16:26
-
i deleted it from the beginning and still same error – nexy Jul 19 '21 at 16:33
-
message.guild.channels.create(`${client.user.tag}`), { ^ TypeError: Cannot read property 'channels' of undefined -----------error--------- message.guild.channels.create(`${client.user.tag}`), { type: 'voice', } -----code-------- – nexy Jul 19 '21 at 16:56
1 Answers
0
(It depends on how you're calling the module, but) You are probably inverting the names of the run
arguments and you should replace :
run: async (message, client) => {
by
run: async (client, message) => {
if it's not the case, then run
's client
argument is shadowing the client
variable declared at the beginning of the script and is of a different type.
Check the type of client
, to be sure you're getting the correct object, by trying something similar to this answer or this one.

Mohamed AMAZIRH
- 1,159
- 7
- 26