Send dm from command file

Im trying to send a dm from a command file but when it runs it errors
ReferenceError: client is not defined
ReferenceError: client is not defined
This is the full file part
const text = interaction.options.getString('text');
let users = []

interaction.channel.members.forEach(member => {
if (member.presence) {
if (member.presence.status == 'online' && !member.user.bot) {
if (member.id == interaction.user.id) {

} else {
users.push(member.id);
}
}
}
});

let index = Math.floor(Math.random() * users.length);
let user = users[index];

const embed = new EmbedBuilder()
.setTitle("Here is a random message from someone")
.setDescription(text)
.setColor('Blurple');
client.users.send(user, {embeds: [embed]});
await interaction.reply({ content: 'Sent', ephemeral: true });
const text = interaction.options.getString('text');
let users = []

interaction.channel.members.forEach(member => {
if (member.presence) {
if (member.presence.status == 'online' && !member.user.bot) {
if (member.id == interaction.user.id) {

} else {
users.push(member.id);
}
}
}
});

let index = Math.floor(Math.random() * users.length);
let user = users[index];

const embed = new EmbedBuilder()
.setTitle("Here is a random message from someone")
.setDescription(text)
.setColor('Blurple');
client.users.send(user, {embeds: [embed]});
await interaction.reply({ content: 'Sent', ephemeral: true });
4 Replies
d.js toolkit
d.js toolkit10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Awashcard0
Awashcard0OP10mo ago
[email protected] node 20.11.1 I think i need to get the client somehow
monbrey
monbrey10mo ago
interaction.client
Awashcard0
Awashcard0OP10mo ago
ty
Want results from more Discord servers?
Add your server