mirror of
https://github.com/jackmerrill/hampbot.git
synced 2024-12-03 20:51:32 -08:00
idk what was wrong with email verification but its working regardless
This commit is contained in:
parent
09c2ae06dc
commit
35ddfe76f8
|
@ -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...").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
|
||||
|
|
|
@ -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"
|
||||
|
|
14
main.go
14
main.go
|
@ -22,6 +22,8 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
log.Info(os.Environ())
|
||||
|
||||
token := os.Getenv("TOKEN")
|
||||
|
||||
session, err := discordgo.New("Bot " + token)
|
||||
|
@ -160,13 +162,15 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Info("Starting daily menu job...")
|
||||
if os.Getenv("ENV") != "development" {
|
||||
log.Info("Starting daily menu job...")
|
||||
|
||||
s.Start()
|
||||
s.Start()
|
||||
|
||||
err = dcMenuJob.RunNow()
|
||||
err = dcMenuJob.RunNow()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user