Discord.js 检测用户何时输入 [英] Discord.js detect when user is typing
问题描述
是否有可能我可以检测到用户是否开始/停止输入?我使用 Discord.js Webpack 第 12 版,但似乎找不到任何解决方案?
is there a possibility I can detect If a user starts/stops typing? I use the Discord.js Webpack Version 12 and I can't seem to find any solution to this?
推荐答案
你可以使用typingStart()
事件,当用户开始输入时触发.
You can use the typingStart()
event, which will trigger when a user starts typing.
client.on('typingStart', (channel, user) => {
console.log(`${user.username} is typing in ${channel.name}`)
};
还有 用户.typingIn()
方法,该方法将检查用户是否在指定频道中输入,并返回 boolean
.
if (<user>.typingIn(<channel>))
console.log(`${<user>.username} in typing in ${<channel>.name}`);
(您也可以使用 typingDurationIn()
和 typingSinceIn()
方法)
(You can also use the typingDurationIn()
and typingSinceIn()
methods)
最后,您可以查看 TextChannel
的 >TextChannel.typing 属性,用于检测 任何人 是否在该频道中输入.
Lastly, you can look at the TextChannel.typing
property of a TextChannel
to detect if anyone is typing in that channel.
if (<channel>.typing)
console.log(`Somebody is typing in ${channel.name}`);
(您也可以使用 typingCount
属性来查看有多少人在给定频道中输入)
这篇关于Discord.js 检测用户何时输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!