diff --git a/discord.go b/discord.go index 150d4e2..d50ea21 100644 --- a/discord.go +++ b/discord.go @@ -310,19 +310,21 @@ func (d *DiscordDaemon) registerCommands() { i++ } - d.deregisterCommands() + // d.deregisterCommands() d.commandIDs = make([]string, len(commands)) - cCommands, err := d.bot.ApplicationCommandBulkOverwrite(d.bot.State.User.ID, d.guildID, commands) - if err != nil { - d.app.err.Printf("Discord: Cannot create commands: %v", err) - } - for i, cmd := range cCommands { - // command, err := d.bot.ApplicationCommandCreate(d.bot.State.User.ID, d.guildID, cmd) - // if err != nil { - // d.app.err.Printf("Discord: Cannot create command \"%s\": %v", cmd.Name, err) - // } - d.commandIDs[i] = cmd.ID + // cCommands, err := d.bot.ApplicationCommandBulkOverwrite(d.bot.State.User.ID, d.guildID, commands) + // if err != nil { + // d.app.err.Printf("Discord: Cannot create commands: %v", err) + // } + for i, cmd := range commands { + command, err := d.bot.ApplicationCommandCreate(d.bot.State.User.ID, d.guildID, cmd) + if err != nil { + d.app.err.Printf("Discord: Cannot create command \"%s\": %v", cmd.Name, err) + } else { + d.app.debug.Printf("Discord: registered command \"%s\"", cmd.Name) + d.commandIDs[i] = command.ID + } } } diff --git a/html/form.html b/html/form.html index 429e9ee..54c7b1f 100644 --- a/html/form.html +++ b/html/form.html @@ -177,7 +177,7 @@ {{ if .captcha }}
- CAPTCHA + CAPTCHA
diff --git a/lang/common/en-us.json b/lang/common/en-us.json index db977e8..322febc 100644 --- a/lang/common/en-us.json +++ b/lang/common/en-us.json @@ -22,6 +22,7 @@ "linkDiscord": "Link Discord", "linkMatrix": "Link Matrix", "contactDiscord": "Contact through Discord", - "theme": "Theme" + "theme": "Theme", + "refresh": "Refresh" } } diff --git a/ts/form.ts b/ts/form.ts index 7dc9580..c0984ae 100644 --- a/ts/form.ts +++ b/ts/form.ts @@ -271,7 +271,7 @@ let captchaVerified = false; let captchaID = ""; let captchaInput = document.getElementById("captcha-input") as HTMLInputElement; -if (window.captcha) { +const genCaptcha = () => { _get("/captcha/gen/"+window.code, null, (req: XMLHttpRequest) => { if (req.readyState == 4) { if (req.status == 200) { @@ -279,9 +279,15 @@ if (window.captcha) { document.getElementById("captcha-img").innerHTML = ` `; + captchaInput.value = ""; } } }); +}; + +if (window.captcha) { + genCaptcha(); + (document.getElementById("captcha-regen") as HTMLSpanElement).onclick = genCaptcha; const input = document.querySelector("input[type=submit]") as HTMLInputElement; const checkbox = document.getElementById("captcha-success") as HTMLSpanElement; captchaInput.onkeyup = () => _post("/captcha/verify/" + window.code + "/" + captchaID + "/" + captchaInput.value, null, (req: XMLHttpRequest) => {