#Send message in specific channel

39 messages · Page 1 of 1 (latest)

frail berryBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

gritty lion
#

V14 and v16.14.0

north goblet
#

or await fetch
or get from cache ( channels should be cached by default )

gritty lion
#

i have try

#

client.guilds.cache.get and client.cache.get

north goblet
north goblet
gritty lion
#

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 });
north goblet
sterile nacelle
frail berryBOT
#

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

north goblet
#

^ also true

sterile nacelle
#

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

north goblet
sterile nacelle
#

I get my channel in guildmemberadd using client

north goblet
#

yeah its possible
but they mixed params

gritty lion
sterile nacelle
#

Then fetch it?

#

Or client is undefined

gritty lion
#

I have console.log(client) that's say that's

#

i think this is not correct x)

sterile nacelle
gritty lion
# sterile nacelle 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)
        }
sterile nacelle
#

Is it even a channel?

gritty lion
#

bruh i wanna kill me

#

thx for the help

#

i have invert "client, member"

sterile nacelle
#

Did you fix it

gritty lion
#

that's "member, client"

sterile nacelle
gritty lion
#

because i call member first