! skyxjs
! skyxjs
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by ! skyxjs on 3/9/2025 in #djs-questions
I want to get the status of a member not the actual presence what am i doing wrong?
const { EmbedBuilder, ChannelType, GuildMember, ActivityType } = require('discord.js');
const guildSchema = require('../../models/guildSchema');
/**
*
* @param {GuildMember} oldMember
* @param {GuildMember} newMember
* @param {*} client
* @returns
*/
module.exports = async (oldMember, newMember, client) => {
const oldPresence = oldMember.presence;
const newPresence = newMember.presence;

if (!oldPresence || !newPresence) return;

const oldStatus = oldPresence.activities.find(activity => activity.type === ActivityType.Custom);
const newStatus = newPresence.activities.find(activity => activity.type === ActivityType.Custom);

if (oldStatus?.state === newStatus?.state) return;

const data = await guildSchema.findOne({ Guild: newMember.guild.id });

if (!data || !data.vanity || !data.vanity.Enabled) {
return;
}

const vanitySubstring = data.vanity.SubString;
if (!vanitySubstring || !newStatus?.state) return;

if (newStatus.state.includes(vanitySubstring)) {
if (data.vanity.LogChannel) {
const logChannel = newMember.guild.channels.cache.get(data.vanity.LogChannel);
if (logChannel) {
const embed = new EmbedBuilder()
.setAuthor({ name: newMember.user.username, iconURL: newMember.user.displayAvatarURL() })
.setTitle('Vanity updated')
.setDescription(`${newMember.user.username} has vanity in the custom status.`)
logChannel.send({ embeds: [embed] })
} else {
return;
}

}
}
}
const { EmbedBuilder, ChannelType, GuildMember, ActivityType } = require('discord.js');
const guildSchema = require('../../models/guildSchema');
/**
*
* @param {GuildMember} oldMember
* @param {GuildMember} newMember
* @param {*} client
* @returns
*/
module.exports = async (oldMember, newMember, client) => {
const oldPresence = oldMember.presence;
const newPresence = newMember.presence;

if (!oldPresence || !newPresence) return;

const oldStatus = oldPresence.activities.find(activity => activity.type === ActivityType.Custom);
const newStatus = newPresence.activities.find(activity => activity.type === ActivityType.Custom);

if (oldStatus?.state === newStatus?.state) return;

const data = await guildSchema.findOne({ Guild: newMember.guild.id });

if (!data || !data.vanity || !data.vanity.Enabled) {
return;
}

const vanitySubstring = data.vanity.SubString;
if (!vanitySubstring || !newStatus?.state) return;

if (newStatus.state.includes(vanitySubstring)) {
if (data.vanity.LogChannel) {
const logChannel = newMember.guild.channels.cache.get(data.vanity.LogChannel);
if (logChannel) {
const embed = new EmbedBuilder()
.setAuthor({ name: newMember.user.username, iconURL: newMember.user.displayAvatarURL() })
.setTitle('Vanity updated')
.setDescription(`${newMember.user.username} has vanity in the custom status.`)
logChannel.send({ embeds: [embed] })
} else {
return;
}

}
}
}
Error: Uncaught Exception: Error: TypeError: Cannot read properties of null (reading 'presence') Stack Trace TypeError: Cannot read properties of null (reading 'presence') at module.exports (/home/container/src/events/presenceUpdate/vanity.js:11:35) at CommandHandler.<anonymous> (/home/container/node_modules/djs-commander/dist/index.js:314:38) at Generator.next (<anonymous>) at /home/container/node_modules/djs-commander/dist/index.js:68:61 at new Promise (<anonymous>) at __async (/home/container/node_modules/djs-commander/dist/index.js:52:10) at Client.<anonymous> (/home/container/node_modules/djs-commander/dist/index.js:311:46) at Client.emit (node:events:519:28) at PresenceUpdateAction.handle (/home/container/node_modules/discord.js/src/client/actions/PresenceUpdate.js:40:19) at module.exports [as PRESENCE_UPDATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/PRESENCE_UPDATE.js:4:33)
4 replies
CC#
Created by ! skyxjs on 11/3/2024 in #help
Build single executable
No description
25 replies
DIAdiscord.js - Imagine an app
Created by ! skyxjs on 8/1/2023 in #djs-questions
Is it possible to get the last message of a guild member?
This is what I found but it doesnt seem to work:
const content = user.lastMessage.content;
const content = user.lastMessage.content;
I think its an outdated way but I dont know the latest way.
3 replies