TJ-Bot icon indicating copy to clipboard operation
TJ-Bot copied to clipboard

Adding the /modmail command

Open DevSerendipity opened this issue 2 years ago • 13 comments

Commands which redirects command called from Guild or Dm to a dedicated channel in Config#getModAuditLogChannelPattern()

Samples of message being public (can be seen which user called the command) /modmail message:test from guild without message private option message-private:true image Sample of message being private (can not be seen which user called the command) /modmail message:test from guild with message private option message-private:true image

DevSerendipity avatar Aug 13 '22 14:08 DevSerendipity

I have within the code added some code between comments and I was wondering would it be overengineering if I turned those to methods for readability and cleanness

DevSerendipity avatar Aug 13 '22 14:08 DevSerendipity

Thanks :heart:

In #311, we decided to send modmail messages to a different channel, and not #mod_audit_log. Something like 'modmail' is fine by me. You will have to make small adjustments to Config to make that happen. ^^

Also, like always, don't forget to make our pipeline checks pass!

marko-radosavljevic avatar Aug 13 '22 18:08 marko-radosavljevic

Since I haven't followed conversation on discord closely, I have a few questions about UI/UX:

  • Why are we using file attachments? Because message might be too long? If it's too long for embed, wouldn't it be too long for the command as well?
  • Would it be possible to ping the user that sent the modmail, instead of just saying 'user#123'. If user is pinged, we can just right-click and message them, or copy id, without searching for them. (User wouldn't actually be pinged, because they have no permissions to view the channel)
  • Does file extension .md mean we can send markdown modmails?

Also, maybe I'm nitpicking, but since we are discussing UI (i.e. how pretty it is)… "Modmail command invoked... Message from user... who used /modmail command". Has a lot of redundant information. Just one of these is enough. For example, 'Modmail from user#123'.

What do you think? :relaxed:

marko-radosavljevic avatar Aug 13 '22 19:08 marko-radosavljevic

  • Why are we using file attachments? Because message might be too long? If it's too long for embed, wouldn't it be too long for the command as well?

I have been told that it has be be a file or embed otherwise people could inject pings and other things

  • Would it be possible to ping the user that sent the modmail, instead of just saying 'user#123'. If user is pinged, we can just right-click and message them, or copy id, without searching for them. (User wouldn't actually be pinged, because they have no permissions to view the channel)

When I tried to retrieve the user event.getUser().getAsMention() all I get is his id <@975000935698935858> but perhaps that could work

  • Does file extension .md mean we can send markdown modmails?

Not really

Also, maybe I'm nitpicking, but since we are discussing UI (i.e. how pretty it is)… "Modmail command invoked... Message from user... who used /modmail command". Has a lot of redundant information. Just one of these is enough. For example, 'Modmail from user#123'.

What do you think? ☺️

Sounds much nicer

DevSerendipity avatar Aug 14 '22 04:08 DevSerendipity

The < @ ID> is the format to @ the user.

mikerasch avatar Aug 14 '22 04:08 mikerasch

I am not sure how to properly name this properly (since in the if statement already talks about what this code block do) or if it even needs to be turned into a method

// replies to the user who called the command if the command is on cooldown
        MessageChannel messageChannel = event.getChannel();
        if (isChannelOnCooldown(messageChannel)) {
            event
                .reply("Please wait a bit, this command can only be used once per %d %s.".formatted(
                        COOLDOWN_DURATION_VALUE,
                        COOLDOWN_DURATION_UNIT.toString().toLowerCase(Locale.US)))
                .setEphemeral(true)
                .queue();
            return;
        }
        channelIdToLastCommandInvocation.put(messageChannel.getIdLong(), Instant.now());

and this piece of code from ChangeHelpCategoryCommand

        channelIdToLastCommandInvocation = Caffeine.newBuilder()
            .maximumSize(1_000)
            .expireAfterAccess(COOLDOWN_DURATION_VALUE, TimeUnit.of(COOLDOWN_DURATION_UNIT))
            .build();

DevSerendipity avatar Aug 14 '22 04:08 DevSerendipity

I have been told that it has be be a file or embed otherwise people could inject pings and other things

Yeah, that make sense. Would it be nicer UI to have message in the embed, and just have title with "Modmail from @user"?

Not really

Knew it, but had to ask. :( One day, one day...

Thanks ^^

marko-radosavljevic avatar Aug 14 '22 18:08 marko-radosavljevic

I am not sure how to properly name this properly (since in the if statement already talks about what this code block do) or if it even needs to be turned into a method

It doesn't need a new method, but it's your choice. Like you said, from the if, it pretty clearly reads "If channel is on cooldown, notify the user and early exit"

and this piece of code from ChangeHelpCategoryCommand

Good name, I know exactly what it represents. And most importantly, it's consistent with our naming scheme for similar cache maps.


Speaking of naming and methods, I would rather have a nicely named method here:

        // this message is creating the embed

        String user = event.getUser().getAsMention();
        boolean optionalMessage =
                Objects.requireNonNull(event.getOption(OPTION_MESSAGE_PRIVATE)).getAsBoolean();
        if (optionalMessage) {
            user = "Anonymous";
        }
        MessageAction message = auditLogChannel.orElseThrow().sendMessageEmbeds(messageEmbed(user));

        message = buildAttachment(attachments, message);
        message.queue();
        // ends here

Because I need a few seconds of reading to understand what it does.

Your comment is a good giveaway that you might want a method, because it outlines an isolated piece of code, that needs additional explanation to be easily understood. :relaxed:

marko-radosavljevic avatar Aug 14 '22 19:08 marko-radosavljevic

and this piece of code from ChangeHelpCategoryCommand

Good name, I know exactly what it represents. And most importantly, it's consistent with our naming scheme for similar cache maps.

I think you misunderstood me, I was mentioning from which class I got it from, not the name I named it. But I will think of a name for it, when I do should I also change it in ChangeHelpCategoryCommand?

DevSerendipity avatar Aug 15 '22 14:08 DevSerendipity

This PR also seem to handle what #219 has mentioned so It should be linked?

DevSerendipity avatar Aug 20 '22 15:08 DevSerendipity

This PR also seem to handle what https://github.com/Together-Java/TJ-Bot/issues/219 has mentioned so It should be linked?

I think we will leave that issue for now, since use-case for report feature would be a bit different.

With report, we need additional information like the member being reported. Then message that is being replied to, so we can easily jump to the interaction, etc. Otherwise, we would have to do a lot of work to find the reported member, and comb through their history to find the offending behaviour.

marko-radosavljevic avatar Aug 20 '22 16:08 marko-radosavljevic

This PR also seem to handle what #219 has mentioned so It should be linked?

I think we will leave that issue for now, since use-case for report feature would be a bit different.

With report, we need additional information like the member being reported. Then message that is being replied to, so we can easily jump to the interaction, etc. Otherwise, we would have to do a lot of work to find the reported member, and comb through their history to find the offending behaviour.

Okay thanks for the explanation

DevSerendipity avatar Aug 20 '22 16:08 DevSerendipity

Is the code good to go? Do I need to fix anything beside the merge?

DevSerendipity avatar Sep 16 '22 18:09 DevSerendipity

Is the code good to go? Do I need to fix anything beside the merge?

Before we can merge, you have to:

  • Resolve unresolved conversations. The best way to do that is to let the reviewer know that you have done what they requested by commenting "done" and optionally pinging them, so they can resolve the review comments. If not, we can do it for you! :relaxed:
  • Resolve the merge conflict in Features.java
  • Get 2 passing reviews. I will give you my review after conflicts are resolved, and all automated checks in our pipeline pass. :heart:

marko-radosavljevic avatar Sep 16 '22 18:09 marko-radosavljevic

can we get the user's message in the embed instead of a separate file, ig that'll look better

Taz03 avatar Sep 30 '22 14:09 Taz03

Can you post some fresh demo images, want to see how's UI/UX looking ^^

marko-radosavljevic avatar Sep 30 '22 15:09 marko-radosavljevic

Can you post some fresh demo images, want to see how's UI/UX looking ^^

It still looks the same as above

DevSerendipity avatar Sep 30 '22 17:09 DevSerendipity

edit the original message instead of sending one

Taz03 avatar Sep 30 '22 17:09 Taz03

Can you post some fresh demo images, want to see how's UI/UX looking ^^

It still looks the same as above

Ah, I thought we agreed on UI/UX improvements

Would it be possible to ping the user that sent the modmail, instead of just saying 'user#123'. If user is pinged, we can just right-click and message them, or copy id, without searching for them. (User wouldn't actually be pinged, because they have no permissions to view the channel)

Also, maybe I'm nitpicking, but since we are discussing UI (i.e. how pretty it is)… "Modmail command invoked... Message from user... who used /modmail command". Has a lot of redundant information. Just one of these is enough. For example, 'Modmail from user#123'.

Why are we using file attachments? Because message might be too long? If it's too long for embed, wouldn't it be too long for the command as well

I have been told that it has be be a file or embed otherwise people could inject pings and other things

Yeah, that makes sense. Would it be nicer UI to have message in the embed, and just have title with "Modmail from @user"?

marko-radosavljevic avatar Oct 02 '22 13:10 marko-radosavljevic

Can we get a better ui?

Taz03 avatar Oct 07 '22 20:10 Taz03

I think UI/UX improved since the PR is last time updated, can you update it @DevSerendipity, so we are all on the same page? :relaxed:

Would be nice to try to do a final push on this, it's been a while. Feel free to resolve old conversations that you have already fixed.

marko-radosavljevic avatar Oct 07 '22 21:10 marko-radosavljevic

I think UI/UX improved since the PR is last time updated, can you update it @DevSerendipity, so we are all on the same page? ☺️

Would be nice to try to do a final push on this, it's been a while. Feel free to resolve old conversations that you have already fixed.

image

DevSerendipity avatar Oct 08 '22 09:10 DevSerendipity

what happens when u click the button?

Taz03 avatar Oct 08 '22 10:10 Taz03

what happens when u click the button?

You see the users profile

DevSerendipity avatar Oct 08 '22 10:10 DevSerendipity

  • [x] Think of a method for DM message duplication
  • [x] Fix a bunch of text errors

DevSerendipity avatar Oct 08 '22 19:10 DevSerendipity

is the ui still the same? the embed?

Taz03 avatar Oct 19 '22 13:10 Taz03

also y not use modals, now that we have modals. it'll be easier to write long modmails in a modal than a slash command option

Taz03 avatar Oct 19 '22 13:10 Taz03

also y not use modals, now that we have modals. it'll be easier to write long modmails in a modal than a slash command option

shhh next pr

DevSerendipity avatar Oct 19 '22 14:10 DevSerendipity

@DevSerendipity what about the ui, iirc marko suggested a better ui

Taz03 avatar Oct 19 '22 18:10 Taz03

@DevSerendipity what about the ui, iirc marko suggested a better ui

That was resolved, the UI is good enough

DevSerendipity avatar Oct 19 '22 19:10 DevSerendipity