Ad

How To Send Discord Messages Over A Period Of Seconds As Opposed To Instantly Or Make It Seem Like The Bot Is Typing For A While

- 1 answer

I have a discord bot that uses Discord.js. It can send messages instantly using code like

message.channel.send('hi')

This works just fine for sending normal messages but I would like to make it seem like it's taking a while to type (Not dissimilar to how the bot Chatty Cathy sends human-like messages).

Check it out here

How would I go about making a bot that also sends human time like messages?

Ad

Answer

You can use channel.startTyping() and channel.stopTyping() to simulate time being taken for a message to send https://discord.js.org/#/docs/main/stable/class/TextChannel?scrollTo=startTyping. Something like:

channel.startTyping();
setTimeout(()=>{
    channel.send(string).then((message)=>{
        channel.stopTyping();
    });
}, 5000)
Ad
source: stackoverflow.com
Ad