Skip to content

Modmail embed failing to update#701

Merged
Ragviswa merged 18 commits intomasterfrom
husky/modmail-no-update-embed-fix
Feb 12, 2024
Merged

Modmail embed failing to update#701
Ragviswa merged 18 commits intomasterfrom
husky/modmail-no-update-embed-fix

Conversation

@tro2
Copy link
Copy Markdown
Contributor

@tro2 tro2 commented Feb 7, 2024

ViBot 8.14.0

Changelog

Changes

  • Modmail interactions backend has been almost completely overhauled. Interactions themselves have not changed and should work as expected, however the code should be much more manageable & less bug prone.
  • ;modmailclose was removed.

Bugs

  • Modmail embed not being updated when user message is replied to

Quality of Life

  • Cleaner, more accessible code
  • Staff can now add attachments when replying to a message, both as a button response and using ;mmr
  • ;mmr now uses the same function as pressing the Send Message button so it now acts exactly as if you pressed it.
  • modmail.js and modmailRespond.js have been fixed for ESLint errors.
  • Modmail buttons no longer use unnecessary collectors on ;restart.

Summary

Overview

Examples

Send Message response with attachment and no text, followed by ;mmr with text and attachments
image

What users see
image
image

husky-rotmg and others added 6 commits February 5, 2024 20:33
- Removed several collectors
- Reduced indent creep
- Split up individual interaction logic into their own functions
- Resolved any multiple uses of `interaction.update`/`interaction.reply`
- Embed-ified certain responses
- Security can now directly add attachments in response to a modmail

This is completely untested as of this commit
This is the start of a potential solution for the confirm interaction bugs, see dev lounge for a more detailed write up
# botSetup.js
- vibotChannels was not actually passed a db argument

# extensions.js
- Rearranged some logic in `TextChannel.next` to ensure message is deleted even when cancelled
- Removed unnecessary `result = message = message.delete()`

# modmailRespond.js
- Now uses `Modmail.send` from modmail.js, this includes adding attachments

# modmail.js
- Added `.then(resp => resp.fetch())` whenever we receive an InteractionResponse instead of a Message
- Confirmed all buttons work as intended
- Confirmed replying with attachments works with and without text
@ghost ghost changed the title [HELP NEEDED] Modmail embed failing to update Modmail embed failing to update Feb 7, 2024
@ghost ghost self-assigned this Feb 7, 2024
@ghost ghost linked an issue Feb 7, 2024 that may be closed by this pull request
2 tasks
@ghost ghost marked this pull request as ready for review February 7, 2024 19:08
@ghost ghost self-requested a review as a code owner February 7, 2024 19:08
@ghost
Copy link
Copy Markdown

ghost commented Feb 7, 2024

This PR should now be ready for a classical review.

- Now shows image if only 1 attachment that is an image
- logCommand.js now uses developerId instead of vi's id
Comment thread commands/modmail.js Outdated
.setFooter({ text: 'Type \'cancel\' to cancel' })
.setColor(Discord.Colors.Blue);

const confirmResponse = await interaction.reply({ embeds: [confirmEmbed] }).then(resp => resp.fetch());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there's a fetchReply boolean flag you can set to true for the reply method that allows you to automatically fetch the reply you send.

Copy link
Copy Markdown
Contributor

@Ragviswa Ragviswa left a comment

Choose a reason for hiding this comment

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

I love the direction modmail has been refactored to so far. It's definitely a lot easier to read and follow compared to before. There are some areas which I feel would make the refactor even better than it is. The only reason I have given this much constructive feedback because I can see the potential for the modmail system with the new refactor.

  • Could we use await wherever there is a promised function, just to be consistent. I see some promised functions like delete and edit aren't always awaited
  • I would prefer if we were more selective about the arguments being passed into the Modmail functions. There are instances where not all arguments are used, the argument names are inconsistent, or we use alternative means to access arguments instead of the direct variable.
  • It would be nice if we used exit conditions for the Modmail functions as opposed to nesting as it makes the code flow easier to understand.
  • Minor, but if we could group embeds together and reduce new-lines to separate functions affecting the same embed, it would help with mentally separating each embed constructor.
  • Do you mind taking modmail.js out of .eslintignore to fix the minor styling issues? Understandable if this is too much work though.

Comment thread lib/logCommand.js Outdated
Comment thread lib/extensions.js Outdated
Comment thread commands/modmail.js Outdated
Comment thread commands/modmail.js Outdated
Comment thread commands/modmail.js Outdated
Comment thread commands/modmail.js Outdated
Comment thread commands/modmail.js Outdated
Comment thread commands/modmail.js Outdated
Comment thread commands/modmail.js Outdated
Comment thread commands/modmail.js Outdated
husky-rotmg and others added 6 commits February 10, 2024 14:30
Co-authored-by: Raghav Viswakumar <59955668+Ragviswa@users.noreply.github.com>
- Moved module.exports to the bottom
- some small style-based changes
- Moved sending modmail reply to user to a function
- Moved destructuring in modmail functions to function declaration
- removed various little-used/uselessly mapped values from the ModmailData structure
- Using `fetchReply: true` instead of `.then(res => res.fetch())`
- Changed forwarding confirmation message to match send response confirmation
- Added await to mmbl check in sendModMail function
- removed modmail from eslintignore
- removed commented out `modmail.init` call
- moved `modmail.js` to the `lib` folder
- Removed individual collectors for modmails in favor of forwarding `modmail*` buttons in `index.js`
- Removed unused execute from modmail
- cleaned up eslint for `modmail.js`
- Modmails now allow more than 1 image to be sent as a modmail
- All vibot messages should now be embeds
@ghost ghost requested a review from Ragviswa February 12, 2024 18:14
husky-rotmg and others added 5 commits February 12, 2024 13:44
Keep button state after restart, no need to reset to 'unlock'
- Deleted modmailclose command
- Refactored modmailRespond
- Removed modmailRespond from eslintignore
Copy link
Copy Markdown
Contributor

@Ragviswa Ragviswa left a comment

Choose a reason for hiding this comment

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

Massive W to readability + code cleanliness. Big TY

@Ragviswa Ragviswa merged commit 1bb2e31 into master Feb 12, 2024
@ghost ghost mentioned this pull request Feb 12, 2024
2 tasks
@Thomasc33 Thomasc33 unassigned ghost Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#mod-mail-review not updating embed upon reply

2 participants