Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
How to create a channel and send a message to it when user logined to server?

How add channel and send message to it by discord bot when user login? Message should include hyper link button.

const Discord = require("discord.js");
const config = require("./config.json");
const { MessageActionRow, MessageButton } = require("discord.js");
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
const prefix = "!";
client.on("messageCreate", function (message) {
    let guild = message.guild;
    if (message.author.bot) return;
    if (!message.content.startsWith(prefix)) return;

    const commandBody = message.content.slice(prefix.length);
    const args = commandBody.split(" ");
    const command = args.shift().toLowerCase();

    if (command === "ping") {
        const timeTaken = Date.now() - message.createdTimestamp;
        message.reply(`Pong! This message had a latency of ${timeTaken}ms.`);
    } else if (command === "sum") {
        const numArgs = args.map((x) => parseFloat(x));
        const sum = numArgs.reduce((counter, x) => (counter += x));
        message.reply(`The sum of all the arguments you provided is ${sum}!`);
    } else if (command === "channel") {
        // Create a new text channel
        guild.channels
            .create("nft-checking", { reason: "Needed a cool new channel" })
            .then(console.log)
            .catch(console.error);
    }
});

// client.on("ready", (client) => {
//     client.channels.get("938800178314485823").send("Hello here!");
// });
client.login(config.BOT_TOKEN);
console.log("Discord server is running.");

Please check this and let me know correct code.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You would send a message to the channel as you do with any other channel. To get your new channel you would access it in the .then() after you created it. Here's an example:

guild.channels
    .create("nft-checking", { reason: "Needed a cool new channel" })
    .then(channel => {
         channel.send('I am a new channel');
    }).catch(console.error);

In order to run this code when a user joins, you would use the guildMemberAdd event.

For example:

client.on('guildMemberAdd', (member) => {
    const guild = member.guild;
    
    guild.channels
        .create("nft-checking", { reason: "Needed a cool new channel" })
        .then(channel => {
             channel.send('I am a new channel');
        }).catch(console.error);
});

If you would like to make the channel restricted to the new user with permissions you can check the documentation here and look at the options available.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda