go: discord/modules: Set limit for validation code length

master
Luther Wen Xu 2019-10-16 12:40:26 +07:00
parent 34daaa83cb
commit b118fbd477
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
2 changed files with 6 additions and 0 deletions

@ -82,6 +82,7 @@ const InviteSuccessNew = "这个验证码现在属于你了。请好好保管并
const InviteSuccessAlreadyOwn = "该验证码原本就已经属于你。请直接交给你要邀请的人吧。\nThe validation code already belongs to you. You can pass it on to a user you want to invite."
const ErrorInviteTitle = "制造验证码失败 Create Validation Code Error"
const ErrorInviteCodeContainsSpace = "所制造的验证码不得有任何空格。\nThe validation code to create cannot contain any spaces."
const ErrorInviteCodeTooLong = "所制造的验证码必须少于512个字符。\nThe validation code cannot be longer than 512 characters."
const ErrorInviteOwnedByOthers = "这个验证码已被其他会员注册。请使用别的验证码。\nThis validation code is already registered. Please try another one."
const ErrorInviteExistAndUsed = "这个验证码已被使用过。请使用别的验证码。\nThis validation code has already been used. Please try another one."

@ -25,6 +25,11 @@ var createInvite = enforceDM(memberFilter(true, enforceArgumentCount(
Send(s, m.ChannelID)
return
}
if len(command[1]) > 512 {
message.InitNewEmbed(config.ErrorInviteTitle, config.ErrorInviteCodeTooLong, config.ErrorColour).
Send(s, m.ChannelID)
return
}
err := db.SetInviteOwner(command[1], m.Author.ID)
switch err {