Centralized file for messages#91
Centralized file for messages#91NimperX wants to merge 8 commits intotypescript-community:masterfrom
Conversation
jellz
left a comment
There was a problem hiding this comment.
You don't need to include : string in every declaration, it is inferred
Also, instead of
const message = 'text';
export { message };you can just do
export const message = 'text';
ckiee
left a comment
There was a problem hiding this comment.
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. p.s. haven't slept for a while, gonna write in more detail tomorrow. |
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 |
|
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? |
ckiee
left a comment
There was a problem hiding this comment.
In addition to the review comments I'd also like to mention you should try to make the constant's names a bit more detached from the sentence.
E.g. beAskerToCloseChannel -> noChannelClosePerms / cannotSendRepToYou -> noSelfRep. (or something like that)
Centralized file for messages #90