generated from sebm253/bot-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mlnrDev
committed
Dec 29, 2023
1 parent
daf959c
commit a602954
Showing
6 changed files
with
96 additions
and
51 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
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,34 @@ | ||
package handlers | ||
|
||
import ( | ||
"dearrow-thumbnails/types" | ||
|
||
"github.com/disgoorg/disgo/discord" | ||
"github.com/disgoorg/disgo/handler" | ||
"github.com/schollz/jsonstore" | ||
) | ||
|
||
func (h *Handler) HandleModeGet(event *handler.CommandEvent) error { | ||
return event.CreateMessage(discord.NewMessageCreateBuilder(). | ||
SetContentf("Current mode is set to **%s**.", h.Bot.GetGuildData(*event.GuildID()).ThumbnailMode). | ||
SetEphemeral(true). | ||
Build()) | ||
} | ||
|
||
func (h *Handler) HandleModeSet(event *handler.CommandEvent) (err error) { | ||
data := event.SlashCommandInteractionData() | ||
guildID := event.GuildID() | ||
thumbnailMode := types.ThumbnailMode(data.Int("mode")) | ||
if err = h.Bot.Keystore.Set(guildID.String(), types.GuildData{ | ||
ThumbnailMode: thumbnailMode, | ||
}); err != nil { | ||
return | ||
} | ||
if err = jsonstore.Save(h.Bot.Keystore, h.Config.StoragePath); err != nil { | ||
return | ||
} | ||
return event.CreateMessage(discord.NewMessageCreateBuilder(). | ||
SetContentf("Mode has been set to **%s**.", thumbnailMode). | ||
SetEphemeral(true). | ||
Build()) | ||
} |
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,12 @@ | ||
package util | ||
|
||
import ( | ||
"net/url" | ||
|
||
"github.com/disgoorg/disgo/discord" | ||
) | ||
|
||
func ParseVideoID(embed discord.Embed) string { | ||
u, _ := url.Parse(embed.URL) | ||
return u.Query().Get("v") | ||
} |