don't know how to go about getting rid of this

i'm not sure what to put in my memberActivity?.name field to make it show whatever the user is playing other than "custom status" when they have a custom status, but are actually playing another game. this is the setup of that part:
const memberInfo = new EmbedBuilder()
.setAuthor({ name: `${isUser.username} is ${memberStatus}!`, iconURL: statuses[memberStatus] })
.setTitle(bold(activities[memberActivity?.type[0]] || 'playing ') + italic(bold(memberActivity?.name || 'nothing')))
.setDescription('\n')
.setColor(0x2d251f)
.setThumbnail(`${isUser.displayAvatarURL()}`)
.setDescription('\n')
.addFields(
{ name: bold('ID:'), value: `${isUser.id}` },
{ name: bold('Nickname:'), value: `${isMember.nickname || 'none'}` },
{ name: bold('Joined: '), value: dayjs(`${isMember.joinedAt}`).format('<t:X>') },
{ name: bold('Created:'), value: dayjs(`${isUser.createdAt}`).format('<t:X>') })
.setFooter({ text: `Requested by ${isUser.username}`, iconURL: `${isUser.displayAvatarURL()}` });
if (memberStatus === 'dnd') {
memberInfo.setAuthor({ name: `${isUser.username} is on ` + memberStatus.toUpperCase() + '!', iconURL: statuses[memberStatus] });
await interaction.reply({ embeds: [memberInfo], content: `${defaultMsg}` });
}
else if (memberStatus) {
await interaction.reply({ embeds: [memberInfo], content: `${defaultMsg}` });
}
else if (memberActivity.type[4]) {
memberInfo.setDescription(memberActivity?.type[4].state);
await interaction.reply({ embeds: [memberInfo], content: `${defaultMsg}` });
}
},
};
const memberInfo = new EmbedBuilder()
.setAuthor({ name: `${isUser.username} is ${memberStatus}!`, iconURL: statuses[memberStatus] })
.setTitle(bold(activities[memberActivity?.type[0]] || 'playing ') + italic(bold(memberActivity?.name || 'nothing')))
.setDescription('\n')
.setColor(0x2d251f)
.setThumbnail(`${isUser.displayAvatarURL()}`)
.setDescription('\n')
.addFields(
{ name: bold('ID:'), value: `${isUser.id}` },
{ name: bold('Nickname:'), value: `${isMember.nickname || 'none'}` },
{ name: bold('Joined: '), value: dayjs(`${isMember.joinedAt}`).format('<t:X>') },
{ name: bold('Created:'), value: dayjs(`${isUser.createdAt}`).format('<t:X>') })
.setFooter({ text: `Requested by ${isUser.username}`, iconURL: `${isUser.displayAvatarURL()}` });
if (memberStatus === 'dnd') {
memberInfo.setAuthor({ name: `${isUser.username} is on ` + memberStatus.toUpperCase() + '!', iconURL: statuses[memberStatus] });
await interaction.reply({ embeds: [memberInfo], content: `${defaultMsg}` });
}
else if (memberStatus) {
await interaction.reply({ embeds: [memberInfo], content: `${defaultMsg}` });
}
else if (memberActivity.type[4]) {
memberInfo.setDescription(memberActivity?.type[4].state);
await interaction.reply({ embeds: [memberInfo], content: `${defaultMsg}` });
}
},
};
17 Replies
d.js toolkit
d.js toolkit16mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
beck
beckOP16mo ago
i have been working on this for a few days and can't seem to figure it out honestly
edocsil
edocsil16mo ago
Activity.state is the text of the custom status
beck
beckOP16mo ago
yeah, i changed it a bit, my issue is how the title gets overriden to "playing Custom Status" when the user isn't playing anything, but has a custom status
beck
beckOP16mo ago
i did originally intend for it to only put a description of an actual custom status but it's fine ig
edocsil
edocsil16mo ago
"Custom Status" is the name of the activity, "test" is the state of that activity
edocsil
edocsil16mo ago
Activity.type isn't an array either so I'm not surprised that this isn't evaluating correctly
activities[memberActivity?.type[0]] || 'playing '
activities[memberActivity?.type[0]] || 'playing '
beck
beckOP16mo ago
it wasn't, i edited it just now lol
beck
beckOP16mo ago
the top message is how i intend for the title to look when there is just a custom status set, the description of the second is what i want to be in that top message
beck
beckOP16mo ago
if that makes sense but i haven't been able to if the custom status out correctly, i only thought of doing a bajillion if statements but i don't think it's necessary to do that idk
edocsil
edocsil16mo ago
So if there's a custom status you want the title to just be the status, otherwise "playing <thing>"?
beck
beckOP16mo ago
nah i want the description to be the status, and the title to say "playing nothing" if they're playing nothing, but "playing x" if they're playing an actual thing idk how to say that less confusingly
edocsil
edocsil16mo ago
Sometimes building it with if statements is a good starting point instead of jumping to using short circuits and other things that are less obvious to read
beck
beckOP16mo ago
i think my main issue at this point is that i'm unsure how to work out the name part that wants to say "Custom Status" because i don't think isMember?.presence?.activities[!4].name (4 being the custom status) is a thing, i can't really remember actually it might just be [4]? but then it just does playing nothing, idk, i'll mess around w it a bit more
beck
beckOP16mo ago
i was going off of this
beck
beckOP16mo ago
maybe i misunderstood that part it seems to think that the "type" of a custom status is Playing in my code
beck
beckOP16mo ago
i've gotten it to work how i wanted with .find, tysm ^^ i ended up doing const activityName = isMember?.presence.activities.find(activity => activity.type !== 4); for .setTitle(bold(activities[activityName?.type] || 'Playing ') + italic(activityName?.name || 'nothing')) and .setDescription((isMember?.presence.activities.find(activity => activity.type === 4)?.state || 'Set a custom status!')) for the description & that's exactly what i needed
Want results from more Discord servers?
Add your server