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

28 messages · Page 1 of 1 (latest)

blissful laurel
#

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}` });
        }
    },
};```
young grottoBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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!
blissful laurel
#

i have been working on this for a few days and can't seem to figure it out honestly

old ruin
#

Activity.state is the text of the custom status

blissful laurel
#

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

#

i did originally intend for it to only put a description of an actual custom status but it's fine ig

old ruin
#

"Custom Status" is the name of the activity, "test" is the state of that activity

#

Activity.type isn't an array either so I'm not surprised that this isn't evaluating correctly
activities[memberActivity?.type[0]] || 'playing '

blissful laurel
#

it wasn't, i edited it just now lol

#

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

#

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

old ruin
#

So if there's a custom status you want the title to just be the status, otherwise "playing <thing>"?

blissful laurel
#

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

old ruin
#

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

blissful laurel
#

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

pastel nova
#

activities is an array of the activities the user has set currently. That usually will contain 0-2 entries. You‘d need to .find the one having type: ActivityType.Custom (or rather find one that doesn’t have that type) and get its name

#

Accessing the index 4 would mean it has 5 items which it definitely never does, no user can have 5 activities at the same time

blissful laurel
#

i was going off of this

#

maybe i misunderstood that part

#

it seems to think that the "type" of a custom status is Playing in my code

pastel nova
#

I have no idea how you defined memberActivity, activities, etc. there. But <Activity>.type is no array so accessing [0] on it would be undefined, not anything useful