feat(database): Improve database definition to add sizes
This commit is contained in:
parent
ec0aa5654c
commit
a3c1bae6db
6 changed files with 38 additions and 30 deletions
|
|
@ -128,10 +128,9 @@ export class GroupCommand implements Command, ChatInteractionCommand, Autocomple
|
|||
);
|
||||
}
|
||||
|
||||
const validName = this.validateGroupName(name);
|
||||
// @ts-expect-error Is correct, since the valid name can return either true or a string and the error should only be thrown if it's a string.
|
||||
if (name !== true) {
|
||||
throw new UserError(`Your group name contains one or more invalid character sequences: ${validName}`)
|
||||
const invalidName = this.validateGroupName(name);
|
||||
if (invalidName) {
|
||||
throw new UserError(`Your group name contains one or more invalid character sequences: ${invalidName}`)
|
||||
}
|
||||
|
||||
const group: GroupModel = {
|
||||
|
|
@ -152,7 +151,7 @@ export class GroupCommand implements Command, ChatInteractionCommand, Autocomple
|
|||
interaction.reply({content: `:white_check_mark: Created group \`${name}\``, flags: MessageFlags.Ephemeral})
|
||||
}
|
||||
|
||||
private validateGroupName(name: string): true | string {
|
||||
private validateGroupName(name: string): string | null {
|
||||
const lowercaseName = name.toLowerCase();
|
||||
for (const invalidcharactersequence of GroupCommand.INVALID_CHARACTER_SEQUENCES) {
|
||||
if (!lowercaseName.includes(invalidcharactersequence)) {
|
||||
|
|
@ -161,7 +160,7 @@ export class GroupCommand implements Command, ChatInteractionCommand, Autocomple
|
|||
|
||||
return invalidcharactersequence
|
||||
}
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
private list(interaction: ChatInputCommandInteraction) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue