-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop.go
41 lines (34 loc) · 812 Bytes
/
stop.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package command
import (
"context"
"github.com/bwmarrin/discordgo"
"os"
)
const StopCommandName = "stop"
type StopCommand struct {
MusicStopChs map[string]chan struct{}
}
func (sc StopCommand) Command() *discordgo.ApplicationCommand {
return &discordgo.ApplicationCommand{
Name: StopCommandName,
Description: "Stop playing song by discord",
GuildID: os.Getenv(serverGuildKey),
Type: discordgo.ChatApplicationCommand,
}
}
func (sc StopCommand) Execute(
ctx context.Context,
s *discordgo.Session,
i *discordgo.InteractionCreate,
) (res DiscordMessageReceiver, _ error) {
res = SimpleMessage{Msg: "Przepraszam"}
select {
case <-ctx.Done():
return
default:
if _, ok := s.VoiceConnections[i.GuildID]; ok {
sc.MusicStopChs[i.GuildID] <- struct{}{}
}
}
return
}