mirror of
https://github.com/jackmerrill/hampbot.git
synced 2024-12-04 04:53:01 -08:00
Compare commits
2 Commits
09c2ae06dc
...
658db4d051
Author | SHA1 | Date | |
---|---|---|---|
658db4d051 | |||
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,9 +103,10 @@ 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,
|
||||||
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,
|
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 {
|
if err != nil {
|
||||||
|
@ -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"
|
||||||
|
|
14
main.go
14
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,13 +162,15 @@ func main() {
|
||||||
log.Fatal(err)
|
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 {
|
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