diff options
| author | Bobby <[email protected]> | 2025-03-27 12:48:49 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2025-03-27 12:48:49 +0530 |
| commit | 1b271061415b33a8f18d1d3d960bc750b9557b69 (patch) | |
| tree | f14bd9b483d849f454f10a9111049e5c191a5154 /commands | |
| parent | 3a63a1a8be65f3e50141a3970a9d63d91b191755 (diff) | |
| download | ai-1b271061415b33a8f18d1d3d960bc750b9557b69.tar.xz ai-1b271061415b33a8f18d1d3d960bc750b9557b69.zip | |
command handler and boilerplate play command
Diffstat (limited to 'commands')
| -rw-r--r-- | commands/commands.go | 20 | ||||
| -rw-r--r-- | commands/play.go | 24 |
2 files changed, 44 insertions, 0 deletions
diff --git a/commands/commands.go b/commands/commands.go new file mode 100644 index 0000000..53dc3dc --- /dev/null +++ b/commands/commands.go @@ -0,0 +1,20 @@ +package commands + +import "github.com/bwmarrin/discordgo" + +var ( + Commands = []*discordgo.ApplicationCommand{ + { + Name: "play", + Description: "Search and play a song from Spotify or YouTube", + Options: []*discordgo.ApplicationCommandOption{ + { + Type: discordgo.ApplicationCommandOptionString, + Name: "query", + Description: "Search query for the song/playlist (or URL)", + Required: true, + }, + }, + }, + } +) diff --git a/commands/play.go b/commands/play.go new file mode 100644 index 0000000..6c7fae4 --- /dev/null +++ b/commands/play.go @@ -0,0 +1,24 @@ +package commands + +import ( + "fmt" + + "github.com/bwmarrin/discordgo" +) + +// Command: Play +// Takes in a search query and autocompletes the search query to play a song from Spotify or YouTube +// Also takes in a URL to a Spotify Song/Playlist or YouTube Video/Playlist +// Joins the user's voice channel and plays the song. Adds to the queue if a song is already playing +// in any of the voice channels. User must be in a voice channel to use this command +// Usage: /play <search query or URL> +func Play(s *discordgo.Session, i *discordgo.InteractionCreate) { + // For now return the query as reply + reply := fmt.Sprintf("Playing: %s", i.ApplicationCommandData().Options[0].StringValue()) + s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{ + Type: discordgo.InteractionResponseChannelMessageWithSource, + Data: &discordgo.InteractionResponseData{ + Content: reply, + }, + }) +} |
