WebApr 12, 2024 · That includes a cache property which has all the channels the bot can see in it [1]. Use the find () method on it and compare the name // remember channel names can only be lowercase and have no spaces const channel = guild.channels.cache.find (channel => channel.name === "channel-name"); console.log (channel.id) WebApr 22, 2024 · In order to get any properties from the client object, it needs to be loaded from within an event. Say for example inside the ready event, i.e. when the bot is fully loaded, you can then do client.channels.cache.find(channel => channel.name == "name_of_channel"), etc.To listen to an event, you do client.on("event_name_here", …
Discord Developer Portal
WebOct 12, 2024 · To get a channel to create an invite you should probably only use ones where the Bot has permissions in, eg: const invitechannels = guild.channels.filter(c=> … WebFor v12: bot.channels.cache.find (channel => channel.name === "channel_name_here"); .find () takes in a callback where each value of the collection is given. With the upper code it gives us each channel object and we check if the name of that channel equals "channel_name_here". user13429955 0. testmax pills
discord.js
WebAug 8, 2024 · 1 Answer. The reason it couldn't find the channel is because the channel type for voice is GUILD_VOICE (not just voice) in discord.js v13. That is why it used the … WebOct 12, 2024 · To get a channel to create an invite you should probably only use ones where the Bot has permissions in, eg: const invitechannels = guild.channels.filter (c=> c.permissionsFor (guild.me).has ('CREATE_INSTANT_INVITE')); invitechannels.random ().createInvite () .then (invite=> console.log ('Create Invite:\n' + invite.code)) WebApr 9, 2024 · v12 Finding channel by id returning undefined. Hello! I would like my bot to post messages in a channel and then edit them later however I seem to have gotten stuck on the first step of finding a channel. const {token, prefix, postchannel} = require ("./config");const {Client, Collection} = require ("discord.js");const bot = new Client ... testmail senden