#Typing

9 messages · Page 1 of 1 (latest)

ornate parcel
public async callHelp(data: DefaultHelpOptions | ReplacerHelpOptions | Snowflake): Promise<void> {
  ...
  if (data.reason === "noadd") console.log(data.replacers);
  ...
}

// Typings
type HelpReasons = 'afk' | 'web';
type ReplacerHelpReasons = 'noadd' | 'nojoin';
export type DefaultReason = HelpReasons | ReplacerHelpReasons;
type HelpOptions = {
    reason: string;
    system: boolean;
}
type DefaultHelpOptions = HelpOptions & {
    reason: HelpReasons;
};
type ReplacerHelpOptions = HelpOptions & {
    reason: ReplacerHelpReasons;
    replacers: { [key: string]: string };
};
cinder widgetBOT
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
ornate parcel
barren hawk

ello is not in any of your types

ornate parcel
barren hawk `ello` is not in any of your types

mb i edited out the explanation

basically, reason can be either a "DefaultReason" or any string

config.reasons[data.reason] ?? data.reason

If a default one is provided, it gets it from config, otherwise it will use the custom one

However, the only reasons with "replacers" option are ReplacerHelpReasons

barren hawk
ornate parcel
boreal otter

Then just type reason as string

ornate parcel