Skip to content

Commit

Permalink
Fix for multiple calls to setState after a single interaction and cle…
Browse files Browse the repository at this point in the history
…aring content without explicit null on a page
  • Loading branch information
Rodentman87 committed Apr 26, 2022
1 parent 93e2d87 commit 284dafd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 57 deletions.
57 changes: 2 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p>
<a href="https://discord.gg/hqtbXzry3h"><img src="https://img.shields.io/discord/939038490023301150?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
<a href="https://www.npmjs.com/package/slashasaurus"><img src="https://img.shields.io/npm/v/slashasaurus.svg?maxAge=3600" alt="npm version" /></a>
<a href="https://rodentman87.gitbook.io/slashasaurus/"><img src="https://img.shields.io/badge/docs-lightgrey.svg?maxAge=3600&logo=gitbook" alt="Gitbook" /></a>
<a href="https://rodentman87.gitbook.io/slashasaurus/"><img src="https://img.shields.io/badge/docs-grey.svg?maxAge=3600&logo=gitbook" alt="Gitbook" /></a>
</p>
</div>

Expand All @@ -15,21 +15,6 @@ Slashasaurus is a command framework built on top of Discord.js. It's inspired by

It is _strongly_ recommended that you use [TypeScript](https://www.typescriptlang.org/) with this library, however, it is not a requirement. The quick start is written in TypeScript, most information should be very similar for vanilla JS.

## Table of Contents

- [Installation](#installation)
- [Docs](#docs)
- [Latest Changelogs](#latest-changelogs)
- [0.5.0](#050)
- [0.4.6](#046)
- [0.4.5](#045)
- [0.4.4](#044)
- [0.4.3](#043)
- [0.4.2](#042)
- [0.4.1](#041)
- [0.4.0](#040)
- [0.3.0](#030)

## Installation

To start a new project with Slashasaurus, you need to install discord.js as well as slashasaurus.
Expand All @@ -50,42 +35,4 @@ See [discord.js's readme](https://github.com/discordjs/discord.js#optional-packa

## Latest Changelogs

### 0.5.0

Custom `transformer`s for autocomplete options! Now, you can specify a `transformer` function on an autocomplete option to transform the value before it is passed to the handler. (And the types will still be correct!) Have a custom autocomplete for dates? Now you can transform the date before it is passed to the handler. Autocomplete option that uses fuzzy search on something from your database? Now you can get the database object passed right into the handler.

### 0.4.6

Hopefully the last round of fixes with comparing messages is done. There's lots of little weird quirks with Discord's API that need to be accounted for. This update also updates the message data when a component on an ephemeral Page is used. This allows the Page to be useful beyond the initial 15 minutes of the interaction that triggered the Page.

### 0.4.5

- Add fix for async render functions
- Fix for some issues related to children of `PageActionRow`s

### 0.4.4

- More fixes related to Pages and caching
- Fix for a couple more comparison issues on embeds

### 0.4.3

- A couple small fixes with converting TSX and the `{condition && ...}` syntax

### 0.4.2

- A couple small fixes when detecting whether or not a Page was updated after a reload from persistent storage.
- Specifically dealing with emoji and labels in buttons and colors in embeds

### 0.4.1

- A couple small fixes when detecting whether or not a Page was updated after a reload from persistent storage.
- Added support for using `{condition && ...}` inside jsx.

### 0.4.0

Added support for specifying an `onAutocomplete` handler for autocomplete args. This allows for easily re-usable autocomplete handlers for things that may be common across multiple commands in your bot.

### 0.3.0

Added TSX support, see the end of the Pages section for details
Check out the [releases on GitHub](https://github.com/Rodentman87/slashasaurus/releases) for the latest changelogs.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slashasaurus",
"version": "0.5.1",
"version": "0.5.2",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
Expand Down
4 changes: 3 additions & 1 deletion src/SlashasaurusClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,8 @@ export class SlashasaurusClient extends Client<true> {
const renderedPage = await page.render();
if (!compareMessages(interaction.message, renderedPage)) {
await interaction.update({
content: null,
embeds: null,
...renderedPage,
components: renderedPage.components
? pageComponentRowsToComponents(renderedPage.components, page)
Expand Down Expand Up @@ -995,7 +997,7 @@ export class SlashasaurusClient extends Client<true> {
if (
message instanceof PageInteractionReplyMessage &&
page.latestInteraction &&
!page.latestInteraction.deferred
!(page.latestInteraction.deferred || page.latestInteraction.replied)
) {
await page.latestInteraction.update({
...messageOptions,
Expand Down

0 comments on commit 284dafd

Please sign in to comment.