how do you check if the channel is full in discordJS v13?
ex. if the !join then if the channel is full return a message
You have to get the channel object first. Then use VoiceChannel.full() to check if a voice channel is full.
Related
I am using Discordjs v13. I have created a slash command and I am able to "print" a message using
await interaction.reply(messageObj);
I need to send the reply to a different channel where the command was triggered, is this possible?
Something like:
interaction.setChannel(channelId).reply(...)
OR
interaction.reply({
channel: ....
....
})
What you want is not possible. The Discord API does not allow to specify the channel where the app interaction should be replied in: https://discord.com/developers/docs/interactions/receiving-and-responding#responding-to-an-interaction
However if you are concerned with the reply being shown to everyone, you can make the reply ephemeral. If you want to log interactions, you can reply to the interaction then send another message using the solution provided in the comments of your question.
this is actually possible in discordjs v14 and may be in v13 as well. Carl-bot does it with suggestions.but its not an actual reply
use
interaction.guild.channels.cache.get('channel-id').send('message')
this will send a message in a the select channel you may still want to
interaction.reply({Content:'replied in #channel' [embed], ephemeral: true })
so the user knows the reply was redirected . ephemeral: true makes the replay only visible to the user that evoked the interaction.
and if you need the message id for the new message use
const msg = await interaction.guild.channels.cache.get('channel-id').send('message');
to send the message and you can do something like const messageid = msg.id
I would like to check with a code if the bot is still active in a voice channel. If it leaves this automatically after the song has been played, the status should be changed. However, I haven't quite found what I'm looking for yet.
I work with #commands.command. I already have a code for changing the status:
activity = discord.Activity(
name=".help",
type=discord.ActivityType.playing
)
await self.bot.change_presence(activity=activity)
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 would like my bot to send a message to a specific channel notifying the user of the completion of the command. However, the channel that the command was executed in is deleted during the command and the message must be sent in a different channel.
I have tried message.channel.sendMessage but I do not know how to set which channel the message sends to.
The command !setup is executed in the default text channels of the guild. During the command, the default channels are deleted and a new channel "reception" is created. I would like the bot to send a message to "reception" to notify the user of the completion of the command.
To find a channel based on its name, you can use Collection.find() for the guild's channels (Guild.channels).
Example:
const receptionChannel = message.guild.channels.find(c => c.name === 'reception');
receptionChannel.send(`Hey ${message.author}, setup is complete.`)
.catch(console.error);
I'm hosting my bot on glitch.com, but it restarts every night.
When my bot gets started, it reads a message from a specific channel and then writes in the others. The problem with this is that I can't use any guild or channel until the bot receives a message.
How can I avoid doing this?
You can use guild and channel IDs. Every element in Discord has a unique ID (called Snowflake) that identifies it.
If you want to get a specific guild or channel, you can save its ID and use it in the code. IDs are public, so there's no risk using them (they're not like passwords or tokens).
Guilds and channels are stored in Collections and mapped by their IDs, so you can use them like this:
let guild = client.guilds.get('guild id as a string');
let channel = guild.channels.get('channel id as a string');
To get your guild's ID (or the ID of pretty much any element in Discord) you can enable the Developer mode in the settings, then right-click on the guild and select "Copy ID".