mirror of
https://github.com/jackmerrill/hampbot.git
synced 2024-12-04 13:02:59 -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()
|
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())
|
err = SendEmail([]string{email}, code, ctx.GetUser())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -98,8 +103,9 @@ func (c *VerifyCommand) Exec(ctx shireikan.Context) error {
|
||||||
// expires in 5 minutes
|
// expires in 5 minutes
|
||||||
expires := time.Now().Add(time.Minute * 5)
|
expires := time.Now().Add(time.Minute * 5)
|
||||||
|
|
||||||
m, err := ctx.GetSession().ChannelMessageSendComplex(ctx.GetChannel().ID, &discordgo.MessageSend{
|
ctx.GetSession().ChannelMessageEditComplex(&discordgo.MessageEdit{
|
||||||
Reference: ctx.GetMessage().Reference(),
|
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,
|
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,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -219,13 +225,21 @@ func SendEmail(to []string, code string, discordUser *discordgo.User) error {
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
err = tmpl.Execute(buf, struct {
|
data := struct {
|
||||||
Code string
|
Code string
|
||||||
DiscordUserName string
|
DiscordUserName string
|
||||||
|
BaseUrl string
|
||||||
}{
|
}{
|
||||||
Code: code,
|
Code: code,
|
||||||
DiscordUserName: discordUser.Username,
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -17,7 +17,7 @@ var (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// BotPrefix is the prefix used for bot commands.
|
// BotPrefix is the prefix used for bot commands.
|
||||||
BotPrefix = ">>"
|
BotPrefix = "!"
|
||||||
|
|
||||||
// BotGuild is the ID of the guild the bot is running on.
|
// BotGuild is the ID of the guild the bot is running on.
|
||||||
BotGuild = "936651575684915201"
|
BotGuild = "936651575684915201"
|
||||||
|
|
4
main.go
4
main.go
|
@ -22,6 +22,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
log.Info(os.Environ())
|
||||||
|
|
||||||
token := os.Getenv("TOKEN")
|
token := os.Getenv("TOKEN")
|
||||||
|
|
||||||
session, err := discordgo.New("Bot " + token)
|
session, err := discordgo.New("Bot " + token)
|
||||||
|
@ -160,6 +162,7 @@ func main() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if os.Getenv("ENV") != "development" {
|
||||||
log.Info("Starting daily menu job...")
|
log.Info("Starting daily menu job...")
|
||||||
|
|
||||||
s.Start()
|
s.Start()
|
||||||
|
@ -169,4 +172,5 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,16 +28,16 @@
|
||||||
<div class="mt-4">
|
<div class="mt-4">
|
||||||
<a
|
<a
|
||||||
class="px-2 py-2 text-white bg-blue-600 rounded-md font-semibold"
|
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
|
>Click to Verify Email</a
|
||||||
>
|
>
|
||||||
<p class="mt-4 text-sm">
|
<p class="mt-4 text-sm">
|
||||||
If you're having trouble clicking the "Verify Email Address" button,
|
If you're having trouble clicking the "Verify Email Address" button,
|
||||||
copy and paste the URL below into your web browser:
|
copy and paste the URL below into your web browser:
|
||||||
<a
|
<a
|
||||||
href="https://hampbot.fly.dev/verify?code={{ .Code }}"
|
href="{{ .BaseUrl }}/verify?code={{ .Code }}"
|
||||||
class="text-blue-600"
|
class="text-blue-600"
|
||||||
>https://hampbot.fly.dev/verify?code={{ .Code }}</a
|
>{{ .BaseUrl }}/verify?code={{ .Code }}</a
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user