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);
}
}
});