bot.guilds.find("id","418798320220241932").channels.find("name","cmd-log").send("Test")
When i do this in 11.3.2 it's dus not work, but in 11.2 this is working
What do you mean it doesn't work? Is it unemployed? What happens when you try to run it? What did you try to run? What's the output? What's the error message? What did you want or expect to happen? Can you post an error?
My error:
bot.guilds.find("id","418798320220241932").channels.find("name","cmd-log").message.channel.send("Test")
^
TypeError: Cannot read property 'channel' of undefined
at command (C:\Users\Paul\Desktop\discord bots\Bananenbot\BOT\bot.js:78:73)
at Client.bot.on.message (C:\Users\Paul\Desktop\discord bots\Bananenbot\BOT\bot.js:122:10)
at emitOne (events.js:115:13)
at Client.emit (events.js:210:7)
at MessageCreateHandler.handle (C:\Users\Paul\node_modules\discord.js\src\client\websocket\packets\handlers\MessageCreate.js:9:34)
at WebSocketPacketManager.handle (C:\Users\Paul\node_modules\discord.js\src\client\websocket\packets\WebSocketPacketManager.js:103:65)
at WebSocketConnection.onPacket (C:\Users\Paul\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:333:35)
at WebSocketConnection.onMessage (C:\Users\Paul\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:296:17)
at WebSocket.onMessage (C:\Users\Paul\node_modules\discord.js\node_modules\ws\lib\event-target.js:120:16)
at emitOne (events.js:115:13)
It's have to find i guild, find a channel in that guild and send a message
The code you provided is inconsistent with the error given (or the wrong line?).
The issue tracker is only for bug reports and enhancement suggestions. If you have a question, please ask it in the Discord server instead of opening an issue – you will get redirected there anyway.
QUICK: For simple "id" searches, the .get("9997893291236126") format should suffice:
msg.guild.members.get("user ID here");
I found this on google. My comment should help spoon-feed anyone the answer and save them time instead of being pointed to this site https://anidiots.guide/understanding/collections
The format for .find has changed from the simple .find("objectskeyname", "valuetosearchfor")
to this lambda (function) format:
BEFORE:
target = msg.channel.guild.members.find("id", userid); //where userid is a "9997893291236126" etc
AFTER:
target = msg.channel.guild.members.find(member => member.id === userid);
EXPLANATION:
As code, this means you will create a temp variable called member (or named anything you want actually) for each time you loop through guild.members to .find() matching elements. Then, (=>) you will perform a conditional check to determine, in this case on the .id key, its exactly equal to the variable userid you want to check for. Extra Note: It should also be possible to write it as a predicate function(member) { blah; //when matched return true;} if you have more complex logic, (or pass in an existing function name re-used from elsewhere to save on repeated code re-use).
You could also simply follow the link on https://discord.js.org/#/docs/main/stable/class/Collection?scrollTo=find leading you to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find which has explanations and examples.
What kind of function (arrow or not) you supply as predicate does not matter.
If you were to read the first link you would also see that finding by ID is in any case (function or key/value) not recommended and instead be pointed to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get
So not only is this a necro post on a redirected thread but also demonstrated using the wrong usecase. Being pointed to the guide you post above is over all a better help then what you wrote here just now.
I'm sure its very clear now thank you for your links. Also I was not aware of such thing as necro'ing on closed github issues, not sure how you even were notified. Sorry... I took the time to learn how. It must have been this:
Automatic watching
When you’re given push access to a repository, automatically receive notifications for it.
I had no intention of sending notifications out to 167 contributors and I will refrain from posting further and angering the gods. Edits don't seem to trigger it.
try this:
bot.guilds.cache.find("id","418798320220241932").channels.find("name","cmd-log").send("Test")