repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh channelUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*ChannelUpdate); ok { eh(s, t) } }
go
func (eh channelUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*ChannelUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "channelUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "ChannelUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ...
// Handle is the handler for ChannelUpdate events.
[ "Handle", "is", "the", "handler", "for", "ChannelUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L130-L134
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh connectEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Connect); ok { eh(s, t) } }
go
func (eh connectEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Connect); ok { eh(s, t) } }
[ "func", "(", "eh", "connectEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "Connect", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")", "\n",...
// Handle is the handler for Connect events.
[ "Handle", "is", "the", "handler", "for", "Connect", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L145-L149
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh disconnectEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Disconnect); ok { eh(s, t) } }
go
func (eh disconnectEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Disconnect); ok { eh(s, t) } }
[ "func", "(", "eh", "disconnectEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "Disconnect", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")", ...
// Handle is the handler for Disconnect events.
[ "Handle", "is", "the", "handler", "for", "Disconnect", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L160-L164
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh eventEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Event); ok { eh(s, t) } }
go
func (eh eventEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Event); ok { eh(s, t) } }
[ "func", "(", "eh", "eventEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "Event", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")", "\n", "...
// Handle is the handler for Event events.
[ "Handle", "is", "the", "handler", "for", "Event", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L175-L179
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildBanAddEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildBanAdd); ok { eh(s, t) } }
go
func (eh guildBanAddEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildBanAdd); ok { eh(s, t) } }
[ "func", "(", "eh", "guildBanAddEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildBanAdd", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")",...
// Handle is the handler for GuildBanAdd events.
[ "Handle", "is", "the", "handler", "for", "GuildBanAdd", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L195-L199
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildBanRemoveEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildBanRemove); ok { eh(s, t) } }
go
func (eh guildBanRemoveEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildBanRemove); ok { eh(s, t) } }
[ "func", "(", "eh", "guildBanRemoveEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildBanRemove", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ...
// Handle is the handler for GuildBanRemove events.
[ "Handle", "is", "the", "handler", "for", "GuildBanRemove", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L215-L219
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildCreateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildCreate); ok { eh(s, t) } }
go
func (eh guildCreateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildCreate); ok { eh(s, t) } }
[ "func", "(", "eh", "guildCreateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildCreate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")",...
// Handle is the handler for GuildCreate events.
[ "Handle", "is", "the", "handler", "for", "GuildCreate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L235-L239
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildDeleteEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildDelete); ok { eh(s, t) } }
go
func (eh guildDeleteEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildDelete); ok { eh(s, t) } }
[ "func", "(", "eh", "guildDeleteEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildDelete", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")",...
// Handle is the handler for GuildDelete events.
[ "Handle", "is", "the", "handler", "for", "GuildDelete", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L255-L259
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildEmojisUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildEmojisUpdate); ok { eh(s, t) } }
go
func (eh guildEmojisUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildEmojisUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "guildEmojisUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildEmojisUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", ...
// Handle is the handler for GuildEmojisUpdate events.
[ "Handle", "is", "the", "handler", "for", "GuildEmojisUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L275-L279
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildIntegrationsUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildIntegrationsUpdate); ok { eh(s, t) } }
go
func (eh guildIntegrationsUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildIntegrationsUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "guildIntegrationsUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildIntegrationsUpdate", ")", ";", "ok", "{", "eh", "(", "...
// Handle is the handler for GuildIntegrationsUpdate events.
[ "Handle", "is", "the", "handler", "for", "GuildIntegrationsUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L295-L299
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildMemberAddEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildMemberAdd); ok { eh(s, t) } }
go
func (eh guildMemberAddEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildMemberAdd); ok { eh(s, t) } }
[ "func", "(", "eh", "guildMemberAddEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildMemberAdd", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ...
// Handle is the handler for GuildMemberAdd events.
[ "Handle", "is", "the", "handler", "for", "GuildMemberAdd", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L315-L319
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildMemberRemoveEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildMemberRemove); ok { eh(s, t) } }
go
func (eh guildMemberRemoveEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildMemberRemove); ok { eh(s, t) } }
[ "func", "(", "eh", "guildMemberRemoveEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildMemberRemove", ")", ";", "ok", "{", "eh", "(", "s", ",", ...
// Handle is the handler for GuildMemberRemove events.
[ "Handle", "is", "the", "handler", "for", "GuildMemberRemove", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L335-L339
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildMemberUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildMemberUpdate); ok { eh(s, t) } }
go
func (eh guildMemberUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildMemberUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "guildMemberUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildMemberUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", ...
// Handle is the handler for GuildMemberUpdate events.
[ "Handle", "is", "the", "handler", "for", "GuildMemberUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L355-L359
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildMembersChunkEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildMembersChunk); ok { eh(s, t) } }
go
func (eh guildMembersChunkEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildMembersChunk); ok { eh(s, t) } }
[ "func", "(", "eh", "guildMembersChunkEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildMembersChunk", ")", ";", "ok", "{", "eh", "(", "s", ",", ...
// Handle is the handler for GuildMembersChunk events.
[ "Handle", "is", "the", "handler", "for", "GuildMembersChunk", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L375-L379
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildRoleCreateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildRoleCreate); ok { eh(s, t) } }
go
func (eh guildRoleCreateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildRoleCreate); ok { eh(s, t) } }
[ "func", "(", "eh", "guildRoleCreateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildRoleCreate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t"...
// Handle is the handler for GuildRoleCreate events.
[ "Handle", "is", "the", "handler", "for", "GuildRoleCreate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L395-L399
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildRoleDeleteEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildRoleDelete); ok { eh(s, t) } }
go
func (eh guildRoleDeleteEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildRoleDelete); ok { eh(s, t) } }
[ "func", "(", "eh", "guildRoleDeleteEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildRoleDelete", ")", ";", "ok", "{", "eh", "(", "s", ",", "t"...
// Handle is the handler for GuildRoleDelete events.
[ "Handle", "is", "the", "handler", "for", "GuildRoleDelete", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L415-L419
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildRoleUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildRoleUpdate); ok { eh(s, t) } }
go
func (eh guildRoleUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildRoleUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "guildRoleUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildRoleUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t"...
// Handle is the handler for GuildRoleUpdate events.
[ "Handle", "is", "the", "handler", "for", "GuildRoleUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L435-L439
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh guildUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildUpdate); ok { eh(s, t) } }
go
func (eh guildUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*GuildUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "guildUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "GuildUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")",...
// Handle is the handler for GuildUpdate events.
[ "Handle", "is", "the", "handler", "for", "GuildUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L455-L459
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh messageAckEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageAck); ok { eh(s, t) } }
go
func (eh messageAckEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageAck); ok { eh(s, t) } }
[ "func", "(", "eh", "messageAckEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "MessageAck", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")", ...
// Handle is the handler for MessageAck events.
[ "Handle", "is", "the", "handler", "for", "MessageAck", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L475-L479
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh messageCreateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageCreate); ok { eh(s, t) } }
go
func (eh messageCreateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageCreate); ok { eh(s, t) } }
[ "func", "(", "eh", "messageCreateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "MessageCreate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ...
// Handle is the handler for MessageCreate events.
[ "Handle", "is", "the", "handler", "for", "MessageCreate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L495-L499
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh messageDeleteEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageDelete); ok { eh(s, t) } }
go
func (eh messageDeleteEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageDelete); ok { eh(s, t) } }
[ "func", "(", "eh", "messageDeleteEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "MessageDelete", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ...
// Handle is the handler for MessageDelete events.
[ "Handle", "is", "the", "handler", "for", "MessageDelete", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L515-L519
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh messageDeleteBulkEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageDeleteBulk); ok { eh(s, t) } }
go
func (eh messageDeleteBulkEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageDeleteBulk); ok { eh(s, t) } }
[ "func", "(", "eh", "messageDeleteBulkEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "MessageDeleteBulk", ")", ";", "ok", "{", "eh", "(", "s", ",", ...
// Handle is the handler for MessageDeleteBulk events.
[ "Handle", "is", "the", "handler", "for", "MessageDeleteBulk", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L535-L539
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh messageReactionAddEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageReactionAdd); ok { eh(s, t) } }
go
func (eh messageReactionAddEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageReactionAdd); ok { eh(s, t) } }
[ "func", "(", "eh", "messageReactionAddEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "MessageReactionAdd", ")", ";", "ok", "{", "eh", "(", "s", ",",...
// Handle is the handler for MessageReactionAdd events.
[ "Handle", "is", "the", "handler", "for", "MessageReactionAdd", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L555-L559
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh messageReactionRemoveEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageReactionRemove); ok { eh(s, t) } }
go
func (eh messageReactionRemoveEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageReactionRemove); ok { eh(s, t) } }
[ "func", "(", "eh", "messageReactionRemoveEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "MessageReactionRemove", ")", ";", "ok", "{", "eh", "(", "s", ...
// Handle is the handler for MessageReactionRemove events.
[ "Handle", "is", "the", "handler", "for", "MessageReactionRemove", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L575-L579
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh messageReactionRemoveAllEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageReactionRemoveAll); ok { eh(s, t) } }
go
func (eh messageReactionRemoveAllEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageReactionRemoveAll); ok { eh(s, t) } }
[ "func", "(", "eh", "messageReactionRemoveAllEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "MessageReactionRemoveAll", ")", ";", "ok", "{", "eh", "(", ...
// Handle is the handler for MessageReactionRemoveAll events.
[ "Handle", "is", "the", "handler", "for", "MessageReactionRemoveAll", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L595-L599
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh messageUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageUpdate); ok { eh(s, t) } }
go
func (eh messageUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*MessageUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "messageUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "MessageUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ...
// Handle is the handler for MessageUpdate events.
[ "Handle", "is", "the", "handler", "for", "MessageUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L615-L619
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh presenceUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*PresenceUpdate); ok { eh(s, t) } }
go
func (eh presenceUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*PresenceUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "presenceUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "PresenceUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ...
// Handle is the handler for PresenceUpdate events.
[ "Handle", "is", "the", "handler", "for", "PresenceUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L635-L639
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh presencesReplaceEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*PresencesReplace); ok { eh(s, t) } }
go
func (eh presencesReplaceEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*PresencesReplace); ok { eh(s, t) } }
[ "func", "(", "eh", "presencesReplaceEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "PresencesReplace", ")", ";", "ok", "{", "eh", "(", "s", ",", "...
// Handle is the handler for PresencesReplace events.
[ "Handle", "is", "the", "handler", "for", "PresencesReplace", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L655-L659
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh rateLimitEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*RateLimit); ok { eh(s, t) } }
go
func (eh rateLimitEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*RateLimit); ok { eh(s, t) } }
[ "func", "(", "eh", "rateLimitEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "RateLimit", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")", "...
// Handle is the handler for RateLimit events.
[ "Handle", "is", "the", "handler", "for", "RateLimit", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L670-L674
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh readyEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Ready); ok { eh(s, t) } }
go
func (eh readyEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Ready); ok { eh(s, t) } }
[ "func", "(", "eh", "readyEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "Ready", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")", "\n", "...
// Handle is the handler for Ready events.
[ "Handle", "is", "the", "handler", "for", "Ready", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L690-L694
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh relationshipAddEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*RelationshipAdd); ok { eh(s, t) } }
go
func (eh relationshipAddEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*RelationshipAdd); ok { eh(s, t) } }
[ "func", "(", "eh", "relationshipAddEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "RelationshipAdd", ")", ";", "ok", "{", "eh", "(", "s", ",", "t"...
// Handle is the handler for RelationshipAdd events.
[ "Handle", "is", "the", "handler", "for", "RelationshipAdd", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L710-L714
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh relationshipRemoveEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*RelationshipRemove); ok { eh(s, t) } }
go
func (eh relationshipRemoveEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*RelationshipRemove); ok { eh(s, t) } }
[ "func", "(", "eh", "relationshipRemoveEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "RelationshipRemove", ")", ";", "ok", "{", "eh", "(", "s", ",",...
// Handle is the handler for RelationshipRemove events.
[ "Handle", "is", "the", "handler", "for", "RelationshipRemove", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L730-L734
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh resumedEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Resumed); ok { eh(s, t) } }
go
func (eh resumedEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*Resumed); ok { eh(s, t) } }
[ "func", "(", "eh", "resumedEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "Resumed", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")", "\n",...
// Handle is the handler for Resumed events.
[ "Handle", "is", "the", "handler", "for", "Resumed", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L750-L754
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh typingStartEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*TypingStart); ok { eh(s, t) } }
go
func (eh typingStartEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*TypingStart); ok { eh(s, t) } }
[ "func", "(", "eh", "typingStartEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "TypingStart", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")",...
// Handle is the handler for TypingStart events.
[ "Handle", "is", "the", "handler", "for", "TypingStart", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L770-L774
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh userGuildSettingsUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*UserGuildSettingsUpdate); ok { eh(s, t) } }
go
func (eh userGuildSettingsUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*UserGuildSettingsUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "userGuildSettingsUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "UserGuildSettingsUpdate", ")", ";", "ok", "{", "eh", "(", "...
// Handle is the handler for UserGuildSettingsUpdate events.
[ "Handle", "is", "the", "handler", "for", "UserGuildSettingsUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L790-L794
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh userNoteUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*UserNoteUpdate); ok { eh(s, t) } }
go
func (eh userNoteUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*UserNoteUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "userNoteUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "UserNoteUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ...
// Handle is the handler for UserNoteUpdate events.
[ "Handle", "is", "the", "handler", "for", "UserNoteUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L810-L814
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh userSettingsUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*UserSettingsUpdate); ok { eh(s, t) } }
go
func (eh userSettingsUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*UserSettingsUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "userSettingsUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "UserSettingsUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",",...
// Handle is the handler for UserSettingsUpdate events.
[ "Handle", "is", "the", "handler", "for", "UserSettingsUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L830-L834
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh userUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*UserUpdate); ok { eh(s, t) } }
go
func (eh userUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*UserUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "userUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "UserUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ")", ...
// Handle is the handler for UserUpdate events.
[ "Handle", "is", "the", "handler", "for", "UserUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L850-L854
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh voiceServerUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*VoiceServerUpdate); ok { eh(s, t) } }
go
func (eh voiceServerUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*VoiceServerUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "voiceServerUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "VoiceServerUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", ...
// Handle is the handler for VoiceServerUpdate events.
[ "Handle", "is", "the", "handler", "for", "VoiceServerUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L870-L874
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh voiceStateUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*VoiceStateUpdate); ok { eh(s, t) } }
go
func (eh voiceStateUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*VoiceStateUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "voiceStateUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "VoiceStateUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", "...
// Handle is the handler for VoiceStateUpdate events.
[ "Handle", "is", "the", "handler", "for", "VoiceStateUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L890-L894
train
bwmarrin/discordgo
eventhandlers.go
Handle
func (eh webhooksUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*WebhooksUpdate); ok { eh(s, t) } }
go
func (eh webhooksUpdateEventHandler) Handle(s *Session, i interface{}) { if t, ok := i.(*WebhooksUpdate); ok { eh(s, t) } }
[ "func", "(", "eh", "webhooksUpdateEventHandler", ")", "Handle", "(", "s", "*", "Session", ",", "i", "interface", "{", "}", ")", "{", "if", "t", ",", "ok", ":=", "i", ".", "(", "*", "WebhooksUpdate", ")", ";", "ok", "{", "eh", "(", "s", ",", "t", ...
// Handle is the handler for WebhooksUpdate events.
[ "Handle", "is", "the", "handler", "for", "WebhooksUpdate", "events", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/eventhandlers.go#L910-L914
train
bwmarrin/discordgo
event.go
AddHandlerOnce
func (s *Session) AddHandlerOnce(handler interface{}) func() { eh := handlerForInterface(handler) if eh == nil { s.log(LogError, "Invalid handler type, handler will never be called") return func() {} } return s.addEventHandlerOnce(eh) }
go
func (s *Session) AddHandlerOnce(handler interface{}) func() { eh := handlerForInterface(handler) if eh == nil { s.log(LogError, "Invalid handler type, handler will never be called") return func() {} } return s.addEventHandlerOnce(eh) }
[ "func", "(", "s", "*", "Session", ")", "AddHandlerOnce", "(", "handler", "interface", "{", "}", ")", "func", "(", ")", "{", "eh", ":=", "handlerForInterface", "(", "handler", ")", "\n\n", "if", "eh", "==", "nil", "{", "s", ".", "log", "(", "LogError"...
// AddHandlerOnce allows you to add an event handler that will be fired the next time // the Discord WSAPI event that matches the function fires. // See AddHandler for more details.
[ "AddHandlerOnce", "allows", "you", "to", "add", "an", "event", "handler", "that", "will", "be", "fired", "the", "next", "time", "the", "Discord", "WSAPI", "event", "that", "matches", "the", "function", "fires", ".", "See", "AddHandler", "for", "more", "detai...
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/event.go#L134-L143
train
bwmarrin/discordgo
event.go
removeEventHandlerInstance
func (s *Session) removeEventHandlerInstance(t string, ehi *eventHandlerInstance) { s.handlersMu.Lock() defer s.handlersMu.Unlock() handlers := s.handlers[t] for i := range handlers { if handlers[i] == ehi { s.handlers[t] = append(handlers[:i], handlers[i+1:]...) } } onceHandlers := s.onceHandlers[t] fo...
go
func (s *Session) removeEventHandlerInstance(t string, ehi *eventHandlerInstance) { s.handlersMu.Lock() defer s.handlersMu.Unlock() handlers := s.handlers[t] for i := range handlers { if handlers[i] == ehi { s.handlers[t] = append(handlers[:i], handlers[i+1:]...) } } onceHandlers := s.onceHandlers[t] fo...
[ "func", "(", "s", "*", "Session", ")", "removeEventHandlerInstance", "(", "t", "string", ",", "ehi", "*", "eventHandlerInstance", ")", "{", "s", ".", "handlersMu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "handlersMu", ".", "Unlock", "(", ")", "...
// removeEventHandler instance removes an event handler instance.
[ "removeEventHandler", "instance", "removes", "an", "event", "handler", "instance", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/event.go#L146-L163
train
bwmarrin/discordgo
event.go
handle
func (s *Session) handle(t string, i interface{}) { for _, eh := range s.handlers[t] { if s.SyncEvents { eh.eventHandler.Handle(s, i) } else { go eh.eventHandler.Handle(s, i) } } if len(s.onceHandlers[t]) > 0 { for _, eh := range s.onceHandlers[t] { if s.SyncEvents { eh.eventHandler.Handle(s, i...
go
func (s *Session) handle(t string, i interface{}) { for _, eh := range s.handlers[t] { if s.SyncEvents { eh.eventHandler.Handle(s, i) } else { go eh.eventHandler.Handle(s, i) } } if len(s.onceHandlers[t]) > 0 { for _, eh := range s.onceHandlers[t] { if s.SyncEvents { eh.eventHandler.Handle(s, i...
[ "func", "(", "s", "*", "Session", ")", "handle", "(", "t", "string", ",", "i", "interface", "{", "}", ")", "{", "for", "_", ",", "eh", ":=", "range", "s", ".", "handlers", "[", "t", "]", "{", "if", "s", ".", "SyncEvents", "{", "eh", ".", "eve...
// Handles calling permanent and once handlers for an event type.
[ "Handles", "calling", "permanent", "and", "once", "handlers", "for", "an", "event", "type", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/event.go#L166-L185
train
bwmarrin/discordgo
event.go
setGuildIds
func setGuildIds(g *Guild) { for _, c := range g.Channels { c.GuildID = g.ID } for _, m := range g.Members { m.GuildID = g.ID } for _, vs := range g.VoiceStates { vs.GuildID = g.ID } }
go
func setGuildIds(g *Guild) { for _, c := range g.Channels { c.GuildID = g.ID } for _, m := range g.Members { m.GuildID = g.ID } for _, vs := range g.VoiceStates { vs.GuildID = g.ID } }
[ "func", "setGuildIds", "(", "g", "*", "Guild", ")", "{", "for", "_", ",", "c", ":=", "range", "g", ".", "Channels", "{", "c", ".", "GuildID", "=", "g", ".", "ID", "\n", "}", "\n\n", "for", "_", ",", "m", ":=", "range", "g", ".", "Members", "{...
// setGuildIds will set the GuildID on all the members of a guild. // This is done as event data does not have it set.
[ "setGuildIds", "will", "set", "the", "GuildID", "on", "all", "the", "members", "of", "a", "guild", ".", "This", "is", "done", "as", "event", "data", "does", "not", "have", "it", "set", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/event.go#L205-L217
train
bwmarrin/discordgo
event.go
onInterface
func (s *Session) onInterface(i interface{}) { switch t := i.(type) { case *Ready: for _, g := range t.Guilds { setGuildIds(g) } s.onReady(t) case *GuildCreate: setGuildIds(t.Guild) case *GuildUpdate: setGuildIds(t.Guild) case *VoiceServerUpdate: go s.onVoiceServerUpdate(t) case *VoiceStateUpdate: ...
go
func (s *Session) onInterface(i interface{}) { switch t := i.(type) { case *Ready: for _, g := range t.Guilds { setGuildIds(g) } s.onReady(t) case *GuildCreate: setGuildIds(t.Guild) case *GuildUpdate: setGuildIds(t.Guild) case *VoiceServerUpdate: go s.onVoiceServerUpdate(t) case *VoiceStateUpdate: ...
[ "func", "(", "s", "*", "Session", ")", "onInterface", "(", "i", "interface", "{", "}", ")", "{", "switch", "t", ":=", "i", ".", "(", "type", ")", "{", "case", "*", "Ready", ":", "for", "_", ",", "g", ":=", "range", "t", ".", "Guilds", "{", "s...
// onInterface handles all internal events and routes them to the appropriate internal handler.
[ "onInterface", "handles", "all", "internal", "events", "and", "routes", "them", "to", "the", "appropriate", "internal", "handler", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/event.go#L220-L240
train
bwmarrin/discordgo
types.go
Parse
func (t Timestamp) Parse() (time.Time, error) { return time.Parse(time.RFC3339, string(t)) }
go
func (t Timestamp) Parse() (time.Time, error) { return time.Parse(time.RFC3339, string(t)) }
[ "func", "(", "t", "Timestamp", ")", "Parse", "(", ")", "(", "time", ".", "Time", ",", "error", ")", "{", "return", "time", ".", "Parse", "(", "time", ".", "RFC3339", ",", "string", "(", "t", ")", ")", "\n", "}" ]
// Parse parses a timestamp string into a time.Time object. // The only time this can fail is if Discord changes their timestamp format.
[ "Parse", "parses", "a", "timestamp", "string", "into", "a", "time", ".", "Time", "object", ".", "The", "only", "time", "this", "can", "fail", "is", "if", "Discord", "changes", "their", "timestamp", "format", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/types.go#L23-L25
train
bwmarrin/discordgo
wsapi.go
listen
func (s *Session) listen(wsConn *websocket.Conn, listening <-chan interface{}) { s.log(LogInformational, "called") for { messageType, message, err := wsConn.ReadMessage() if err != nil { // Detect if we have been closed manually. If a Close() has already // happened, the websocket we are listening on w...
go
func (s *Session) listen(wsConn *websocket.Conn, listening <-chan interface{}) { s.log(LogInformational, "called") for { messageType, message, err := wsConn.ReadMessage() if err != nil { // Detect if we have been closed manually. If a Close() has already // happened, the websocket we are listening on w...
[ "func", "(", "s", "*", "Session", ")", "listen", "(", "wsConn", "*", "websocket", ".", "Conn", ",", "listening", "<-", "chan", "interface", "{", "}", ")", "{", "s", ".", "log", "(", "LogInformational", ",", "\"", "\"", ")", "\n\n", "for", "{", "mes...
// listen polls the websocket connection for events, it will stop when the // listening channel is closed, or an error occurs.
[ "listen", "polls", "the", "websocket", "connection", "for", "events", "it", "will", "stop", "when", "the", "listening", "channel", "is", "closed", "or", "an", "error", "occurs", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L211-L255
train
bwmarrin/discordgo
wsapi.go
HeartbeatLatency
func (s *Session) HeartbeatLatency() time.Duration { return s.LastHeartbeatAck.Sub(s.LastHeartbeatSent) }
go
func (s *Session) HeartbeatLatency() time.Duration { return s.LastHeartbeatAck.Sub(s.LastHeartbeatSent) }
[ "func", "(", "s", "*", "Session", ")", "HeartbeatLatency", "(", ")", "time", ".", "Duration", "{", "return", "s", ".", "LastHeartbeatAck", ".", "Sub", "(", "s", ".", "LastHeartbeatSent", ")", "\n\n", "}" ]
// HeartbeatLatency returns the latency between heartbeat acknowledgement and heartbeat send.
[ "HeartbeatLatency", "returns", "the", "latency", "between", "heartbeat", "acknowledgement", "and", "heartbeat", "send", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L271-L275
train
bwmarrin/discordgo
wsapi.go
heartbeat
func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{}, heartbeatIntervalMsec time.Duration) { s.log(LogInformational, "called") if listening == nil || wsConn == nil { return } var err error ticker := time.NewTicker(heartbeatIntervalMsec * time.Millisecond) defer ticker.Stop() for...
go
func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{}, heartbeatIntervalMsec time.Duration) { s.log(LogInformational, "called") if listening == nil || wsConn == nil { return } var err error ticker := time.NewTicker(heartbeatIntervalMsec * time.Millisecond) defer ticker.Stop() for...
[ "func", "(", "s", "*", "Session", ")", "heartbeat", "(", "wsConn", "*", "websocket", ".", "Conn", ",", "listening", "<-", "chan", "interface", "{", "}", ",", "heartbeatIntervalMsec", "time", ".", "Duration", ")", "{", "s", ".", "log", "(", "LogInformatio...
// heartbeat sends regular heartbeats to Discord so it knows the client // is still connected. If you do not send these heartbeats Discord will // disconnect the websocket connection after a few seconds.
[ "heartbeat", "sends", "regular", "heartbeats", "to", "Discord", "so", "it", "knows", "the", "client", "is", "still", "connected", ".", "If", "you", "do", "not", "send", "these", "heartbeats", "Discord", "will", "disconnect", "the", "websocket", "connection", "...
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L280-L323
train
bwmarrin/discordgo
wsapi.go
UpdateStatus
func (s *Session) UpdateStatus(idle int, game string) (err error) { return s.UpdateStatusComplex(*newUpdateStatusData(idle, GameTypeGame, game, "")) }
go
func (s *Session) UpdateStatus(idle int, game string) (err error) { return s.UpdateStatusComplex(*newUpdateStatusData(idle, GameTypeGame, game, "")) }
[ "func", "(", "s", "*", "Session", ")", "UpdateStatus", "(", "idle", "int", ",", "game", "string", ")", "(", "err", "error", ")", "{", "return", "s", ".", "UpdateStatusComplex", "(", "*", "newUpdateStatusData", "(", "idle", ",", "GameTypeGame", ",", "game...
// UpdateStatus is used to update the user's status. // If idle>0 then set status to idle. // If game!="" then set game. // if otherwise, set status to active, and no game.
[ "UpdateStatus", "is", "used", "to", "update", "the", "user", "s", "status", ".", "If", "idle", ">", "0", "then", "set", "status", "to", "idle", ".", "If", "game!", "=", "then", "set", "game", ".", "if", "otherwise", "set", "status", "to", "active", "...
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L362-L364
train
bwmarrin/discordgo
wsapi.go
UpdateStreamingStatus
func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err error) { gameType := GameTypeGame if url != "" { gameType = GameTypeStreaming } return s.UpdateStatusComplex(*newUpdateStatusData(idle, gameType, game, url)) }
go
func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err error) { gameType := GameTypeGame if url != "" { gameType = GameTypeStreaming } return s.UpdateStatusComplex(*newUpdateStatusData(idle, gameType, game, url)) }
[ "func", "(", "s", "*", "Session", ")", "UpdateStreamingStatus", "(", "idle", "int", ",", "game", "string", ",", "url", "string", ")", "(", "err", "error", ")", "{", "gameType", ":=", "GameTypeGame", "\n", "if", "url", "!=", "\"", "\"", "{", "gameType",...
// UpdateStreamingStatus is used to update the user's streaming status. // If idle>0 then set status to idle. // If game!="" then set game. // If game!="" and url!="" then set the status type to streaming with the URL set. // if otherwise, set status to active, and no game.
[ "UpdateStreamingStatus", "is", "used", "to", "update", "the", "user", "s", "streaming", "status", ".", "If", "idle", ">", "0", "then", "set", "status", "to", "idle", ".", "If", "game!", "=", "then", "set", "game", ".", "If", "game!", "=", "and", "url!"...
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L371-L377
train
bwmarrin/discordgo
wsapi.go
UpdateListeningStatus
func (s *Session) UpdateListeningStatus(game string) (err error) { return s.UpdateStatusComplex(*newUpdateStatusData(0, GameTypeListening, game, "")) }
go
func (s *Session) UpdateListeningStatus(game string) (err error) { return s.UpdateStatusComplex(*newUpdateStatusData(0, GameTypeListening, game, "")) }
[ "func", "(", "s", "*", "Session", ")", "UpdateListeningStatus", "(", "game", "string", ")", "(", "err", "error", ")", "{", "return", "s", ".", "UpdateStatusComplex", "(", "*", "newUpdateStatusData", "(", "0", ",", "GameTypeListening", ",", "game", ",", "\"...
// UpdateListeningStatus is used to set the user to "Listening to..." // If game!="" then set to what user is listening to // Else, set user to active and no game.
[ "UpdateListeningStatus", "is", "used", "to", "set", "the", "user", "to", "Listening", "to", "...", "If", "game!", "=", "then", "set", "to", "what", "user", "is", "listening", "to", "Else", "set", "user", "to", "active", "and", "no", "game", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L382-L384
train
bwmarrin/discordgo
wsapi.go
UpdateStatusComplex
func (s *Session) UpdateStatusComplex(usd UpdateStatusData) (err error) { s.RLock() defer s.RUnlock() if s.wsConn == nil { return ErrWSNotFound } s.wsMutex.Lock() err = s.wsConn.WriteJSON(updateStatusOp{3, usd}) s.wsMutex.Unlock() return }
go
func (s *Session) UpdateStatusComplex(usd UpdateStatusData) (err error) { s.RLock() defer s.RUnlock() if s.wsConn == nil { return ErrWSNotFound } s.wsMutex.Lock() err = s.wsConn.WriteJSON(updateStatusOp{3, usd}) s.wsMutex.Unlock() return }
[ "func", "(", "s", "*", "Session", ")", "UpdateStatusComplex", "(", "usd", "UpdateStatusData", ")", "(", "err", "error", ")", "{", "s", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "RUnlock", "(", ")", "\n", "if", "s", ".", "wsConn", "==", "nil"...
// UpdateStatusComplex allows for sending the raw status update data untouched by discordgo.
[ "UpdateStatusComplex", "allows", "for", "sending", "the", "raw", "status", "update", "data", "untouched", "by", "discordgo", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L387-L400
train
bwmarrin/discordgo
wsapi.go
onVoiceStateUpdate
func (s *Session) onVoiceStateUpdate(st *VoiceStateUpdate) { // If we don't have a connection for the channel, don't bother if st.ChannelID == "" { return } // Check if we have a voice connection to update s.RLock() voice, exists := s.VoiceConnections[st.GuildID] s.RUnlock() if !exists { return } // We...
go
func (s *Session) onVoiceStateUpdate(st *VoiceStateUpdate) { // If we don't have a connection for the channel, don't bother if st.ChannelID == "" { return } // Check if we have a voice connection to update s.RLock() voice, exists := s.VoiceConnections[st.GuildID] s.RUnlock() if !exists { return } // We...
[ "func", "(", "s", "*", "Session", ")", "onVoiceStateUpdate", "(", "st", "*", "VoiceStateUpdate", ")", "{", "// If we don't have a connection for the channel, don't bother", "if", "st", ".", "ChannelID", "==", "\"", "\"", "{", "return", "\n", "}", "\n\n", "// Check...
// onVoiceStateUpdate handles Voice State Update events on the data websocket.
[ "onVoiceStateUpdate", "handles", "Voice", "State", "Update", "events", "on", "the", "data", "websocket", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L663-L689
train
bwmarrin/discordgo
wsapi.go
onVoiceServerUpdate
func (s *Session) onVoiceServerUpdate(st *VoiceServerUpdate) { s.log(LogInformational, "called") s.RLock() voice, exists := s.VoiceConnections[st.GuildID] s.RUnlock() // If no VoiceConnection exists, just skip this if !exists { return } // If currently connected to voice ws/udp, then disconnect. // Has n...
go
func (s *Session) onVoiceServerUpdate(st *VoiceServerUpdate) { s.log(LogInformational, "called") s.RLock() voice, exists := s.VoiceConnections[st.GuildID] s.RUnlock() // If no VoiceConnection exists, just skip this if !exists { return } // If currently connected to voice ws/udp, then disconnect. // Has n...
[ "func", "(", "s", "*", "Session", ")", "onVoiceServerUpdate", "(", "st", "*", "VoiceServerUpdate", ")", "{", "s", ".", "log", "(", "LogInformational", ",", "\"", "\"", ")", "\n\n", "s", ".", "RLock", "(", ")", "\n", "voice", ",", "exists", ":=", "s",...
// onVoiceServerUpdate handles the Voice Server Update data websocket event. // // This is also fired if the Guild's voice region changes while connected // to a voice channel. In that case, need to re-establish connection to // the new region endpoint.
[ "onVoiceServerUpdate", "handles", "the", "Voice", "Server", "Update", "data", "websocket", "event", ".", "This", "is", "also", "fired", "if", "the", "Guild", "s", "voice", "region", "changes", "while", "connected", "to", "a", "voice", "channel", ".", "In", "...
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L696-L725
train
bwmarrin/discordgo
wsapi.go
identify
func (s *Session) identify() error { properties := identifyProperties{runtime.GOOS, "Discordgo v" + VERSION, "", "", "", } data := identifyData{s.Token, properties, 250, s.Compress, nil, } if s.ShardCount > 1 { if s.ShardID >= s.ShardCount { return ErrWSShardBounds } data.Shard = &[2]...
go
func (s *Session) identify() error { properties := identifyProperties{runtime.GOOS, "Discordgo v" + VERSION, "", "", "", } data := identifyData{s.Token, properties, 250, s.Compress, nil, } if s.ShardCount > 1 { if s.ShardID >= s.ShardCount { return ErrWSShardBounds } data.Shard = &[2]...
[ "func", "(", "s", "*", "Session", ")", "identify", "(", ")", "error", "{", "properties", ":=", "identifyProperties", "{", "runtime", ".", "GOOS", ",", "\"", "\"", "+", "VERSION", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "}", "\n\n", ...
// identify sends the identify packet to the gateway
[ "identify", "sends", "the", "identify", "packet", "to", "the", "gateway" ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/wsapi.go#L749-L781
train
bwmarrin/discordgo
oauth2.go
Applications
func (s *Session) Applications() (st []*Application, err error) { body, err := s.RequestWithBucketID("GET", EndpointApplications, nil, EndpointApplications) if err != nil { return } err = unmarshal(body, &st) return }
go
func (s *Session) Applications() (st []*Application, err error) { body, err := s.RequestWithBucketID("GET", EndpointApplications, nil, EndpointApplications) if err != nil { return } err = unmarshal(body, &st) return }
[ "func", "(", "s", "*", "Session", ")", "Applications", "(", ")", "(", "st", "[", "]", "*", "Application", ",", "err", "error", ")", "{", "body", ",", "err", ":=", "s", ".", "RequestWithBucketID", "(", "\"", "\"", ",", "EndpointApplications", ",", "ni...
// Applications returns all applications for the authenticated user
[ "Applications", "returns", "all", "applications", "for", "the", "authenticated", "user" ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/oauth2.go#L46-L55
train
bwmarrin/discordgo
logging.go
log
func (s *Session) log(msgL int, format string, a ...interface{}) { if msgL > s.LogLevel { return } msglog(msgL, 2, format, a...) }
go
func (s *Session) log(msgL int, format string, a ...interface{}) { if msgL > s.LogLevel { return } msglog(msgL, 2, format, a...) }
[ "func", "(", "s", "*", "Session", ")", "log", "(", "msgL", "int", ",", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "if", "msgL", ">", "s", ".", "LogLevel", "{", "return", "\n", "}", "\n\n", "msglog", "(", "msgL", ",", ...
// helper function that wraps msglog for the Session struct // This adds a check to insure the message is only logged // if the session log level is equal or higher than the // message log level
[ "helper", "function", "that", "wraps", "msglog", "for", "the", "Session", "struct", "This", "adds", "a", "check", "to", "insure", "the", "message", "is", "only", "logged", "if", "the", "session", "log", "level", "is", "equal", "or", "higher", "than", "the"...
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/logging.go#L71-L78
train
bwmarrin/discordgo
logging.go
log
func (v *VoiceConnection) log(msgL int, format string, a ...interface{}) { if msgL > v.LogLevel { return } msglog(msgL, 2, format, a...) }
go
func (v *VoiceConnection) log(msgL int, format string, a ...interface{}) { if msgL > v.LogLevel { return } msglog(msgL, 2, format, a...) }
[ "func", "(", "v", "*", "VoiceConnection", ")", "log", "(", "msgL", "int", ",", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "if", "msgL", ">", "v", ".", "LogLevel", "{", "return", "\n", "}", "\n\n", "msglog", "(", "msgL", ...
// helper function that wraps msglog for the VoiceConnection struct // This adds a check to insure the message is only logged // if the voice connection log level is equal or higher than the // message log level
[ "helper", "function", "that", "wraps", "msglog", "for", "the", "VoiceConnection", "struct", "This", "adds", "a", "check", "to", "insure", "the", "message", "is", "only", "logged", "if", "the", "voice", "connection", "log", "level", "is", "equal", "or", "high...
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/logging.go#L84-L91
train
bwmarrin/discordgo
examples/airhorn/main.go
loadSound
func loadSound() error { file, err := os.Open("airhorn.dca") if err != nil { fmt.Println("Error opening dca file :", err) return err } var opuslen int16 for { // Read opus frame length from dca file. err = binary.Read(file, binary.LittleEndian, &opuslen) // If this is the end of the file, just return...
go
func loadSound() error { file, err := os.Open("airhorn.dca") if err != nil { fmt.Println("Error opening dca file :", err) return err } var opuslen int16 for { // Read opus frame length from dca file. err = binary.Read(file, binary.LittleEndian, &opuslen) // If this is the end of the file, just return...
[ "func", "loadSound", "(", ")", "error", "{", "file", ",", "err", ":=", "os", ".", "Open", "(", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Println", "(", "\"", "\"", ",", "err", ")", "\n", "return", "err", "\n", "}", "\...
// loadSound attempts to load an encoded sound file from disk.
[ "loadSound", "attempts", "to", "load", "an", "encoded", "sound", "file", "from", "disk", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/examples/airhorn/main.go#L138-L179
train
bwmarrin/discordgo
examples/airhorn/main.go
playSound
func playSound(s *discordgo.Session, guildID, channelID string) (err error) { // Join the provided voice channel. vc, err := s.ChannelVoiceJoin(guildID, channelID, false, true) if err != nil { return err } // Sleep for a specified amount of time before playing the sound time.Sleep(250 * time.Millisecond) //...
go
func playSound(s *discordgo.Session, guildID, channelID string) (err error) { // Join the provided voice channel. vc, err := s.ChannelVoiceJoin(guildID, channelID, false, true) if err != nil { return err } // Sleep for a specified amount of time before playing the sound time.Sleep(250 * time.Millisecond) //...
[ "func", "playSound", "(", "s", "*", "discordgo", ".", "Session", ",", "guildID", ",", "channelID", "string", ")", "(", "err", "error", ")", "{", "// Join the provided voice channel.", "vc", ",", "err", ":=", "s", ".", "ChannelVoiceJoin", "(", "guildID", ",",...
// playSound plays the current buffer to the provided channel.
[ "playSound", "plays", "the", "current", "buffer", "to", "the", "provided", "channel", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/examples/airhorn/main.go#L182-L211
train
bwmarrin/discordgo
message.go
NewMessageEdit
func NewMessageEdit(channelID string, messageID string) *MessageEdit { return &MessageEdit{ Channel: channelID, ID: messageID, } }
go
func NewMessageEdit(channelID string, messageID string) *MessageEdit { return &MessageEdit{ Channel: channelID, ID: messageID, } }
[ "func", "NewMessageEdit", "(", "channelID", "string", ",", "messageID", "string", ")", "*", "MessageEdit", "{", "return", "&", "MessageEdit", "{", "Channel", ":", "channelID", ",", "ID", ":", "messageID", ",", "}", "\n", "}" ]
// NewMessageEdit returns a MessageEdit struct, initialized // with the Channel and ID.
[ "NewMessageEdit", "returns", "a", "MessageEdit", "struct", "initialized", "with", "the", "Channel", "and", "ID", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/message.go#L120-L125
train
bwmarrin/discordgo
message.go
SetContent
func (m *MessageEdit) SetContent(str string) *MessageEdit { m.Content = &str return m }
go
func (m *MessageEdit) SetContent(str string) *MessageEdit { m.Content = &str return m }
[ "func", "(", "m", "*", "MessageEdit", ")", "SetContent", "(", "str", "string", ")", "*", "MessageEdit", "{", "m", ".", "Content", "=", "&", "str", "\n", "return", "m", "\n", "}" ]
// SetContent is the same as setting the variable Content, // except it doesn't take a pointer.
[ "SetContent", "is", "the", "same", "as", "setting", "the", "variable", "Content", "except", "it", "doesn", "t", "take", "a", "pointer", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/message.go#L129-L132
train
bwmarrin/discordgo
message.go
SetEmbed
func (m *MessageEdit) SetEmbed(embed *MessageEmbed) *MessageEdit { m.Embed = embed return m }
go
func (m *MessageEdit) SetEmbed(embed *MessageEmbed) *MessageEdit { m.Embed = embed return m }
[ "func", "(", "m", "*", "MessageEdit", ")", "SetEmbed", "(", "embed", "*", "MessageEmbed", ")", "*", "MessageEdit", "{", "m", ".", "Embed", "=", "embed", "\n", "return", "m", "\n", "}" ]
// SetEmbed is a convenience function for setting the embed, // so you can chain commands.
[ "SetEmbed", "is", "a", "convenience", "function", "for", "setting", "the", "embed", "so", "you", "can", "chain", "commands", "." ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/message.go#L136-L139
train
bwmarrin/discordgo
message.go
ContentWithMentionsReplaced
func (m *Message) ContentWithMentionsReplaced() (content string) { content = m.Content for _, user := range m.Mentions { content = strings.NewReplacer( "<@"+user.ID+">", "@"+user.Username, "<@!"+user.ID+">", "@"+user.Username, ).Replace(content) } return }
go
func (m *Message) ContentWithMentionsReplaced() (content string) { content = m.Content for _, user := range m.Mentions { content = strings.NewReplacer( "<@"+user.ID+">", "@"+user.Username, "<@!"+user.ID+">", "@"+user.Username, ).Replace(content) } return }
[ "func", "(", "m", "*", "Message", ")", "ContentWithMentionsReplaced", "(", ")", "(", "content", "string", ")", "{", "content", "=", "m", ".", "Content", "\n\n", "for", "_", ",", "user", ":=", "range", "m", ".", "Mentions", "{", "content", "=", "strings...
// ContentWithMentionsReplaced will replace all @<id> mentions with the // username of the mention.
[ "ContentWithMentionsReplaced", "will", "replace", "all" ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/message.go#L230-L240
train
bwmarrin/discordgo
message.go
ContentWithMoreMentionsReplaced
func (m *Message) ContentWithMoreMentionsReplaced(s *Session) (content string, err error) { content = m.Content if !s.StateEnabled { content = m.ContentWithMentionsReplaced() return } channel, err := s.State.Channel(m.ChannelID) if err != nil { content = m.ContentWithMentionsReplaced() return } for _,...
go
func (m *Message) ContentWithMoreMentionsReplaced(s *Session) (content string, err error) { content = m.Content if !s.StateEnabled { content = m.ContentWithMentionsReplaced() return } channel, err := s.State.Channel(m.ChannelID) if err != nil { content = m.ContentWithMentionsReplaced() return } for _,...
[ "func", "(", "m", "*", "Message", ")", "ContentWithMoreMentionsReplaced", "(", "s", "*", "Session", ")", "(", "content", "string", ",", "err", "error", ")", "{", "content", "=", "m", ".", "Content", "\n\n", "if", "!", "s", ".", "StateEnabled", "{", "co...
// ContentWithMoreMentionsReplaced will replace all @<id> mentions with the // username of the mention, but also role IDs and more.
[ "ContentWithMoreMentionsReplaced", "will", "replace", "all" ]
8325a6bf6dd6c91ed4040a1617b07287b8fb0eba
https://github.com/bwmarrin/discordgo/blob/8325a6bf6dd6c91ed4040a1617b07287b8fb0eba/message.go#L246-L291
train
markbates/goth
provider.go
UseProviders
func UseProviders(viders ...Provider) { for _, provider := range viders { providers[provider.Name()] = provider } }
go
func UseProviders(viders ...Provider) { for _, provider := range viders { providers[provider.Name()] = provider } }
[ "func", "UseProviders", "(", "viders", "...", "Provider", ")", "{", "for", "_", ",", "provider", ":=", "range", "viders", "{", "providers", "[", "provider", ".", "Name", "(", ")", "]", "=", "provider", "\n", "}", "\n", "}" ]
// UseProviders adds a list of available providers for use with Goth. // Can be called multiple times. If you pass the same provider more // than once, the last will be used.
[ "UseProviders", "adds", "a", "list", "of", "available", "providers", "for", "use", "with", "Goth", ".", "Can", "be", "called", "multiple", "times", ".", "If", "you", "pass", "the", "same", "provider", "more", "than", "once", "the", "last", "will", "be", ...
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/provider.go#L34-L38
train
markbates/goth
provider.go
GetProvider
func GetProvider(name string) (Provider, error) { provider := providers[name] if provider == nil { return nil, fmt.Errorf("no provider for %s exists", name) } return provider, nil }
go
func GetProvider(name string) (Provider, error) { provider := providers[name] if provider == nil { return nil, fmt.Errorf("no provider for %s exists", name) } return provider, nil }
[ "func", "GetProvider", "(", "name", "string", ")", "(", "Provider", ",", "error", ")", "{", "provider", ":=", "providers", "[", "name", "]", "\n", "if", "provider", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", ...
// GetProvider returns a previously created provider. If Goth has not // been told to use the named provider it will return an error.
[ "GetProvider", "returns", "a", "previously", "created", "provider", ".", "If", "Goth", "has", "not", "been", "told", "to", "use", "the", "named", "provider", "it", "will", "return", "an", "error", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/provider.go#L47-L53
train
markbates/goth
provider.go
ContextForClient
func ContextForClient(h *http.Client) context.Context { if h == nil { return oauth2.NoContext } return context.WithValue(oauth2.NoContext, oauth2.HTTPClient, h) }
go
func ContextForClient(h *http.Client) context.Context { if h == nil { return oauth2.NoContext } return context.WithValue(oauth2.NoContext, oauth2.HTTPClient, h) }
[ "func", "ContextForClient", "(", "h", "*", "http", ".", "Client", ")", "context", ".", "Context", "{", "if", "h", "==", "nil", "{", "return", "oauth2", ".", "NoContext", "\n", "}", "\n", "return", "context", ".", "WithValue", "(", "oauth2", ".", "NoCon...
// ContextForClient provides a context for use with oauth2.
[ "ContextForClient", "provides", "a", "context", "for", "use", "with", "oauth2", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/provider.go#L62-L67
train
markbates/goth
provider.go
HTTPClientWithFallBack
func HTTPClientWithFallBack(h *http.Client) *http.Client { if h != nil { return h } return http.DefaultClient }
go
func HTTPClientWithFallBack(h *http.Client) *http.Client { if h != nil { return h } return http.DefaultClient }
[ "func", "HTTPClientWithFallBack", "(", "h", "*", "http", ".", "Client", ")", "*", "http", ".", "Client", "{", "if", "h", "!=", "nil", "{", "return", "h", "\n", "}", "\n", "return", "http", ".", "DefaultClient", "\n", "}" ]
// HTTPClientWithFallBack to be used in all fetch operations.
[ "HTTPClientWithFallBack", "to", "be", "used", "in", "all", "fetch", "operations", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/provider.go#L70-L75
train
markbates/goth
providers/xero/session.go
Authorize
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) if p.Method == "private" { return p.ClientKey, nil } accessToken, err := p.consumer.AuthorizeToken(s.RequestToken, params.Get("oauth_verifier")) if err != nil { return "", err } s.AccessTokenE...
go
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) if p.Method == "private" { return p.ClientKey, nil } accessToken, err := p.consumer.AuthorizeToken(s.RequestToken, params.Get("oauth_verifier")) if err != nil { return "", err } s.AccessTokenE...
[ "func", "(", "s", "*", "Session", ")", "Authorize", "(", "provider", "goth", ".", "Provider", ",", "params", "goth", ".", "Params", ")", "(", "string", ",", "error", ")", "{", "p", ":=", "provider", ".", "(", "*", "Provider", ")", "\n", "if", "p", ...
// Authorize the session with Xero and return the access token to be stored for future use.
[ "Authorize", "the", "session", "with", "Xero", "and", "return", "the", "access", "token", "to", "be", "stored", "for", "future", "use", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/xero/session.go#L30-L44
train
markbates/goth
providers/xero/session.go
Marshal
func (s Session) Marshal() string { b, _ := json.Marshal(s) return string(b) }
go
func (s Session) Marshal() string { b, _ := json.Marshal(s) return string(b) }
[ "func", "(", "s", "Session", ")", "Marshal", "(", ")", "string", "{", "b", ",", "_", ":=", "json", ".", "Marshal", "(", "s", ")", "\n", "return", "string", "(", "b", ")", "\n", "}" ]
// Marshal the session into a string
[ "Marshal", "the", "session", "into", "a", "string" ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/xero/session.go#L47-L50
train
markbates/goth
providers/influxcloud/influxcloud.go
New
func New(clientKey, secret, callbackURL string, scopes ...string) *Provider { domain := os.Getenv(domainEnvKey) if domain == "" { domain = defaultDomain } tokenURL := fmt.Sprintf("https://%s%s", domain, tokenPath) authURL := fmt.Sprintf("https://%s%s", domain, authPath) userAPIEndpoint := fmt.Sprintf("https://%...
go
func New(clientKey, secret, callbackURL string, scopes ...string) *Provider { domain := os.Getenv(domainEnvKey) if domain == "" { domain = defaultDomain } tokenURL := fmt.Sprintf("https://%s%s", domain, tokenPath) authURL := fmt.Sprintf("https://%s%s", domain, authPath) userAPIEndpoint := fmt.Sprintf("https://%...
[ "func", "New", "(", "clientKey", ",", "secret", ",", "callbackURL", "string", ",", "scopes", "...", "string", ")", "*", "Provider", "{", "domain", ":=", "os", ".", "Getenv", "(", "domainEnvKey", ")", "\n", "if", "domain", "==", "\"", "\"", "{", "domain...
// New creates a new influx provider, and sets up important connection details. // You should always call `influxcloud.New` to get a new Provider. Never try to create // one manually.
[ "New", "creates", "a", "new", "influx", "provider", "and", "sets", "up", "important", "connection", "details", ".", "You", "should", "always", "call", "influxcloud", ".", "New", "to", "get", "a", "new", "Provider", ".", "Never", "try", "to", "create", "one...
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/influxcloud/influxcloud.go#L34-L44
train
markbates/goth
providers/influxcloud/influxcloud.go
RefreshToken
func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) { return nil, errors.New("Refresh token is not provided by influxcloud") }
go
func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) { return nil, errors.New("Refresh token is not provided by influxcloud") }
[ "func", "(", "p", "*", "Provider", ")", "RefreshToken", "(", "refreshToken", "string", ")", "(", "*", "oauth2", ".", "Token", ",", "error", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
//RefreshToken refresh token is not provided by influxcloud
[ "RefreshToken", "refresh", "token", "is", "not", "provided", "by", "influxcloud" ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/influxcloud/influxcloud.go#L174-L176
train
markbates/goth
providers/tumblr/tumblr.go
FetchUser
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ Provider: p.Name(), } if sess.AccessToken == nil { // data is not yet retrieved since accessToken is still empty return user, fmt.Errorf("%s cannot get user information without accessToken", ...
go
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ Provider: p.Name(), } if sess.AccessToken == nil { // data is not yet retrieved since accessToken is still empty return user, fmt.Errorf("%s cannot get user information without accessToken", ...
[ "func", "(", "p", "*", "Provider", ")", "FetchUser", "(", "session", "goth", ".", "Session", ")", "(", "goth", ".", "User", ",", "error", ")", "{", "sess", ":=", "session", ".", "(", "*", "Session", ")", "\n", "user", ":=", "goth", ".", "User", "...
// FetchUser will go to Tumblr and access basic information about the user.
[ "FetchUser", "will", "go", "to", "Tumblr", "and", "access", "basic", "information", "about", "the", "user", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/tumblr/tumblr.go#L89-L128
train
markbates/goth
providers/yandex/yandex.go
FetchUser
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ AccessToken: sess.AccessToken, Provider: p.Name(), RefreshToken: sess.RefreshToken, ExpiresAt: sess.ExpiresAt, } if user.AccessToken == "" { // data is not yet retrieved since acc...
go
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ AccessToken: sess.AccessToken, Provider: p.Name(), RefreshToken: sess.RefreshToken, ExpiresAt: sess.ExpiresAt, } if user.AccessToken == "" { // data is not yet retrieved since acc...
[ "func", "(", "p", "*", "Provider", ")", "FetchUser", "(", "session", "goth", ".", "Session", ")", "(", "goth", ".", "User", ",", "error", ")", "{", "sess", ":=", "session", ".", "(", "*", "Session", ")", "\n", "user", ":=", "goth", ".", "User", "...
// FetchUser will go to Yandex and access basic information about the user.
[ "FetchUser", "will", "go", "to", "Yandex", "and", "access", "basic", "information", "about", "the", "user", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/yandex/yandex.go#L74-L118
train
markbates/goth
providers/steam/session.go
Authorize
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) if params.Get("openid.mode") != "id_res" { return "", errors.New("Mode must equal to \"id_res\".") } if params.Get("openid.return_to") != s.CallbackURL { return "", errors.New("The \"return_to ur...
go
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) if params.Get("openid.mode") != "id_res" { return "", errors.New("Mode must equal to \"id_res\".") } if params.Get("openid.return_to") != s.CallbackURL { return "", errors.New("The \"return_to ur...
[ "func", "(", "s", "*", "Session", ")", "Authorize", "(", "provider", "goth", ".", "Provider", ",", "params", "goth", ".", "Params", ")", "(", "string", ",", "error", ")", "{", "p", ":=", "provider", ".", "(", "*", "Provider", ")", "\n", "if", "para...
// Authorize the session with Steam and return the unique response_nonce by OpenID.
[ "Authorize", "the", "session", "with", "Steam", "and", "return", "the", "unique", "response_nonce", "by", "OpenID", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/steam/session.go#L32-L83
train
markbates/goth
providers/faux/faux.go
BeginAuth
func (p *Provider) BeginAuth(state string) (goth.Session, error) { c := &oauth2.Config{ Endpoint: oauth2.Endpoint{ AuthURL: "http://example.com/auth", }, } url := c.AuthCodeURL(state) return &Session{ ID: "id", AuthURL: url, }, nil }
go
func (p *Provider) BeginAuth(state string) (goth.Session, error) { c := &oauth2.Config{ Endpoint: oauth2.Endpoint{ AuthURL: "http://example.com/auth", }, } url := c.AuthCodeURL(state) return &Session{ ID: "id", AuthURL: url, }, nil }
[ "func", "(", "p", "*", "Provider", ")", "BeginAuth", "(", "state", "string", ")", "(", "goth", ".", "Session", ",", "error", ")", "{", "c", ":=", "&", "oauth2", ".", "Config", "{", "Endpoint", ":", "oauth2", ".", "Endpoint", "{", "AuthURL", ":", "\...
// BeginAuth is used only for testing.
[ "BeginAuth", "is", "used", "only", "for", "testing", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/faux/faux.go#L41-L52
train
markbates/goth
providers/faux/faux.go
FetchUser
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ UserID: sess.ID, Name: sess.Name, Email: sess.Email, Provider: p.Name(), AccessToken: sess.AccessToken, } if user.AccessToken == "" { return user, fmt.Errorf("%s ca...
go
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ UserID: sess.ID, Name: sess.Name, Email: sess.Email, Provider: p.Name(), AccessToken: sess.AccessToken, } if user.AccessToken == "" { return user, fmt.Errorf("%s ca...
[ "func", "(", "p", "*", "Provider", ")", "FetchUser", "(", "session", "goth", ".", "Session", ")", "(", "goth", ".", "User", ",", "error", ")", "{", "sess", ":=", "session", ".", "(", "*", "Session", ")", "\n", "user", ":=", "goth", ".", "User", "...
// FetchUser is used only for testing.
[ "FetchUser", "is", "used", "only", "for", "testing", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/faux/faux.go#L55-L69
train
markbates/goth
providers/faux/faux.go
Authorize
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { s.AccessToken = "access" return s.AccessToken, nil }
go
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { s.AccessToken = "access" return s.AccessToken, nil }
[ "func", "(", "s", "*", "Session", ")", "Authorize", "(", "provider", "goth", ".", "Provider", ",", "params", "goth", ".", "Params", ")", "(", "string", ",", "error", ")", "{", "s", ".", "AccessToken", "=", "\"", "\"", "\n", "return", "s", ".", "Acc...
// Authorize is used only for testing.
[ "Authorize", "is", "used", "only", "for", "testing", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/faux/faux.go#L96-L99
train
markbates/goth
providers/xero/xero.go
New
func New(clientKey, secret, callbackURL string) *Provider { p := &Provider{ ClientKey: clientKey, Secret: secret, CallbackURL: callbackURL, //Method determines how you will connect to Xero. //Options are public, private, and partner //Use public if this is your first time. //More details here: htt...
go
func New(clientKey, secret, callbackURL string) *Provider { p := &Provider{ ClientKey: clientKey, Secret: secret, CallbackURL: callbackURL, //Method determines how you will connect to Xero. //Options are public, private, and partner //Use public if this is your first time. //More details here: htt...
[ "func", "New", "(", "clientKey", ",", "secret", ",", "callbackURL", "string", ")", "*", "Provider", "{", "p", ":=", "&", "Provider", "{", "ClientKey", ":", "clientKey", ",", "Secret", ":", "secret", ",", "CallbackURL", ":", "callbackURL", ",", "//Method de...
// New creates a new Xero provider, and sets up important connection details. // You should always call `xero.New` to get a new Provider. Never try to create // one manually.
[ "New", "creates", "a", "new", "Xero", "provider", "and", "sets", "up", "important", "connection", "details", ".", "You", "should", "always", "call", "xero", ".", "New", "to", "get", "a", "new", "Provider", ".", "Never", "try", "to", "create", "one", "man...
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/xero/xero.go#L58-L82
train
markbates/goth
providers/xero/xero.go
BeginAuth
func (p *Provider) BeginAuth(state string) (goth.Session, error) { requestToken, url, err := p.consumer.GetRequestTokenAndUrl(p.CallbackURL) if err != nil { return nil, err } session := &Session{ AuthURL: url, RequestToken: requestToken, } return session, err }
go
func (p *Provider) BeginAuth(state string) (goth.Session, error) { requestToken, url, err := p.consumer.GetRequestTokenAndUrl(p.CallbackURL) if err != nil { return nil, err } session := &Session{ AuthURL: url, RequestToken: requestToken, } return session, err }
[ "func", "(", "p", "*", "Provider", ")", "BeginAuth", "(", "state", "string", ")", "(", "goth", ".", "Session", ",", "error", ")", "{", "requestToken", ",", "url", ",", "err", ":=", "p", ".", "consumer", ".", "GetRequestTokenAndUrl", "(", "p", ".", "C...
// BeginAuth asks Xero for an authentication end-point and a request token for a session. // Xero does not support the "state" variable.
[ "BeginAuth", "asks", "Xero", "for", "an", "authentication", "end", "-", "point", "and", "a", "request", "token", "for", "a", "session", ".", "Xero", "does", "not", "support", "the", "state", "variable", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/xero/xero.go#L118-L128
train
markbates/goth
providers/xero/xero.go
FetchUser
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ Provider: p.Name(), } if sess.AccessToken == nil { // data is not yet retrieved since accessToken is still empty return user, fmt.Errorf("%s cannot get user information without accessToken", ...
go
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ Provider: p.Name(), } if sess.AccessToken == nil { // data is not yet retrieved since accessToken is still empty return user, fmt.Errorf("%s cannot get user information without accessToken", ...
[ "func", "(", "p", "*", "Provider", ")", "FetchUser", "(", "session", "goth", ".", "Session", ")", "(", "goth", ".", "User", ",", "error", ")", "{", "sess", ":=", "session", ".", "(", "*", "Session", ")", "\n", "user", ":=", "goth", ".", "User", "...
// FetchUser will go to Xero and access basic information about the user.
[ "FetchUser", "will", "go", "to", "Xero", "and", "access", "basic", "information", "about", "the", "user", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/xero/xero.go#L131-L180
train
markbates/goth
providers/xero/xero.go
RefreshOAuth1Token
func (p *Provider) RefreshOAuth1Token(session *Session) error { newAccessToken, err := p.consumer.RefreshToken(session.AccessToken) if err != nil { return err } session.AccessToken = newAccessToken session.AccessTokenExpires = time.Now().UTC().Add(30 * time.Minute) return nil }
go
func (p *Provider) RefreshOAuth1Token(session *Session) error { newAccessToken, err := p.consumer.RefreshToken(session.AccessToken) if err != nil { return err } session.AccessToken = newAccessToken session.AccessTokenExpires = time.Now().UTC().Add(30 * time.Minute) return nil }
[ "func", "(", "p", "*", "Provider", ")", "RefreshOAuth1Token", "(", "session", "*", "Session", ")", "error", "{", "newAccessToken", ",", "err", ":=", "p", ".", "consumer", ".", "RefreshToken", "(", "session", ".", "AccessToken", ")", "\n", "if", "err", "!...
//RefreshOAuth1Token should be used instead of RefeshToken which is not compliant with the Oauth1.0a standard
[ "RefreshOAuth1Token", "should", "be", "used", "instead", "of", "RefeshToken", "which", "is", "not", "compliant", "with", "the", "Oauth1", ".", "0a", "standard" ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/xero/xero.go#L240-L248
train
markbates/goth
providers/azureadv2/azureadv2.go
BeginAuth
func (p *Provider) BeginAuth(state string) (goth.Session, error) { authURL := p.config.AuthCodeURL(state) return &Session{ AuthURL: authURL, }, nil }
go
func (p *Provider) BeginAuth(state string) (goth.Session, error) { authURL := p.config.AuthCodeURL(state) return &Session{ AuthURL: authURL, }, nil }
[ "func", "(", "p", "*", "Provider", ")", "BeginAuth", "(", "state", "string", ")", "(", "goth", ".", "Session", ",", "error", ")", "{", "authURL", ":=", "p", ".", "config", ".", "AuthCodeURL", "(", "state", ")", "\n\n", "return", "&", "Session", "{", ...
// BeginAuth asks for an authentication end-point for AzureAD.
[ "BeginAuth", "asks", "for", "an", "authentication", "end", "-", "point", "for", "AzureAD", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/azureadv2/azureadv2.go#L122-L128
train
markbates/goth
gothic/gothic.go
GetFromSession
func GetFromSession(key string, req *http.Request) (string, error) { session, _ := Store.Get(req, SessionName) value, err := getSessionValue(session, key) if err != nil { return "", errors.New("could not find a matching session for this request") } return value, nil }
go
func GetFromSession(key string, req *http.Request) (string, error) { session, _ := Store.Get(req, SessionName) value, err := getSessionValue(session, key) if err != nil { return "", errors.New("could not find a matching session for this request") } return value, nil }
[ "func", "GetFromSession", "(", "key", "string", ",", "req", "*", "http", ".", "Request", ")", "(", "string", ",", "error", ")", "{", "session", ",", "_", ":=", "Store", ".", "Get", "(", "req", ",", "SessionName", ")", "\n", "value", ",", "err", ":=...
// GetFromSession retrieves a previously-stored value from the session. // If no value has previously been stored at the specified key, it will return an error.
[ "GetFromSession", "retrieves", "a", "previously", "-", "stored", "value", "from", "the", "session", ".", "If", "no", "value", "has", "previously", "been", "stored", "at", "the", "specified", "key", "it", "will", "return", "an", "error", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/gothic/gothic.go#L298-L306
train
markbates/goth
providers/steam/steam.go
New
func New(apiKey string, callbackURL string) *Provider { p := &Provider{ APIKey: apiKey, CallbackURL: callbackURL, providerName: "steam", } return p }
go
func New(apiKey string, callbackURL string) *Provider { p := &Provider{ APIKey: apiKey, CallbackURL: callbackURL, providerName: "steam", } return p }
[ "func", "New", "(", "apiKey", "string", ",", "callbackURL", "string", ")", "*", "Provider", "{", "p", ":=", "&", "Provider", "{", "APIKey", ":", "apiKey", ",", "CallbackURL", ":", "callbackURL", ",", "providerName", ":", "\"", "\"", ",", "}", "\n", "re...
// New creates a new Steam provider, and sets up important connection details. // You should always call `steam.New` to get a new Provider. Never try to create // one manually.
[ "New", "creates", "a", "new", "Steam", "provider", "and", "sets", "up", "important", "connection", "details", ".", "You", "should", "always", "call", "steam", ".", "New", "to", "get", "a", "new", "Provider", ".", "Never", "try", "to", "create", "one", "m...
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/steam/steam.go#L29-L36
train
markbates/goth
providers/steam/steam.go
BeginAuth
func (p *Provider) BeginAuth(state string) (goth.Session, error) { u, err := p.getAuthURL() s := &Session{ AuthURL: u.String(), CallbackURL: p.CallbackURL, } return s, err }
go
func (p *Provider) BeginAuth(state string) (goth.Session, error) { u, err := p.getAuthURL() s := &Session{ AuthURL: u.String(), CallbackURL: p.CallbackURL, } return s, err }
[ "func", "(", "p", "*", "Provider", ")", "BeginAuth", "(", "state", "string", ")", "(", "goth", ".", "Session", ",", "error", ")", "{", "u", ",", "err", ":=", "p", ".", "getAuthURL", "(", ")", "\n", "s", ":=", "&", "Session", "{", "AuthURL", ":", ...
// BeginAuth will return the authentication end-point for Steam.
[ "BeginAuth", "will", "return", "the", "authentication", "end", "-", "point", "for", "Steam", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/steam/steam.go#L64-L71
train
markbates/goth
providers/steam/steam.go
getAuthURL
func (p *Provider) getAuthURL() (*url.URL, error) { callbackURL, err := url.Parse(p.CallbackURL) if err != nil { return nil, err } urlValues := map[string]string{ "openid.claimed_id": openIDIdentifier, "openid.identity": openIDIdentifier, "openid.mode": openIDMode, "openid.ns": openIDNs, ...
go
func (p *Provider) getAuthURL() (*url.URL, error) { callbackURL, err := url.Parse(p.CallbackURL) if err != nil { return nil, err } urlValues := map[string]string{ "openid.claimed_id": openIDIdentifier, "openid.identity": openIDIdentifier, "openid.mode": openIDMode, "openid.ns": openIDNs, ...
[ "func", "(", "p", "*", "Provider", ")", "getAuthURL", "(", ")", "(", "*", "url", ".", "URL", ",", "error", ")", "{", "callbackURL", ",", "err", ":=", "url", ".", "Parse", "(", "p", ".", "CallbackURL", ")", "\n", "if", "err", "!=", "nil", "{", "...
// getAuthURL is an internal function to build the correct // authentication url to redirect the user to Steam.
[ "getAuthURL", "is", "an", "internal", "function", "to", "build", "the", "correct", "authentication", "url", "to", "redirect", "the", "user", "to", "Steam", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/steam/steam.go#L75-L102
train
markbates/goth
providers/steam/steam.go
FetchUser
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { s := session.(*Session) u := goth.User{ Provider: p.Name(), AccessToken: s.ResponseNonce, } if s.SteamID == "" { // data is not yet retrieved since SteamID is still empty return u, fmt.Errorf("%s cannot get user information without ...
go
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { s := session.(*Session) u := goth.User{ Provider: p.Name(), AccessToken: s.ResponseNonce, } if s.SteamID == "" { // data is not yet retrieved since SteamID is still empty return u, fmt.Errorf("%s cannot get user information without ...
[ "func", "(", "p", "*", "Provider", ")", "FetchUser", "(", "session", "goth", ".", "Session", ")", "(", "goth", ".", "User", ",", "error", ")", "{", "s", ":=", "session", ".", "(", "*", "Session", ")", "\n", "u", ":=", "goth", ".", "User", "{", ...
// FetchUser will go to Steam and access basic info about the user.
[ "FetchUser", "will", "go", "to", "Steam", "and", "access", "basic", "info", "about", "the", "user", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/steam/steam.go#L105-L139
train
markbates/goth
providers/steam/steam.go
buildUserObject
func buildUserObject(r io.Reader, u goth.User) (goth.User, error) { // Response object from Steam apiResponse := struct { Response struct { Players []struct { UserID string `json:"steamid"` NickName string `json:"personaname"` Name string `json:"realname"` A...
go
func buildUserObject(r io.Reader, u goth.User) (goth.User, error) { // Response object from Steam apiResponse := struct { Response struct { Players []struct { UserID string `json:"steamid"` NickName string `json:"personaname"` Name string `json:"realname"` A...
[ "func", "buildUserObject", "(", "r", "io", ".", "Reader", ",", "u", "goth", ".", "User", ")", "(", "goth", ".", "User", ",", "error", ")", "{", "// Response object from Steam", "apiResponse", ":=", "struct", "{", "Response", "struct", "{", "Players", "[", ...
// buildUserObject is an internal function to build a goth.User object // based in the data stored in r
[ "buildUserObject", "is", "an", "internal", "function", "to", "build", "a", "goth", ".", "User", "object", "based", "in", "the", "data", "stored", "in", "r" ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/steam/steam.go#L143-L189
train
markbates/goth
providers/yammer/session.go
Authorize
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) v := url.Values{ "grant_type": {"authorization_code"}, "code": CondVal(params.Get("code")), "redirect_uri": CondVal(p.config.RedirectURL), "scope": CondVal(strings.Join(p.config...
go
func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string, error) { p := provider.(*Provider) v := url.Values{ "grant_type": {"authorization_code"}, "code": CondVal(params.Get("code")), "redirect_uri": CondVal(p.config.RedirectURL), "scope": CondVal(strings.Join(p.config...
[ "func", "(", "s", "*", "Session", ")", "Authorize", "(", "provider", "goth", ".", "Provider", ",", "params", "goth", ".", "Params", ")", "(", "string", ",", "error", ")", "{", "p", ":=", "provider", ".", "(", "*", "Provider", ")", "\n", "v", ":=", ...
// Authorize the session with Yammer and return the access token to be stored for future use.
[ "Authorize", "the", "session", "with", "Yammer", "and", "return", "the", "access", "token", "to", "be", "stored", "for", "future", "use", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/yammer/session.go#L33-L51
train
markbates/goth
providers/yammer/session.go
retrieveAuthData
func retrieveAuthData(p *Provider, TokenURL string, v url.Values) (map[string]map[string]interface{}, error) { v.Set("client_id", p.ClientKey) v.Set("client_secret", p.Secret) req, err := http.NewRequest("POST", TokenURL, strings.NewReader(v.Encode())) if err != nil { return nil, err } req.Header.Set("Content-T...
go
func retrieveAuthData(p *Provider, TokenURL string, v url.Values) (map[string]map[string]interface{}, error) { v.Set("client_id", p.ClientKey) v.Set("client_secret", p.Secret) req, err := http.NewRequest("POST", TokenURL, strings.NewReader(v.Encode())) if err != nil { return nil, err } req.Header.Set("Content-T...
[ "func", "retrieveAuthData", "(", "p", "*", "Provider", ",", "TokenURL", "string", ",", "v", "url", ".", "Values", ")", "(", "map", "[", "string", "]", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "v", ".", "Set", "(", ...
//Custom implementation for yammer to get access token and user data //Yammer provides user data along with access token, no separate api available
[ "Custom", "implementation", "for", "yammer", "to", "get", "access", "token", "and", "user", "data", "Yammer", "provides", "user", "data", "along", "with", "access", "token", "no", "separate", "api", "available" ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/yammer/session.go#L65-L95
train
markbates/goth
providers/google/google.go
BeginAuth
func (p *Provider) BeginAuth(state string) (goth.Session, error) { var opts []oauth2.AuthCodeOption if p.prompt != nil { opts = append(opts, p.prompt) } url := p.config.AuthCodeURL(state, opts...) session := &Session{ AuthURL: url, } return session, nil }
go
func (p *Provider) BeginAuth(state string) (goth.Session, error) { var opts []oauth2.AuthCodeOption if p.prompt != nil { opts = append(opts, p.prompt) } url := p.config.AuthCodeURL(state, opts...) session := &Session{ AuthURL: url, } return session, nil }
[ "func", "(", "p", "*", "Provider", ")", "BeginAuth", "(", "state", "string", ")", "(", "goth", ".", "Session", ",", "error", ")", "{", "var", "opts", "[", "]", "oauth2", ".", "AuthCodeOption", "\n", "if", "p", ".", "prompt", "!=", "nil", "{", "opts...
// BeginAuth asks Google for an authentication endpoint.
[ "BeginAuth", "asks", "Google", "for", "an", "authentication", "endpoint", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/google/google.go#L63-L73
train
markbates/goth
providers/google/google.go
FetchUser
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ AccessToken: sess.AccessToken, Provider: p.Name(), RefreshToken: sess.RefreshToken, ExpiresAt: sess.ExpiresAt, } if user.AccessToken == "" { // Data is not yet retrieved, since ac...
go
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) user := goth.User{ AccessToken: sess.AccessToken, Provider: p.Name(), RefreshToken: sess.RefreshToken, ExpiresAt: sess.ExpiresAt, } if user.AccessToken == "" { // Data is not yet retrieved, since ac...
[ "func", "(", "p", "*", "Provider", ")", "FetchUser", "(", "session", "goth", ".", "Session", ")", "(", "goth", ".", "User", ",", "error", ")", "{", "sess", ":=", "session", ".", "(", "*", "Session", ")", "\n", "user", ":=", "goth", ".", "User", "...
// FetchUser will go to Google and access basic information about the user.
[ "FetchUser", "will", "go", "to", "Google", "and", "access", "basic", "information", "about", "the", "user", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/google/google.go#L86-L134
train
markbates/goth
providers/mailru/mailru.go
New
func New(clientID, clientSecret, redirectURL string, scopes ...string) *Provider { var c = &oauth2.Config{ ClientID: clientID, ClientSecret: clientSecret, RedirectURL: redirectURL, Endpoint: oauth2.Endpoint{ AuthURL: authURL, TokenURL: tokenURL, }, Scopes: []string{}, } for _, scope := range...
go
func New(clientID, clientSecret, redirectURL string, scopes ...string) *Provider { var c = &oauth2.Config{ ClientID: clientID, ClientSecret: clientSecret, RedirectURL: redirectURL, Endpoint: oauth2.Endpoint{ AuthURL: authURL, TokenURL: tokenURL, }, Scopes: []string{}, } for _, scope := range...
[ "func", "New", "(", "clientID", ",", "clientSecret", ",", "redirectURL", "string", ",", "scopes", "...", "string", ")", "*", "Provider", "{", "var", "c", "=", "&", "oauth2", ".", "Config", "{", "ClientID", ":", "clientID", ",", "ClientSecret", ":", "clie...
// New creates a new MAILRU provider and sets up important connection details. // You should always call `mailru.New` to get a new provider. Never try to // create one manually.
[ "New", "creates", "a", "new", "MAILRU", "provider", "and", "sets", "up", "important", "connection", "details", ".", "You", "should", "always", "call", "mailru", ".", "New", "to", "get", "a", "new", "provider", ".", "Never", "try", "to", "create", "one", ...
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/mailru/mailru.go#L26-L46
train
markbates/goth
providers/mailru/mailru.go
FetchUser
func (p *Provider) FetchUser(session goth.Session) (_ goth.User, err error) { var ( sess = session.(*Session) user = goth.User{ AccessToken: sess.AccessToken, RefreshToken: sess.RefreshToken, Provider: p.Name(), ExpiresAt: sess.ExpiresAt, } ) if user.AccessToken == "" { return user, fmt....
go
func (p *Provider) FetchUser(session goth.Session) (_ goth.User, err error) { var ( sess = session.(*Session) user = goth.User{ AccessToken: sess.AccessToken, RefreshToken: sess.RefreshToken, Provider: p.Name(), ExpiresAt: sess.ExpiresAt, } ) if user.AccessToken == "" { return user, fmt....
[ "func", "(", "p", "*", "Provider", ")", "FetchUser", "(", "session", "goth", ".", "Session", ")", "(", "_", "goth", ".", "User", ",", "err", "error", ")", "{", "var", "(", "sess", "=", "session", ".", "(", "*", "Session", ")", "\n", "user", "=", ...
// FetchUser will go to MAILRU and access basic information about the user.
[ "FetchUser", "will", "go", "to", "MAILRU", "and", "access", "basic", "information", "about", "the", "user", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/mailru/mailru.go#L79-L149
train
markbates/goth
providers/mailru/mailru.go
RefreshToken
func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) { t := &oauth2.Token{RefreshToken: refreshToken} ts := p.oauthConfig.TokenSource(goth.ContextForClient(p.Client()), t) return ts.Token() }
go
func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) { t := &oauth2.Token{RefreshToken: refreshToken} ts := p.oauthConfig.TokenSource(goth.ContextForClient(p.Client()), t) return ts.Token() }
[ "func", "(", "p", "*", "Provider", ")", "RefreshToken", "(", "refreshToken", "string", ")", "(", "*", "oauth2", ".", "Token", ",", "error", ")", "{", "t", ":=", "&", "oauth2", ".", "Token", "{", "RefreshToken", ":", "refreshToken", "}", "\n", "ts", "...
// RefreshToken refresh token is not provided by mailru.
[ "RefreshToken", "refresh", "token", "is", "not", "provided", "by", "mailru", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/mailru/mailru.go#L155-L160
train
markbates/goth
providers/openidConnect/openidConnect.go
FetchUser
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) expiresAt := sess.ExpiresAt if sess.IDToken == "" { return goth.User{}, fmt.Errorf("%s cannot get user information without id_token", p.providerName) } // decode returned id token to get expiry claims, err := d...
go
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { sess := session.(*Session) expiresAt := sess.ExpiresAt if sess.IDToken == "" { return goth.User{}, fmt.Errorf("%s cannot get user information without id_token", p.providerName) } // decode returned id token to get expiry claims, err := d...
[ "func", "(", "p", "*", "Provider", ")", "FetchUser", "(", "session", "goth", ".", "Session", ")", "(", "goth", ".", "User", ",", "error", ")", "{", "sess", ":=", "session", ".", "(", "*", "Session", ")", "\n\n", "expiresAt", ":=", "sess", ".", "Exp...
// FetchUser will use the the id_token and access requested information about the user.
[ "FetchUser", "will", "use", "the", "the", "id_token", "and", "access", "requested", "information", "about", "the", "user", "." ]
9db62076e0965a39b5a282e506e0aec27d2b1625
https://github.com/markbates/goth/blob/9db62076e0965a39b5a282e506e0aec27d2b1625/providers/openidConnect/openidConnect.go#L141-L180
train