-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhelp.go
More file actions
37 lines (31 loc) · 919 Bytes
/
help.go
File metadata and controls
37 lines (31 loc) · 919 Bytes
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
// SPDX-License-Identifier: BSD-2-Clause
//
// Copyright (c) Lewis Cook <lcook@FreeBSD.org>
package command
import (
"fmt"
"github.com/bwmarrin/discordgo"
)
func (h *Handler) Help(s *discordgo.Session, m *discordgo.MessageCreate) {
if m.Author.Bot || m.Author.ID == s.State.User.ID {
return
}
if m.Content != h.Settings.Prefix+"help" {
return
}
fields := make([]*discordgo.MessageEmbedField, 0, len(h.commands))
for _, command := range h.commands {
fields = append(fields, &discordgo.MessageEmbedField{
Name: h.Settings.Prefix + command.Name,
Value: "-# " + command.Description,
})
}
s.ChannelMessageSendEmbed(m.ChannelID, &discordgo.MessageEmbed{
Description: fmt.Sprintf(
"-# List of commands available (%d) to use in the server. For more see the [GitHub repository](https://github.com/lcook/pulsar).",
len(h.commands),
),
Color: embedColorFreeBSD,
Fields: fields,
})
}