I was trying to set a channels description, but I couldn't find it in the discord.js docs. Does any one know the code for that?
You probably are looking for: channel.setTopic().
Example:
// Set a new channel topic
channel.setTopic('Needs more rate limiting')
.then(updated => console.log(`Channel's new topic is ${updated.topic}`))
.catch(console.error);
You can use the .setTopic() function. For example:
<channel>.setTopic('Topic here')
Related
I'm trying to make a wipe command and my original idea was to clear messages from that channel but when I found out that the limit for deleting messages is 100, I tried to switch to cloning the channel and then deleting it, but I can't seem to get the channel ID. (I know how to do this manually.)
This is what I've tried:
const fetchedChannel = message.guild.channels.cache.get(channel_id);
and then
channel.clone(fetchedChannel);
fetchedChannel.delete();
Any ideas how to get the channel ID?
That's not how clone() method works.
To clone the channel that you fetched, you need to do: fetchedChannel.clone()
then you can delete it with fetchedChannel.delete().
If you want to get the cloned channel you can do:
const clonedChannel = await fetchedChannel.clone()
I have such a problem that I want to send a message via the bot only to a given channel. How can I do this?
Client.channels.cache.get(id).send(text)
This don't work
You can do like so with discord.js v12:
let channel = client.guilds.cache.get('ID_of_the_guild_in_which_the_channel_is_in').channels.cache.get('channel_ID');
if(channel) channel.send('your message');
I'm making a discord bot that will has a feature to move user's to a random voice channel if they want. I searched the internet 3 hours straight and checked the whole documentation. But still can't find anything.
note : I know this bot idea looks useless. But that's what I need.
code :
let voiceChannels = message.guild.filter(g => **idk how to check if it's vc** );
that's what I just found in 3 hours.
You'd need to access the guild's channels and then choose a random channel of type voice.
So in your case, it'd be:
let voiceChannel = message.guild.channels.cache.filter((channel) => channel.type === "voice").random();
if (!message.member.voice.channel) return message.reply("User is not in a voice channel");
await message.member.voice.setChannel(voiceChannel);
I'm trying to basically do what the title says.
I've tried
let channel = message.channel.get(68352726916713XXXX)
message.channel.send(channel.topic)
and stuff like that, But nothing works.
Any suggestions or answers?
If you are trying to get a channel in the same guild as the message was sent in, use message.guild.channels.get. Otherwise, use client.channels.get.
let channel = message.guild.channels.get("68352726916713XXXX");
message.channel.send(channel.topic);
I'd like our Discord Bot to mention a specific channel, and let it be clickable. I understand mentioning a user you use the user ID. I do have the channel Id, just unsure how to implement it.
You just have to do the following:
message.channel.send('Please take a look at this Discord Server channel <#CHANNELID>')
or if you get the channel id from the bot
const channel = message.guild.channels.find(channel => channel.name === 'Name of the channel');
message.channel.send(`Please take a look at this Discord Server channel <#${channel.id}>`)
Then the channel is clickable like in this screenshot:
It is simple :^)
<#channel.id>
Channels on Discord have this special kinda syntax here:
<#channel id>
As commented by Elitezen here, running toString() on a Channel can do that mention for you. Then, just send that string yourself. It's much simpler than manually doing it.
Like this if you're answering a message:
message.channel.send(message.channel.toString());
Also, like answered by others in this question, you can do that yourself if you feel like it.
If you have a Channel object already, you can do something like this (imagine your channel is named myChannel - it doesn't have to be named that, though):
message.channel.send(`<#${message.channel.id}>`);