diff options
| author | Max Isom <[email protected]> | 2020-03-27 17:14:08 -0500 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2020-03-27 17:14:08 -0500 |
| commit | 7703506aae30e56ca668d078f72cc5e8abe843d8 (patch) | |
| tree | cfc4d2775112693baa7a5fca51bc52ee376e7b19 /src/events | |
| parent | a2950ed722d5ed1f0e3d31922d796836ec1b18da (diff) | |
| download | muse-7703506aae30e56ca668d078f72cc5e8abe843d8.tar.xz muse-7703506aae30e56ca668d078f72cc5e8abe843d8.zip | |
Bump dependencies and add typing event handler
Diffstat (limited to 'src/events')
| -rw-r--r-- | src/events/handle-typing-start.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/events/handle-typing-start.ts b/src/events/handle-typing-start.ts new file mode 100644 index 0000000..603d2bd --- /dev/null +++ b/src/events/handle-typing-start.ts @@ -0,0 +1,21 @@ +import {Channel, TextChannel, PartialDMChannel, User, PartialUser} from 'discord.js'; + +const WAIT_TIME_SECONDS = 12; + +export default (channel: Channel | PartialDMChannel, user: User | PartialUser): void => { + if (channel.type !== 'text') { + return; + } + + const textChannel = channel as TextChannel; + + setTimeout(async () => { + if (user.typingIn(channel)) { + const msg = await textChannel.send(`take your time why don'tcha <@${user.id}>`); + + setTimeout(async () => { + await msg.delete(); + }, 2000); + } + }, WAIT_TIME_SECONDS * 1000); // Discord sends typing updates every 10s +}; |
