Skip to content

Adding the /modmail command - #493

Merged
Zabuzard merged 45 commits into
developfrom
feature/modMailCommand
Oct 20, 2022
Merged

Zabuzard merged 45 commits into
developfrom
feature/modMailCommand

Conversation

@DevSerendipity

@DevSerendipity DevSerendipity commented Aug 13, 2022 •

Copy link
Copy Markdown
Contributor

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

The messages related to the mode Utils

image

Config

Added:

"modMailChannelPattern": "modmail"

@DevSerendipity

Copy link
Copy Markdown
Contributor Author

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

@marko-radosavljevic

Copy link
Copy Markdown
Contributor

Thanks ❤️

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

Copy link
Copy Markdown
Contributor

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? ☺️

@DevSerendipity

Copy link
Copy Markdown
Contributor Author
  • 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

@mikerasch

mikerasch commented Aug 14, 2022 •

Copy link
Copy Markdown
Contributor

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

@DevSerendipity

DevSerendipity commented Aug 14, 2022 •

Copy link
Copy Markdown
Contributor Author

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();

@Taz03 Taz03 linked an issue Aug 14, 2022 that may be closed by this pull request
@Taz03 Taz03 added new command Add a new command or group of commands to the bot priority: normal labels Aug 14, 2022
@marko-radosavljevic

Copy link
Copy Markdown
Contributor

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

marko-radosavljevic commented Aug 14, 2022 •

Copy link
Copy Markdown
Contributor

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. ☺️

@DevSerendipity

Copy link
Copy Markdown
Contributor Author

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
DevSerendipity marked this pull request as ready for review August 16, 2022 08:06
@DevSerendipity
DevSerendipity requested review from a team as code owners August 16, 2022 08:06
@DevSerendipity

Copy link
Copy Markdown
Contributor Author

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

@marko-radosavljevic

Copy link
Copy Markdown
Contributor

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.

@DevSerendipity

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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

@marko-radosavljevic

Copy link
Copy Markdown
Contributor

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! ☺️
  • 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. ❤️

@Zabuzard Zabuzard left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sth seems broken. it cant send DMs anymore due to:

java.lang.IllegalArgumentException: Command 'modmail' does not exist in guild 884866931784572949

gotta investigate

@Taz03

Taz03 commented Oct 19, 2022

Copy link
Copy Markdown
Contributor

is the ui still the same? the embed?

@Taz03

Taz03 commented Oct 19, 2022

Copy link
Copy Markdown
Contributor

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

@Tais993 Tais993 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm almost satisfied, just missing slashcommand mentions still.

@Zabuzard
Zabuzard force-pushed the feature/modMailCommand branch from d40ab31 to 0e46dcd Compare October 19, 2022 14:11
Zabuzard
Zabuzard previously approved these changes Oct 19, 2022
Co-authored-by: Tais993 <49957334+Tais993@users.noreply.github.com>
@Zabuzard
Zabuzard force-pushed the feature/modMailCommand branch from de7bfa5 to 8da2eca Compare October 19, 2022 14:14
Zabuzard
Zabuzard previously approved these changes Oct 19, 2022
@Zabuzard
Zabuzard requested a review from Tais993 October 19, 2022 14:19
@DevSerendipity

Copy link
Copy Markdown
Contributor Author

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

@Taz03

Taz03 commented Oct 19, 2022

Copy link
Copy Markdown
Contributor

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

@DevSerendipity

Copy link
Copy Markdown
Contributor Author

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

That was resolved, the UI is good enough

@Taz03

Taz03 commented Oct 19, 2022

Copy link
Copy Markdown
Contributor

its not

@Zabuzard

Copy link
Copy Markdown
Member

its not

this PR is about adding /modmail. not improving the DM UI. also, we agreed on using modals in a second iteration for /modmail, not in the first. the scope of this PR is already way too large anyways. we wrap it up here.

@Zabuzard Zabuzard self-assigned this Oct 20, 2022
@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Zabuzard
Zabuzard dismissed Taz03’s stale review October 20, 2022 08:48

stuff was done

@Zabuzard
Zabuzard merged commit 16fd842 into develop Oct 20, 2022
@Zabuzard
Zabuzard deleted the feature/modMailCommand branch October 20, 2022 08:50
@Zabuzard Zabuzard mentioned this pull request Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new command Add a new command or group of commands to the bot priority: normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create /modmail command

8 participants