Compare commits

...

2 Commits

4 changed files with 32 additions and 14 deletions

View File

@ -89,6 +89,11 @@ func (c *VerifyCommand) Exec(ctx shireikan.Context) error {
code := uuid.New().String()
m, err := ctx.GetSession().ChannelMessageSendComplex(ctx.GetChannel().ID, &discordgo.MessageSend{
Reference: ctx.GetMessage().Reference(),
Embed: embed.NewWarningEmbed(ctx).SetTitle("Sending Verification Email").SetDescription("Please wait...").MessageEmbed,
})
err = SendEmail([]string{email}, code, ctx.GetUser())
if err != nil {
@ -98,9 +103,10 @@ func (c *VerifyCommand) Exec(ctx shireikan.Context) error {
// expires in 5 minutes
expires := time.Now().Add(time.Minute * 5)
m, err := ctx.GetSession().ChannelMessageSendComplex(ctx.GetChannel().ID, &discordgo.MessageSend{
Reference: ctx.GetMessage().Reference(),
Embed: embed.NewSuccessEmbed(ctx).SetTitle("Sent Verification Email").SetDescription("Waiting for you to verify...").AddField("Expires", fmt.Sprintf("<t:%d:R>", expires.Unix()), false).MessageEmbed,
ctx.GetSession().ChannelMessageEditComplex(&discordgo.MessageEdit{
ID: m.ID,
Channel: ctx.GetChannel().ID,
Embed: embed.NewSuccessEmbed(ctx).SetTitle("Sent Verification Email").SetDescription("Waiting for you to verify...\n\n**Make sure to check your spam folder!**").AddField("Expires", fmt.Sprintf("<t:%d:R>", expires.Unix()), false).MessageEmbed,
})
if err != nil {
@ -219,13 +225,21 @@ func SendEmail(to []string, code string, discordUser *discordgo.User) error {
buf := new(bytes.Buffer)
err = tmpl.Execute(buf, struct {
data := struct {
Code string
DiscordUserName string
BaseUrl string
}{
Code: code,
DiscordUserName: discordUser.Username,
})
BaseUrl: "http://localhost:8080",
}
if os.Getenv("ENV") != "development" {
data.BaseUrl = "https://hampbot.fly.dev"
}
err = tmpl.Execute(buf, data)
if err != nil {
return err

View File

@ -17,7 +17,7 @@ var (
var (
// BotPrefix is the prefix used for bot commands.
BotPrefix = ">>"
BotPrefix = "!"
// BotGuild is the ID of the guild the bot is running on.
BotGuild = "936651575684915201"

View File

@ -22,6 +22,8 @@ import (
)
func main() {
log.Info(os.Environ())
token := os.Getenv("TOKEN")
session, err := discordgo.New("Bot " + token)
@ -160,6 +162,7 @@ func main() {
log.Fatal(err)
}
if os.Getenv("ENV") != "development" {
log.Info("Starting daily menu job...")
s.Start()
@ -169,4 +172,5 @@ func main() {
if err != nil {
log.Fatal(err)
}
}
}

View File

@ -28,16 +28,16 @@
<div class="mt-4">
<a
class="px-2 py-2 text-white bg-blue-600 rounded-md font-semibold"
href="https://hampbot.fly.dev/verify?code={{ .Code }}"
href="{{ .BaseUrl }}/verify?code={{ .Code }}"
>Click to Verify Email</a
>
<p class="mt-4 text-sm">
If you're having trouble clicking the "Verify Email Address" button,
copy and paste the URL below into your web browser:
<a
href="https://hampbot.fly.dev/verify?code={{ .Code }}"
href="{{ .BaseUrl }}/verify?code={{ .Code }}"
class="text-blue-600"
>https://hampbot.fly.dev/verify?code={{ .Code }}</a
>{{ .BaseUrl }}/verify?code={{ .Code }}</a
>
</p>
</div>