-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* exp with an interaction data union * compiler panic * comment out assignment * upgrade routing, mostly stable * fix Route field on Request * remove migration to seperate folders * feat: modals * fix: constant naming, CI pipeline
- Loading branch information
Showing
32 changed files
with
1,249 additions
and
885 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"log" | ||
"os" | ||
|
||
"github.com/Karitham/corde" | ||
) | ||
|
||
var command = corde.NewSlashCommand("modal", "send a modal") | ||
|
||
func main() { | ||
token := os.Getenv("DISCORD_BOT_TOKEN") | ||
if token == "" { | ||
log.Fatalln("DISCORD_BOT_TOKEN not set") | ||
} | ||
appID := corde.SnowflakeFromString(os.Getenv("DISCORD_APP_ID")) | ||
if appID == 0 { | ||
log.Fatalln("DISCORD_APP_ID not set") | ||
} | ||
pk := os.Getenv("DISCORD_PUBLIC_KEY") | ||
if pk == "" { | ||
log.Fatalln("DISCORD_PUBLIC_KEY not set") | ||
} | ||
|
||
m := corde.NewMux(pk, appID, token) | ||
m.SlashCommand("modal", respondModal) | ||
m.Modal("pog-modal", func(w corde.ResponseWriter, r *corde.Request[corde.ModalInteractionData]) { | ||
json.NewEncoder(os.Stderr).Encode(r) | ||
w.DeferedUpdate() | ||
}) | ||
|
||
g := corde.GuildOpt(corde.SnowflakeFromString(os.Getenv("DISCORD_GUILD_ID"))) | ||
if err := m.RegisterCommand(command, g); err != nil { | ||
log.Fatalln("error registering command: ", err) | ||
} | ||
|
||
log.Println("serving on :8070") | ||
if err := m.ListenAndServe(":8070"); err != nil { | ||
log.Fatalln(err) | ||
} | ||
} | ||
|
||
func respondModal(w corde.ResponseWriter, r *corde.Request[corde.SlashCommandInteractionData]) { | ||
w.Modal(corde.Modal{ | ||
Title: "xoxo", | ||
CustomID: "pog-modal", | ||
Components: []corde.Component{ | ||
corde.TextInputComponent{ | ||
CustomID: "pog-component", | ||
Style: corde.TEXT_PARAGRAPH, | ||
Label: "label", | ||
Required: false, | ||
Placeholder: "placeholder", | ||
}.Component(), | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.