-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdgate.go
More file actions
205 lines (153 loc) · 6.66 KB
/
dgate.go
File metadata and controls
205 lines (153 loc) · 6.66 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package discoself
import (
"strings"
"github.com/krishnassh/discoself/discord"
"github.com/krishnassh/discoself/types"
)
type Client struct {
Selfbot *discord.Selfbot
Gateway *discord.Gateway
Config *types.Config
}
func NewClient(token string, config *types.Config) *Client {
token = strings.TrimSpace(token)
selfbot := discord.Selfbot{Token: token}
gateway := discord.CreateGateway(&selfbot, config)
return &Client{&selfbot, gateway, config}
}
func (client *Client) Connect() error {
return client.Gateway.Connect()
}
func (client *Client) AddHandler(event string, function any) error {
return client.Gateway.Handlers.Add(event, function)
}
func (client *Client) GetMembers(guildId string, memberIds []string) error {
return client.Gateway.GetMembers(guildId, memberIds)
}
func (client *Client) Close() {
client.Gateway.Close()
}
// channel
func (client *Client) SendMessage(channelID string, content string) bool {
return discord.SendMessage(client.Gateway, channelID, content)
}
func (client *Client) GetChannel(channelID string) (types.Channel, error) {
return discord.GetChannel(client.Gateway, channelID)
}
func (client *Client) SendMessageWithReply(channelID string, content string, replyMessageID string) bool {
return discord.SendMessageWithReply(client.Gateway, channelID, content, replyMessageID)
}
func (client *Client) EditMessage(channelID string, messageID string, content string) bool {
return discord.EditMessage(client.Gateway, channelID, messageID, content)
}
func (client *Client) DeleteMessage(channelID string, messageID string) bool {
return discord.DeleteMessage(client.Gateway, channelID, messageID)
}
func (client *Client) SendTyping(channelID string) bool {
return discord.SendTyping(client.Gateway, channelID)
}
func (client *Client) AddReaction(channelID string, messageID string, emoji string) bool {
return discord.AddReaction(client.Gateway, channelID, messageID, emoji)
}
func (client *Client) RemoveReaction(channelID string, messageID string, emoji string) bool {
return discord.RemoveReaction(client.Gateway, channelID, messageID, emoji)
}
func (client *Client) DeleteAllReactions(channelID string, messageID string) bool {
return discord.DeleteAllReactions(client.Gateway, channelID, messageID)
}
func (client *Client) GetMessage(channelID string, messageID string) (types.MessageData, error) {
return discord.GetMessage(client.Gateway, channelID, messageID)
}
func (client *Client) GetMessages(channelID string, limit int) ([]types.MessageData, error) {
return discord.GetMessages(client.Gateway, channelID, limit)
}
func (client *Client) GetPinnedMessages(channelID string) ([]types.MessageData, error) {
return discord.GetPinnedMessages(client.Gateway, channelID)
}
func (client *Client) PinMessage(channelID string, messageID string) bool {
return discord.PinMessage(client.Gateway, channelID, messageID)
}
func (client *Client) UnpinMessage(channelID string, messageID string) bool {
return discord.UnpinMessage(client.Gateway, channelID, messageID)
}
func (client *Client) CreateThread(channelID string, messageID string, name string) (types.Channel, error) {
return discord.CreateThread(client.Gateway, channelID, messageID, name)
}
// interactions
func (client *Client) GetSlashCommands(guildID string) (types.ApplicationCommandIndex, error) {
return discord.GetSlashCommands(client.Gateway, guildID)
}
func (client *Client) GetUserSlashCommands() (types.ApplicationCommandIndex, error) {
return discord.GetUserSlashCommands(client.Gateway)
}
func (client *Client) SendSlashCommand(channelID string, guildID string, command types.ApplicationCommand) bool {
return discord.SendSlashCommand(client.Gateway, channelID, guildID, command)
}
func (client *Client) SendSlashCommandWithOptions(channelID string, guildID string, command types.ApplicationCommand, options []any) bool {
return discord.SendSlashCommandWithOptions(client.Gateway, channelID, guildID, command, options)
}
func (client *Client) ClickButton(e *types.MessageEventData, interactionID string) bool {
return discord.ClickButton(client.Gateway, e, interactionID)
}
// guild
func (client *Client) GetGuild(guildID string) (types.Guild, error) {
return discord.GetGuild(client.Gateway, guildID)
}
func (client *Client) GetGuildChannels(guildID string) ([]types.Channel, error) {
return discord.GetGuildChannels(client.Gateway, guildID)
}
func (client *Client) GetGuildRoles(guildID string) ([]types.Role, error) {
return discord.GetGuildRoles(client.Gateway, guildID)
}
func (client *Client) KickMember(guildID string, userID string) error {
return discord.KickMember(client.Gateway, guildID, userID)
}
func (client *Client) BanMember(guildID string, userID string, deleteMessageSeconds int) error {
return discord.BanMember(client.Gateway, guildID, userID, deleteMessageSeconds)
}
func (client *Client) UnbanMember(guildID string, userID string) error {
return discord.UnbanMember(client.Gateway, guildID, userID)
}
func (client *Client) AddRole(guildID string, userID string, roleID string) error {
return discord.AddRole(client.Gateway, guildID, userID, roleID)
}
func (client *Client) RemoveRole(guildID string, userID string, roleID string) error {
return discord.RemoveRole(client.Gateway, guildID, userID, roleID)
}
func (client *Client) LeaveGuild(guildID string) bool {
return discord.LeaveGuild(client.Gateway, guildID)
}
func (client *Client) SetSlowmode(channelID string, seconds int) bool {
return discord.SetSlowmode(client.Gateway, channelID, seconds)
}
// user
func (client *Client) GetUser(userID string) (types.User, error) {
return discord.GetUser(client.Gateway, userID)
}
func (client *Client) GetProfile(userID string, guildID string) (types.User, error) {
return discord.GetProfile(client.Gateway, userID, guildID)
}
func (client *Client) ModifyUsername(username string, password string) bool {
return discord.ModifyUsername(client.Gateway, username, password)
}
func (client *Client) SetStatus(status string) bool {
return discord.SetStatus(client.Gateway, status)
}
func (client *Client) SetCustomStatus(text string, emoji string) bool {
return discord.SetCustomStatus(client.Gateway, text, emoji)
}
func (client *Client) ClearCustomStatus() bool {
return discord.ClearCustomStatus(client.Gateway)
}
func (client *Client) SetNickname(guildID string, nickname string) bool {
return discord.SetNickname(client.Gateway, guildID, nickname)
}
func (client *Client) SendFriendRequest(username string) bool {
return discord.SendFriendRequest(client.Gateway, username)
}
func (client *Client) RemoveFriend(userID string) bool {
return discord.RemoveFriend(client.Gateway, userID)
}
func (client *Client) BlockUser(userID string) bool {
return discord.BlockUser(client.Gateway, userID)
}