Skip to content

Commit 363382d

Browse files
committed
Resolve #509
1 parent 8ae80b1 commit 363382d

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/commands/nickname.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ interface UserVote {
2929
readonly trusted: boolean;
3030
}
3131

32+
const nickNameMaxLength = 32;
33+
3234
export default class NicknameCommand implements ApplicationCommand, AutocompleteCommand {
3335
name = "nickname";
3436
description = "Setzt Nicknames für einen User";
@@ -50,7 +52,8 @@ export default class NicknameCommand implements ApplicationCommand, Autocomplete
5052
new SlashCommandStringOption()
5153
.setRequired(true)
5254
.setName("nickname")
53-
.setDescription("Was du tun willst"),
55+
.setDescription("Was du tun willst")
56+
.setMaxLength(nickNameMaxLength),
5457
),
5558
)
5659
.addSubcommand(
@@ -146,6 +149,13 @@ export default class NicknameCommand implements ApplicationCommand, Autocomplete
146149
}
147150

148151
const nickname = cmd.options.getString("nickname", true);
152+
if (nickname.length > nickNameMaxLength) {
153+
await cmd.reply(
154+
`'${nickname}' ist zu lang. Maximal ${nickNameMaxLength} Zeichen.`,
155+
);
156+
return;
157+
}
158+
149159
if (await nickName.nickNameExist(user.id, nickname)) {
150160
await cmd.reply(
151161
`Würdest du Hurensohn aufpassen, wüsstest du, dass für ${user} '${nickname}' bereits existiert.`,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { Kysely } from "kysely";
2+
3+
// https://github.com/NullDev/CSZ-Bot/issues/509
4+
5+
export async function up(db: Kysely<any>): Promise<void> {
6+
await db
7+
.deleteFrom("nickNames")
8+
.where(({ fn }) => fn<number>("length", ["nickName"]), ">", 32)
9+
.execute();
10+
}
11+
12+
export async function down(_db: Kysely<any>): Promise<void> {
13+
throw new Error("Not supported lol");
14+
}

0 commit comments

Comments
 (0)