Skip to content

Instantly share code, notes, and snippets.

@Nevexo
Last active August 2, 2018 23:54
Show Gist options
  • Save Nevexo/184ababa4f9c132f3d6b8815f080b8fa to your computer and use it in GitHub Desktop.
Save Nevexo/184ababa4f9c132f3d6b8815f080b8fa to your computer and use it in GitHub Desktop.
Honestly the worst code - but fun as HECK inspired by https://twitter.com/leinweber/status/989267343002951680 it does that but in discord
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
let dict = {}
const channels = ["309127154220924929", "441778887064813568", "309894498119319564"] // Place channel IDs in here to monitor - all Dms are monitored by default
client.on('typingStart', (channel, user) => {
if (user.id != client.user.id) {
if (channels.indexOf(channel.id) > -1 ) {
if (dict[channel.id] != true) {
console.log("[INTERACTION] " + user.tag + " started typing...")
console.log(" -> GUILD - Start typing... " + channel.name + " (" + user.tag + ")")
dict[channel.id] = true
channel.startTyping()
}
}
if (user.dmChannel != undefined) {
if (dict[user.id] != true) {
console.log(" -> DM - Sending type indicator to " + user.tag)
dict[user.dmChannel] = true
user.dmChannel.startTyping()
}
}
}
})
client.on("typingStop", (channel, user) => {
if (user.id != client.user.id) {
if (channels.indexOf(channel.id) > -1 ) {
console.log("[INTERACTION] " + user.tag + " stopped typing.")
console.log(" -> GUILD - Stop typing " + channel.name + " (" + user.tag + ")")
dict[channel.id] = false
channel.stopTyping()
}
if (user.dmChannel != undefined) {
if (dict[user.dmChannel]) {
dict[user.dmChannel] = false
user.dmChannel.stopTyping()
console.log(" -> DM - Stopping type indicator " + user.tag)
}
}
}
})
client.login("Discord token")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment