Cyanic76 / discord-modmail

THIS IS A MIRROR. ISSUES AND PR MUST BE SUBMITTED TO CODEBERG.
https://codeberg.org/Cyanic76/discord-modmail
MIT License
77 stars 48 forks source link

Type Effect. #28

Closed DJKieranl29 closed 3 years ago

DJKieranl29 commented 3 years ago

I want to intergrate this: https://stackoverflow.com/questions/44751653/client-starttyping-is-not-a-function-discord-js into the bot for when the staff are typing a reply to the user. Please can you help me get this working... Thanks.

Cyanic76 commented 3 years ago

You can make use of the typingStart event, and using Channel.startTyping()

DJKieranl29 commented 3 years ago

Ok how do i make that work in the users dm and stuff? can u send me an example command?>?

DJKieranl29 commented 3 years ago

Please dm kieranl29#3675 a resolve if u can when you are next on! Thanks.

Cyanic76 commented 3 years ago

I wrote some code I haven't tested yet, and I'll edit it if it doesn't work, but here goes:

client.on("typingStart", async (channel, user) => {

  // channel must be DM and user must be human
  if(!channel.type === "dm" || user.bot) return;

  var support = await dbTable.get(`supportChannel_${message.channel.id}`);
  let supportUser = client.users.cache.get(support.targetID);
  supportUser.dmChannel.startTyping()
});

also add this before this and this:

supportUser.dmChannel.stopTyping();
DJKieranl29 commented 3 years ago

I am so comfused i am local hosting it can u make it without all the random comfusing comments?

I want it so that if a user is typing to the bot the bot startstyping in the users channel If the staff are typing in the users ticket, the bot starts typing in the dms.

Cyanic76 commented 3 years ago

There you go

DJKieranl29 commented 3 years ago

Where do you suggest i put it in the bot.js?

DJKieranl29 commented 3 years ago

Could this work??


    client.on("typingStart", async (channel, user) => {

      // channel must be DM and user must be human
      if (!channel.type === "dm" || user.bot) return;

      var support = await dbTable.get(`supportChannel_${message.channel.id}`);
      let supportUser = client.users.cache.get(support.targetID);
      supportUser.dmChannel.startTyping()
      setTimeout(function () {
        supportUser.dmChannel.stopTyping();
      }, times);
    });
Cyanic76 commented 3 years ago

Yep, you'd need to define times though. And the "Bot is typing..." would stay for x seconds, not until the message gets sent

DJKieranl29 commented 3 years ago

How in the world do i do that one?

Cyanic76 commented 3 years ago
client.on("typingStart", async (channel, user) => {
  let times = 5000; // 5 seconds
  if (!channel.type === "dm" || user.bot) return;
  var support = await dbTable.get(`supportChannel_${message.channel.id}`);
  let supportUser = client.users.cache.get(support.targetID);
  supportUser.dmChannel.startTyping()
  setTimeout(() => {
    supportUser.dmChannel.stopTyping();
  }, times);
});
DJKieranl29 commented 3 years ago

When i added what u put it fucked up the bot

Cyanic76 commented 3 years ago
client.on("typingStart", async (channel, user) => {
  let times = 5000; // 5 seconds
  if (channel.type === "dm" || user.bot) return;
  var support = await dbTable.get(`supportChannel_${message.channel.id}`);
  let supportUser = await client.users.fetch(support);
  supportUser.dmChannel.startTyping()
  setTimeout(() => {
    supportUser.dmChannel.stopTyping();
  }, times);
});
stale[bot] commented 3 years ago

This issue was marked as stale because it had no activity during the past 2 weeks. If this issue keeps being inactive, it will get closed in 3 days. Thanks for your contributions!

stale[bot] commented 3 years ago

This issue was closed due to inactivity. Thanks for your contributions!