Skip to content

Instantly share code, notes, and snippets.

@alex-taxiera
Created August 26, 2019 18:09
Show Gist options
  • Save alex-taxiera/6ac0d186ff91b1aed4be47361d2b0f78 to your computer and use it in GitHub Desktop.
Save alex-taxiera/6ac0d186ff91b1aed4be47361d2b0f78 to your computer and use it in GitHub Desktop.
Simple typing management for d.js v12
const {
TextChannel,
DMChannel
} = require('discord.js')
function isTextBasedChannel (channel) {
return channel instanceof TextChannel || channel instanceof DMChannel
}
module.exports = function (channel, limit) {
if (!channel || !isTextBasedChannel(channel)) {
throw new TypeError('CHANNEL_TYPE')
}
if (ms && (isNaN(ms) || ms < 0) {
throw new RangeError('TYPING_LIMIT')
}
setTimeout(() => {
channel.stopTyping(true)
}, limit || 1000)
return channel.startTyping(Infinity)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment