Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

discord.js v13 afk command

client.on("interactionCreate", interaction => {
  if(interaction.command && interaction.customId === "afk"){
  		const reason = interaction.options.getString('reason')
const redis = require('quickredis-db')
const db = redis.createClient(process.env.redis)

db.set(`${interaction.user.id}_afk`, "true")
if(reason) { db.set(`${interaction.user.id}_afkreason`, `${reason}`) }
interaction.reply({
	content: 'Okay!'
})
  }
})
client.on("messageCreate", async msg => {
	const isafk = await db.get(`${msg.author.id}_afk`)
  if(isafk === "true") {
		msg.reply("Welcome back from AFKness!")
		db.delete(`${msg.author.id}_afk`)
		db.delete(`${msg.author.id}_afkreason`)
	} else {
		const user = msg.mentions.users.first()
		if(!user) return;
		const afk = await db.get(`${user.id}_afk`)
		if(afk === "true") {
			const afkreason = await db.get(`${user.id}_afkreason`)
			if(!afkreason) return msg.reply(`${user.tag} is AFK!`)
			if(afkreason) return msg.reply(`${user.tag} is afk
`${afkreason}``)
		}
	}
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: supabase realtime connection 
Javascript :: erpnext date difference client script 
Javascript :: nodejs cors 
Javascript :: vscode new file crlf 
Javascript :: momentjs isomonth 
Javascript :: disable click extra collapse antd 
Javascript :: React uses _____________ syntax. 
Javascript :: javascript class prototype 
Javascript :: get position/offset of element relative to a parent container 
Javascript :: Membuat contact di google contact dengan google app script, sync ke android. 
Javascript :: jquery escape 
Javascript :: Handle Race Condition in Node Js using Mutex 
Javascript :: dangerously meaning 
Javascript :: how to see a mongo document in a pretty mode 
Javascript :: self excuting arrow function 
Javascript :: js particles without plugin 
Javascript :: gsap cdn not working 
Javascript :: To enable server-to-server and REST tools like Postman to access our API - 
Javascript :: date et heure javascript 
Javascript :: create a friend component react js 
Javascript :: what is renderer in three.js 
Javascript :: Tow sums 
Javascript :: react using props and parent state 
Javascript :: Combine multiple JSONs Into One 
Javascript :: how to create element with class in javascript 
Javascript :: ajaxpost 
Javascript :: netsuite get search column value suitescript 
Javascript :: js calculate hours between two times 
Javascript :: hide Card Number Format 
Javascript :: modalInstance.result.then when execute 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =