This is a small update on the surface but that hugelly improve the typings.
Now templates can have a values
field the defines the values they are waiting, this will allow you to have autocompletion for the values
argument, but because of Typescript behaviors you have to cast the template for a custom template and it cannot work if you use the name.
Example :
import {BetterEmbed, templates} from 'discord.js-better-embed';
import type {Template} from 'discords.js-better-embed';
// Create your template, you could also set the fields of the Template but it's not used anywhere so no need for that
type MyTemplate = Template<{text: string, bar: string}>
// Add the property to the 'templates' object
interface templates {
myTemplate: MyTemplate
}
// Setup the template
templates.myTemplate = {
description: 'Hi ${bar} ! You have ${text.length} bits.'
}
// create your embed
// if you use the name it cannot be casted
const embed = BetterEmbed.fromTemplate(templates.myTemplate as MyTemplate, {text: 'foo', bar: 'baz' });
// but you can do this
const embed = BetterEmbed.fromTemplate<'myTemplate', MyTemplate['values']>('myTemplate', {text: 'foo', bar: 'baz' });
// you can also use it like this :
const embed = BetterEmbed.fromTemplate(templates.myTemplate as templates['myTemplate'], {text: 'foo', bar: 'baz' });
// as it will use the interface types
Thanks to the people using this library !
📆 09.08.2021
🏷️ 1.3.0
💾 C52F54D
🚀 1
📚 1
✏️ 1
👥 1