This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand_upcomming.go
76 lines (57 loc) · 2.14 KB
/
command_upcomming.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package main
import (
"fmt"
"time"
"github.com/bwmarrin/discordgo"
)
var UpCommingCommand Command = Command{
Name: "upcomming",
Description: "Shows information for the next song in queue.",
Aliases: []string{"upc"},
Instance: func(client *Client, message *discordgo.MessageCreate, arg string) {
userPermission, _, _ := client.CheckPermissionsForUser(message)
if userPermission == PERM_ERROR {
client.MessageInteraction(message, ERROR_MSG, COLOR_ERROR)
return
} else if userPermission == PERM_NOT_IN_VC {
client.MessageInteraction(message, "❌ | You're not in a voice channel!", COLOR_ERROR)
return
} else if userPermission == PERM_WRONG_VC {
client.MessageInteraction(message, "⚠️ | I'm in another voice channel!", COLOR_WARNING)
return
}
if client.IsPlaying == false {
client.MessageInteraction(message, CustomWarning("I'm not playing."), COLOR_WARNING)
return
}
var index int
if client.Queue.RepeatingMode == RepeatingModeOff && int(client.Queue.GetNextIndex()+1) >= len(client.Queue.Queue) {
client.MessageInteraction(message, CustomWarning("There's no next song!"), COLOR_WARNING)
return
} else if client.Queue.RepeatingMode == RepeatingModeOff && int(client.Queue.GetNextIndex()+1) < len(client.Queue.Queue) {
index = client.Queue.GetNextIndex() + 1
} else if client.Queue.RepeatingMode == RepeatingModeQueue {
index = (client.Queue.GetNextIndex() + 1) % (MaxPages * MaxSongsPerPage)
} else {
index = client.Queue.GetNextIndex()
}
response := discordgo.MessageEmbed{
Type: discordgo.EmbedTypeRich,
Author: &discordgo.MessageEmbedAuthor{
Name: "Up comming 🎶",
},
Title: fmt.Sprintf("%s | requested by %s", client.Queue.Queue[index].AudioTrack.Info.Title, client.Queue.Queue[index].RequesterName),
Color: COLOR_INFO,
}
msg, err := client.Session.ChannelMessageSendEmbed(client.AnchorTextChannel, &response)
if err != nil {
client.MessageInteraction(message, ERROR_MSG, COLOR_ERROR)
return
}
go func() {
time.Sleep(time.Duration(ephemeralTime) * time.Second)
client.Session.ChannelMessageDelete(msg.ChannelID, msg.ID)
}()
return
},
}