Releases: Rodentman87/slashasaurus
v0.8.1
This is a fairly small patch that fixes some issues with the type for a channel option that caused the types to break if you tried to specify an array of valid channel types
v0.8.0: Localization and TemplateModals
Version 0.8.0 adds support for command localization when defining your slash commands and context menu commands.
It also adds a new system called TemplateModals. TemplateModals work almost like slash commands, you can create a modal with templated strings similar to handlebars and pass a handler.
import { TemplateModal } from "slashasaurus";
const MyModal = new TemplateModal(
"My Modal for {{user}}",
"my-modal",
[
{
customId: "textInput",
label: "Text Input for {{user}}",
required: true,
placeholder: "This is some placeholder text with a {{variable}}",
},
{
customId: "textInput2",
label: "Text Input 2",
required: false,
placeholder:
"This is some placeholder text with a {{variable}} and {{variable2}}",
},
{
customId: "textInput3",
label: "Text Input 3",
required: false,
style: "PARAGRAPH",
value: "Text preset with a {{user}}",
},
{
customId: "textInput4",
label: "Text Input 4",
required: true,
minLength: 5,
maxLength: 10,
},
] as const,
(interaction, values) => {
interaction.reply({
content: `You entered:\n\`\`\`\n${JSON.stringify(
values,
null,
4
)}\n\`\`\``,
ephemeral: true,
});
}
);
export default MyModal;
then register all your modals from a folder, similar to commands or Pages.
client.registerModalsFrom(path.join(__dirname, "modals"));
and finally, send the modal from an interaction:
import { SlashCommand } from "slashasaurus";
import MyModal from "../../modals/CustomModal";
export default new SlashCommand(
{
name: "modal",
description: "See a cool TemplateModal",
options: [],
},
{
run: async (interaction) => {
interaction.showModal(
MyModal.getModal({
user: interaction.user.tag,
variable: "variable",
variable2: "variable2",
})
);
},
}
);
(plus, the variables you pass into getModal
are fully typed to match your template strings, so if you ever change them you'll know right away if any calls to get the modal are missing a variable)
v0.7.0 Discord.js 13.7 support
This version adds support for attachment options that came with discord.js v13.7, simply upgrade and you're on your way! Also, there's a new tool I just released for setting up the boilerplate for a slashasaurus bot, simply run npx create-slashasaurus-app
, follow the prompts, and you're good to go!
v0.6.0 New Page hooks
Version 0.6.0 adds two new hooks for pages, pageDidSend
and pageWillLeaveCache
. Simply specify one or both of those methods on your Page and they will run. pageDidSend
will be triggered only when the Page is first sent, or when it is first transitioned to from another Page. pageWillLeaveCache
will be triggered when the Page leaves the cache. These allow you to run one time operations as well as clean up things like timers that may exist on your Pages in order to prevent memory leaks.
v0.5.2 Fixes for updating Pages
There was a small bug introduced with 0.5.1 that caused multiple calls to setState
after a page interaction to throw an error, this has been fixed with this version.
There was another bug where if content wasn't explicit set to null
on a Page, content wouldn't be cleared when updating to a newer version of a Page this has also been fixed with this version.
v0.5.1 Small fixes for calling setState and bots without the `bot` scope
Adds a small fix for calling setState
if the latest interaction hasn't been deferred. Previously, this would cause an issue since the update didn't use a normal interaction response update and Discord wouldn't allow the update to occur since there was no initial reply. Now, it will check if the latest interaction has been replied to and use an update response if it hasn't.
⚠️ Note: If you do want to callinteraction.deferUpdate()
, make sure you await it before callingsetState
next.
Slashasaurus also no longer pulls the command manager for you dev guild from the cache. This should fix an issue when trying to register guild commands on a bot without the bot
scope in guilds.
v0.5.0 Autocomplete transformers
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 string into a Date before it is passed to the handler. Use and autocomplete option that searches something from your database? Now you can get the database object passed right into the handler.
v0.4.5
- Add fix for async render functions
- Fix for some issues related to children of
PageActionRow
s
v0.4.4
This release features a rewrite of the Page cache to fix some major issues with it as well as reduce resource usage of the cache. It also features more bugfixes with embed comparison (who knew there was so many quirks with embeds?)
There are no API changes so it should drop in just fine, simply install it and restart your bot.
v0.4.1: Some small bugfixes
- 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.