[英]Check if a member has Custom Status containing invite link
I have tried multiple of the other threads posted maybe they are outdated?我已经尝试了多个其他帖子,也许它们已经过时了? I'm using discord.js 14.6.0 and I'd like to check if a member has custom status containing an invite link.
我正在使用 discord.js 14.6.0,我想检查成员是否具有包含邀请链接的自定义状态。
Here is my code这是我的代码
const invitelink = '.gg/VANITY';
// Status Update
client.on(Events.PresenceUpdate, (oldPresence, newPresence) => {
const member = newPresence.member
if(member){
const customStatus = member.activites
.find(activity => activity.type === 'CUSTOM_STATUS')
?.state
if (customStatus) {
if (customStatus.includes(inviteLink)) {
console.log(customStatus)
}
}
}
})
In v14, you will need to use the ActivityType
enums or numbers for activity.type
.在 v14 中,您将需要为
activity.type
使用ActivityType
枚举或数字。 For custom status you can use ActivityType.Custom
.对于自定义状态,您可以使用
ActivityType.Custom
。
You can import it from discord.js
:您可以从
discord.js
导入它:
const { Client, GatewayIntentBits, ActivityType } = require('discord.js');
And use it like this:并像这样使用它:
const customStatus = member.activites.find(
(activity) => activity.type === ActivityType.Custom
)?.state;
if (customStatus) {
if (customStatus.includes(inviteLink)) {
console.log(customStatus);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.