-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchatCommand.go
51 lines (44 loc) · 1.42 KB
/
chatCommand.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
package announcement
import (
"github.com/bwmarrin/discordgo"
"github.com/cake4everyone/cake4everybot/data/lang"
"github.com/cake4everyone/cake4everybot/util"
)
// The Chat (slash) command of the announcement package.
type Chat struct {
announcementBase
ID string
}
const (
// Prefix for translation key, i.e.:
// key := tp+"base" // => announcement
tp = "discord.command.announcement."
)
// AppCmd (ApplicationCommand) returns the definition of the chat command
func (cmd Chat) AppCmd() *discordgo.ApplicationCommand {
return &discordgo.ApplicationCommand{
Name: lang.GetDefault(tp + "base"),
NameLocalizations: util.TranslateLocalization(tp + "base"),
Description: lang.GetDefault(tp + "base.description"),
DescriptionLocalizations: util.TranslateLocalization(tp + "base.description"),
}
}
// Handle handles the functionality of a command
func (cmd Chat) Handle(s *discordgo.Session, i *discordgo.InteractionCreate) {
cmd.InteractionUtil = util.InteractionUtil{Session: s, Interaction: i}
cmd.member = i.Member
cmd.user = i.User
if i.Member != nil {
cmd.user = i.Member.User
} else if i.User != nil {
cmd.member = &discordgo.Member{User: i.User}
}
}
// SetID sets the registered command ID for internal uses after uploading to discord
func (cmd *Chat) SetID(id string) {
cmd.ID = id
}
// GetID gets the registered command ID
func (cmd Chat) GetID() string {
return cmd.ID
}