#Send message in specific channel
39 messages · Page 1 of 1 (latest)
V14 and v16.14.0
or await fetch
or get from cache ( channels should be cached by default )
but cache doesn't work too
i have try
client.guilds.cache.get and client.cache.get
if client is ready it will
client.guilds.cache
Cannot read properties of undefined (reading 'cache')
x)
module.exports = {
name: 'guildMemberAdd',
async execute(client, member) {
const { EmbedBuilder } = require('discord.js')
// Embed
try {
const channel = client.guilds.cache('1010649171759472743')
await channel.send({ embeds: [newMemberEmbed] })
} catch (error) {
console.log("Message non envoyé " + error)
}
}
}
const { Client, Collection, IntentsBitField } = require('discord.js')
const myIntents = new IntentsBitField([
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.DirectMessages,
IntentsBitField.Flags.GuildPresences,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.GuildMessageTyping
]);
const client = new Client({ intents: myIntents });
show your function params
You’re defining channel by getting a guild?
The order of function parameters must match between definition and function call.
function execute(client, message, args) { ... };
execute(message, client, args);
• mismatch! you pass a Message where the client is expected
• mismatch! you pass the Client where a Message is expected
^ also true
Const channel = client.guilds.cache is getting a guild
To get a channel
const channel = client.channels.cache.get('id')
Bro autocorrect on phone is a nightmare
also client is prob member
I get my channel in guildmemberadd using client
yeah its possible
but they mixed params
TypeError: Cannot read properties of undefined (reading 'cache') bruh x)
How did you define your channel
try {
console.log(client)
const channel = client.channels.cache.get('1010649171759472743')
await channel.send({ embeds: [newMemberEmbed] })
} catch (error) {
console.log("Message non envoyé " + error)
}
^^ read what Jaw0r3k#3218 said too
Is it even a channel?
Did you fix it
that's "member, client"
Jaw0r3k#3218 said that anyway
because i call member first