-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ctx.go
48 lines (39 loc) · 984 Bytes
/
Ctx.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
package ctx
import "github.com/bwmarrin/discordgo"
type Ctx interface {
GetArgs() []string
GetAuthor() *discordgo.User
GetChannel() *discordgo.Channel
GetGuild() *discordgo.Guild
GetMessage() *discordgo.MessageCreate
}
type BaseCtx struct {
args []string
author *discordgo.User
channel *discordgo.Channel
guild *discordgo.Guild
message *discordgo.MessageCreate
}
func (b BaseCtx) GetArgs() []string {
return b.args
}
func (b BaseCtx) GetAuthor() *discordgo.User {
return b.author
}
func (b BaseCtx) GetChannel() *discordgo.Channel {
return b.channel
}
func (b BaseCtx) GetGuild() *discordgo.Guild {
return b.guild
}
func (b BaseCtx) GetMessage() *discordgo.MessageCreate {
return b.message
}
func New(args []string,msg *discordgo.MessageCreate,session *discordgo.Session) *BaseCtx {
ctx := &BaseCtx{args: args}
ctx.author = msg.Author
ctx.channel,_ = session.Channel(msg.ChannelID)
ctx.guild,_ = session.Guild(msg.GuildID)
ctx.message = msg
return ctx
}