Centralized file for messages
Centralized file for messages #90
We need a way to store messages with templates too, not sure how yet but this can be discussed.
We can just export functions instead of strings from the file
// template
export const templateMessage = (a: string) => `${a} is used here`;
// static
export const staticMessage = () => 'static message';
We need a way to store messages with templates too, not sure how yet but this can be discussed.
We can just export functions instead of strings from the file
// template export const templateMessage = (a: string) => `${a} is used here`; // static export const staticMessage = () => 'static message';
This won't allow us to use the Discord.js toString() overrides as TypeScript will be mad. Additionally, it will be quite big as we have to have that whole thing for each message.
p.s. haven't slept for a while, gonna write in more detail tomorrow.
We need a way to store messages with templates too, not sure how yet but this can be discussed.
In that case I think using a message class would be a perfect solution.
export class Message {
functionWithStaticMessage(): string { return 'some text'; }
functionWithParameter(a: string): string { return 'value of a is' + a; }
}
@robertt Thoughts?
Personally I don't really like this since you have to make an instance of the class and the static keyword on every method would probably just make this even longer.
I'd like some Rust/Python-ey solution that lets us just have a object of strings and a function to call to populate stuff like %s but that seems quite far fetched for TS.
Consider:
export const messages = {
staticMessage: () => 'static message here',
templateMessage: (a: string) => `this is a template, ${a}`
}
Short lines and simplicity.
@jellz 👍, would probably be worth putting it in an object, so for example:
const messages = {
commands: {
rep: {
toSelf: () => ':x: you cannot send rep to yourself',
success: (member: string) => `:ok_hand: successfully sent rep to ${member}`
}
},
};
Anything blocking this from being merged?