Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
How do i make my discord bot type in a specific channel while someone is typing in the bots dms?

I want my discord bot to type in a specific channel while an user is typing in the bots dms to make it look like the user is typing through the bot. I've managed to make it so my bot starts typing in the channel whenever someone is typing in the bots dms but it doesn't stop when the user stops typing yet

Thank you for you help

I now want the bot to do it the other way around which is why I added the following few lines to the code. It doesn't work yet. The error message goes as follows: "(node:38868) UnhandledPromiseRejectionWarning: TypeError: dmToTypeIn.startTyping is not a function"

Client.on("typingStart", async function(channel, user){
    if(user.bot){
        return;
    }

    let channelToTypeIn = Client.channels.cache.get(openTicketsByUserID[user.id].ticketID)
    if(channel.type === "dm"){
        if(openTicketsByUserID[user.id]){

            console.log("one")
            channelToTypeIn.startTyping()

        } else{
            return;
        }   
    }
    
})

The new code:

Client.on("typingStart", async function(channel, user) {

    function Sleep(milliseconds) {
        return new Promise(resolve => setTimeout(resolve, milliseconds));
    }


    if (channel.type === "dm") {

        if (openTicketsByUserID[user.id]) {
            let channelToTypeIn = Client.channels.cache.get(openTicketsByUserID[user.id].ticketID);
            channelToTypeIn.startTyping();
        }
        let fulfilled = false;
        while (!fulfilled) {
            if (!user.typingIn(user.dmChannel)) {
                let channelToTypeIn = Client.channels.cache.get(openTicketsByUserID[user.id].ticketID);
                fulfilled = true;
                channelToTypeIn.stopTyping(true);
            }
        }     
    }

↓↓↓ The part that isn't working yet ↓↓↓

    if(openTicketsByChannelID[channel.id]){
        let dmToTypeIn = Client.users.fetch(openTicketsByChannelID[channel.id].userID)
        dmToTypeIn.startTyping();
    }
    let fulfilled = false;
    while(!fulfilled){
        if(!user.typingIn(channel)){
            let dmToTypeIn = Client.channels.get(openTicketsByChannelID[channel.id].userID)
            fulfilled = true;
            dmToTypeIn.stopTyping(true);
        }
    }

});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You have to check if the user is typing with the User.typingIn method

Client.on("typingStart", async function(channel, user) {
    if (user.bot) {
        return;
    }

    let channelToTypeIn = Client.channels.cache.get(openTicketsByUserID[user.id].ticketID);
    if (channel.type === "dm") {
        if (openTicketsByUserID[user.id]) {
            channelToTypeIn.startTyping();
        }  
    }
   let fulfilled = false;
    while (!fulfilled) {
        if (!user.typingIn(user.dmChannel)) {
            fulfilled = true;
            channelToTypeIn.stopTyping(true);
        }
    } 
});

You can actually use this to make your own custom event!

Client.on("typingStart", async (channel, user) => {
    let fulfilled = false;
        while (!fulfilled) {
            if (!user.typingIn(channel)) {
                fulfilled = true;
                Client.emit("typingStop", channel, user)
            }
    }
})

And listen with

Client.on("typingStop", async (channel, user) => {
//code for when user stops typing
})
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda