Skip to content
GitHub

UseTheme

function in meocord/decorator Since 4.1.0

UseTheme(theme: ThemeOverride): ClassDecorator & MethodDecorator

Sets part of the theme for a controller's handlers, or for one handler.

Use it where a controller or a handler looks different from the rest of the app. Only what it names changes; every other role keeps the value beneath it.

Parameters

NameTypeDescription
themeThemeOverride

The roles to change, in any of the theme's groups, MeoCord's or the app's.

theme.colors?{ primary?: ColorResolvable neutral?: ColorResolvable success?: ColorResolvable warning?: ColorResolvable danger?: ColorResolvable info?: ColorResolvable }

Colours by role.

theme.colors.primary?ColorResolvable

The app's own colour, for what is neither good nor bad news.

theme.colors.neutral?ColorResolvable

A quiet colour, for what needs no attention.

theme.colors.success?ColorResolvable

Something went as asked.

theme.colors.warning?ColorResolvable

Something needs the user's attention, or was refused because of what they did.

theme.colors.danger?ColorResolvable

Something failed, a fault in the bot rather than the user.

theme.colors.info?ColorResolvable

Information, with no action needed.

theme.emojis?{ loading?: string success?: string warning?: string danger?: string info?: string }

Emojis by role.

theme.emojis.loading?string

Shown while a deferred call is still working.

theme.emojis.success?string

Something went as asked.

theme.emojis.warning?string

Something needs the user's attention, or was refused because of what they did.

theme.emojis.danger?string

Something failed, a fault in the bot rather than the user.

theme.emojis.info?string

Information, with no action needed.

theme.buttons?{ primary?: ThemeButtonStyle neutral?: ThemeButtonStyle success?: ThemeButtonStyle danger?: ThemeButtonStyle }

Button styles by role.

theme.buttons.primary?ThemeButtonStyle

The action the app most expects, such as Submit.

theme.buttons.neutral?ThemeButtonStyle

A secondary action, such as Cancel or Back.

theme.buttons.success?ThemeButtonStyle

An action that confirms or approves, such as Approve.

theme.buttons.danger?ThemeButtonStyle

An action that removes or refuses, such as Delete or Reject.

Returns

Returns a decorator for a class or a method.

ClassDecorator & MethodDecorator

Throws

  • Error naming each token that is not valid, and when a class or method already has a @UseTheme.

Examples

TypeScript
@Controller()
@UseTheme({ colors: { primary: '#26A042' } })
export class ShopController {
  @Command('refund', CommandType.SLASH)
  @UseTheme({ colors: { primary: '#E3606D' }, emojis: { loading: '💸' } })
  async refund(interaction: ChatInputCommandInteraction) {
    await respond(interaction).send({ embeds: [new EmbedBuilder().setDescription('Refund started.')] })
  }
}