1
|
|
|
package cmd |
2
|
|
|
|
3
|
|
|
import ( |
4
|
|
|
"fmt" |
5
|
|
|
"strings" |
6
|
|
|
"time" |
7
|
|
|
|
8
|
|
|
"github.com/FlameInTheDark/dtbot/bot" |
9
|
|
|
) |
10
|
|
|
|
11
|
|
|
// DebugCommand special bot commands handler |
12
|
|
|
func DebugCommand(ctx bot.Context) { |
13
|
|
|
if ctx.IsServerAdmin() { |
14
|
|
|
ctx.MetricsCommand("debug", "admin") |
15
|
|
|
if len(ctx.Args) == 0 { |
16
|
|
|
return |
17
|
|
|
} |
18
|
|
|
switch ctx.Args[0] { |
19
|
|
|
case "roles": |
20
|
|
|
var roles []string |
21
|
|
|
for _, val := range ctx.GetRoles().Roles { |
22
|
|
|
roles = append(roles, val.Name) |
23
|
|
|
} |
24
|
|
|
ctx.ReplyEmbedPM("Debug", strings.Join(roles, ", ")) |
25
|
|
|
case "time": |
26
|
|
|
ctx.ReplyEmbedPM("Debug", time.Now().String()) |
27
|
|
|
case "session": |
28
|
|
|
sess := ctx.Sessions.GetByGuild(ctx.Guild.ID) |
29
|
|
|
if sess != nil { |
30
|
|
|
ctx.ReplyEmbed("Debug", sess.ChannelID) |
31
|
|
|
} else { |
32
|
|
|
ctx.ReplyEmbed("Debug", "Session is nil") |
33
|
|
|
} |
34
|
|
|
case "voice": |
35
|
|
|
var resp string |
36
|
|
|
resp += fmt.Sprintf("Voice connections: %v\n", len(ctx.Discord.VoiceConnections)) |
37
|
|
|
for i, c := range ctx.Discord.VoiceConnections { |
38
|
|
|
resp += i + " | G: " + c.GuildID + " | C: " + c.ChannelID + "\n" |
39
|
|
|
} |
40
|
|
|
ctx.ReplyEmbed("Debug", resp) |
41
|
|
|
case "leavevoice": |
42
|
|
|
if v, ok := ctx.Discord.VoiceConnections[ctx.Args[1]]; ok { |
43
|
|
|
err := v.Disconnect() |
44
|
|
|
if err != nil { |
45
|
|
|
ctx.ReplyEmbed("Debug", "Voice: "+err.Error()) |
46
|
|
|
} |
47
|
|
|
} else { |
48
|
|
|
ctx.ReplyEmbed("Debug", "Voice connection not found") |
49
|
|
|
} |
50
|
|
|
case "volume": |
51
|
|
|
ctx.ReplyEmbed("Debug", fmt.Sprintf("Voice volume is %.2f", ctx.Guilds.Guilds[ctx.Guild.ID].VoiceVolume)) |
52
|
|
|
} |
53
|
|
|
} else { |
54
|
|
|
ctx.ReplyEmbedPM("Debug", "Not a Admin") |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|