Get member object of command sender Discord.js v14 - discord.js

How do I get the member object of #My Server Nickname (the command sender) given the message id of this message? The message author is the bot.

const channel = await interaction.client.channels.fetch('channelid');
const message = await channel.messages.fetch('messageid');
console.log(; //gives user id of person who sent command


get the number of users in a voice channel with my discord bot in python

I'm looking for a way to get the number of users in a voice channel and to get their username to use it in one of my discord bot command, I found that I can use ctx.guild.member to get the members of users in the server, but not in a specific channel, is there a method to do that ?
I tried this
from discord.ext import commands
bot = commands.Bot(intents=discord.Intents.all(),command_prefix = "/")
async def teamup(ctx):
channel =
Or this
bot = commands.Bot(intents=discord.Intents.all(),command_prefix = "/")
async def teamup(ctx):
channel =
None of them works, the first tells me that member objects has no attribute VoiceChannel
and the second one tells me that is a NoneType object and has no attribute channel
You're very close.
async def teamup(ctx):
channel =
ctx has an author property; this returns the user/member object for the individual that invoked the command. The user/member has a voice property that returns the VoiceState object of the user. This has a channel property which will return the voice channel that the user is in. Importantly, this will be None if the user isn't in a voice channel. So, putting it together:
async def teamup(ctx):
voice =
if not
await ctx.send("You are not currently in a voice channel")
channel =
# do what you want with the channel here
await ctx.send(f"You're in {}!")

Discord.js bot command to take users with a specific role and to return an embedded message with all the users in that role

I've been working on this and I cannot figure out why the bot will not enact the command. Essentially this is how the situation should work:
In the channel you send a message: "!listroletest"
After that, the bot should send an embedded with every user who has the role "test" with their userID's
client.on("message", message => {
if(message.content == "!listroletest") {
const ListEmbed = new Discord.MessageEmbed()
.setTitle('Users with the test role:')

Discord.js Voice Channel with Slash Commands

I want to create a Music Bot with the new Discord Slash Commands, but I don't know how to get the voice channel which the user is in.
With a normal Message-Command it's
Because interaction.member doesn't contain any voice information, i defined the voice channel as follows:
const guild = client.guilds.cache.get(interaction.guild_id)
const member = guild.members.cache.get(;
const voiceChannel =;
const guild = client.guilds.cache.get(interaction.guild_id)
const member = guild.member(
const vchannel =
This is what worked for me.
You can use Interaction#member which will return the member who sent the interaction if it was sent in a guild, or null if it was not sent in a guild.
const voice_channel_id = interaction.guild.members.cache.get(

How can I send a message to 2 server the bot is in with node discord

I would like it so that when I type a command and a message it will forward that message to a channel in 2 server the bot is connected to with node discord.
Thanx :)
You can use
var message = '[Message]';
To get the ID of a channel just right click the channel -> copy ID
If you have named your client differently just change bot to the name you use.
const Discord = require('discord.js');
const bot = new Discord.Client();

Sending private message to a group of user (Discord.js)

I'm looking a way to send a private message to à group of users, who have the same role (using discord.js)
I found the way to send a message (client.users.get("ID").send("Message");
But not the way to get all member who have the same role and loop on that list to send them a private message. Someone can help me?
You could do so by first making a list of all the members with the desired role (see Collection.filter()), and then loop through (see Map.forEach()) and send a DM to each member. Check out the code below for an example.
// Assuming 'guild' is defined as the guild with the desired members.
const roleID = ''; // Insert ID of role.
const members = guild.members.filter(m => m.roles.has(roleID) && !==;
members.forEach(member => {
member.send('Hello there.')
.catch(() => console.error(`Unable to send DM to ${member.user.tag}.`));
// The above error would most likely be due to the user's privacy settings within the guild.