Commit graph

346 commits

Author SHA1 Message Date
jonas747
3fdc5f373d Add "PermissionAdministrator" to "PermissionAll" (#302) 2016-12-24 11:36:14 -08:00
Bruce Marriner
9e777a083b Linting. 2016-12-11 12:45:34 -06:00
Bruce Marriner
68a784327f Merge branch 'develop' of https://github.com/bwmarrin/discordgo into develop 2016-12-11 12:24:29 -06:00
Bruce Marriner
c541df15df Removed dead code. 2016-12-11 12:24:17 -06:00
Chris Rhodes
db2f9eb29b Support getting the color of a user. (#299) 2016-12-10 21:37:11 -08:00
Chris Rhodes
36601253a4 Remove use of reflect.
This introduces gogenerate'ed EventHandlers from the files in events.go

This also adds support for AddHandlerOnce.
2016-12-03 23:31:07 -08:00
AI
2092185ec5 Implement support for new member role endpoint (#289)
Implements support for the new member role add and delete endpoint
hammerandchisel/discord-api-docs#179
2016-11-30 08:57:22 -08:00
Chris Rhodes
b7c7e60fd5 Fix presence unmarshalling as the values are inconsistent from Discord. (#287) 2016-11-12 11:59:51 -08:00
jonas747
5d1dd7ddac Add nick and roles to Presence 2016-11-07 15:53:54 -08:00
jonas747
f0cb678022 Add member_count to guild 2016-11-06 09:09:54 -08:00
jonas747
56b19073d3 Ratelimits (#273)
* Added ratelimiter

Handles the new ratelimit headers
 - X-RateLimit-Remaining
 - X-RateLimit-Reset
 - X-RateLimit-Global

* Pad only reset time with a second

* Moved ratelimiter out of internal package

* Change for loop, move global ratelimit check inside sleep check

* Moved ratelimiter locking to getBucket

* Added global bucket

* Changed how bucket id's are done

Now each request function will need to specify the bucket id if the
endpoint contains minor variables

* Allow empty bucketID in request

* Remove some uneeded Endpoint* function calls

* Added test for global ratelimits

* Fixed a silly little mistake causing incorrect ratelimits

* Update test comments, Fixed treating a endpoint as 2 in ratelimiting

* Use date header from discord instead of relying on sys time sync

* Update all REST functions to use RequestWithBucketID

* Embed mutex into bucket

* Added webhook and reaction buckets
2016-11-04 08:07:22 -07:00
Chris Rhodes
5ef835fc80 Fix GuildBans. Fixes #263 2016-11-03 22:39:55 -07:00
Chris Rhodes
c96162c425 Add support for Message Reactions. 2016-11-03 22:07:06 -07:00
Chris Rhodes
84a92549bc Merge pull request #274 from iopred/develop
Add Webhook support.
2016-11-03 19:47:15 -07:00
Chris Rhodes
ee3e500749 Add webhook support. 2016-11-03 19:41:57 -07:00
jonas747
9187964002 Added custom rest error type (#271) 2016-10-13 19:13:42 -07:00
jonas747
9f24531220 Update ChannelMessageAck because of api changes (#270) 2016-10-13 12:42:05 -07:00
robbix1206
af3fe4842a Add Support of changing user status (#258)
Add Support of changing user status
2016-09-28 10:04:37 -07:00
Chris Rhodes
581f6e7867 Merge pull request #256 from jonas747/request-members
Added RequestGuildMembers to request guild members from the gateway
2016-09-27 22:08:36 -07:00
Chris Rhodes
ef83d2098f Merge pull request #236 from jonas747/split
Added UserGuild struct, UserGuilds now returns a UserGuild slice
2016-09-27 22:04:37 -07:00
Chris Rhodes
42e934d3b2 Merge pull request #246 from robbix1206/timestamps
Timestamps
2016-09-27 21:22:07 -07:00
Chris Rhodes
8bd3f75441 Merge pull request #227 from jonas747/retry
Retry on 502's
2016-09-27 21:19:25 -07:00
Chris Rhodes
9b6b657083 Merge pull request #249 from iopred/develop
Correctly merge GUILD_UPDATE events. Closes #242
2016-09-27 21:15:03 -07:00
jonas747
9c7c9d3fd2 Added RequestGuildMembers to request guild members from the gateway 2016-09-25 21:29:59 +02:00
soft as HELL
ef3cd76e3d Add mentionable to Role struct 2016-09-11 14:32:41 +03:00
Chris Rhodes
678756c9a9 Simplify Guild.Unavailable and correctly merge GUILD_UPDATE events. 2016-09-08 19:39:29 -07:00
jonas747
2a1f0ff893 Added the CHANNEL_PINS_UPDATE event 2016-07-29 23:40:56 +02:00
jonas747
3fd53413de Added userguild struct, and UserGuilds() now returns a userguild 2016-07-29 23:13:55 +02:00
uppfinnarn
0c11cae782 Timestamp type; a string with a Parse() function
Closes #204
2016-07-28 21:16:10 +02:00
jonas747
092ed4b585 Retry on 502's 2016-07-11 22:30:11 +02:00
Bruce Marriner
af57bc1789 comment Deprecation for VoiceReady and UDPReady 2016-06-24 13:10:56 -05:00
Bruce Marriner
eeb2d4f62d Add mfa_enabled to User struct 2016-06-24 11:55:52 -05:00
Bruce
79d49f86fb Merge pull request #216 from jonas747/userguildsettings
Added UserGuildSettingsEdit
2016-06-15 08:30:01 -05:00
jonas747
f2f2d6430b Added UserGuildSettingsEdit 2016-06-15 12:07:57 +02:00
Bruce Marriner
9dc51d1c49 Only Shard when ShardCount > 1
Also cleaned up identify sending so there's now a function that handles
it instead of duplicate code.  Renamed handshake* structs to identify*
structs to make naming match up.
2016-06-14 13:45:38 -05:00
Bruce Marriner
d03b3eedfa Merge branch 'feature/sharding' of https://github.com/b1naryth1ef/discordgo into b1naryth1ef-feature/sharding 2016-06-14 11:45:59 -05:00
Bruce Marriner
cec33d9477 Arange struct to reduce memory usage. 2016-06-14 09:05:19 -05:00
andrei
835a23a89d Implement guild sharding 2016-06-13 15:34:40 -07:00
Chris Rhodes
323abd1a87 Use embedded Presence in presenceUpdate 2016-06-05 22:41:08 -07:00
jonas747
caadaaaf2c Added guild_positions field to settings 2016-05-18 02:40:41 +02:00
Chris Rhodes
80c2158605 Support streaming status updates. 2016-05-06 15:23:21 -07:00
Bruce Marriner
a9da8a5daf Cleanup, Logging, Finished Resumed code. 2016-04-30 21:40:13 -05:00
Bruce
dd0b83333c Merge pull request #189 from jonas747/develop
Nickname support
2016-04-30 19:12:18 -05:00
Bruce Marriner
e9e9ef86b3 Prevent concurrent writes to gateway websocket. 2016-04-30 19:11:13 -05:00
jonas747
0b313b016f Add nick field to guild member struct 2016-04-30 23:43:52 +02:00
Bruce Marriner
f6de2b2c98 gateway, voice, & logging improvements
We now store teh sessionID of the gateway connection for later use. We
are now caching the gateway url and will use it until unable to connect
to that gateway.  We're not longer smashing the VoiceConnections map
during reconnects which was causing Voice problems. Slight change to
log output format.
2016-04-28 21:15:32 -05:00
Bruce Marriner
098d7861a4 BREAKING - Added RateLimited event
Renamed RateLimit struct to TooManyRequests{} and added new event struct
RateLimited{} which can be registerd to with AddHandler() and will be
emitted anytime a HTTP 429 is received on the HTTP API.
2016-04-28 17:41:05 -05:00
Bruce Marriner
94770635a9 Event handing improvements.
Corrected the Event struct to match it's new state based on Discord docs
and started tracking sequence number and sending it with heatbeats.
Also, move cleanup and comment improvements.
2016-04-28 16:59:45 -05:00
Bruce Marriner
a24f9e3d10 Slight better rate limit handling
This improves greatly on the previous rate limit handling
however still needs review and possible improvement.
Please report bugs!
2016-04-28 13:38:20 -05:00
Bruce Marriner
fc7ce3db94 Initial add of new logging system
This adds a LogLevel setting for both Websocket and VoiceConnections
that can be configured to set the specific log level desired. This
also adds a new logging function that adds additional helpful
information when printing out log messages.
2016-04-26 21:17:51 -05:00
jonas747
ef3264d3a2 Added default_message_notifications to guild struct 2016-04-25 20:52:58 +02:00
Bruce
cb6b3b956e Revert "Add sharding support" 2016-04-25 13:24:00 -05:00
Bruce
d5503b3621 Merge pull request #176 from jonas747/settings
Added new fields to Settings struct
2016-04-24 20:53:39 -05:00
jonas747
82ac29f0bc Updated settings struct 2016-04-25 03:30:12 +02:00
Bruce
ceac4e3e25 Merge pull request #174 from jonas747/dunno
Added new fields to READY struct.
2016-04-24 18:24:20 -05:00
jonas747
339ad583da Changed Id to ID per iopreds request 2016-04-25 00:59:03 +02:00
jonas747
88c37e75a1 Figured out relationship type 2016-04-25 00:56:51 +02:00
jonas747
4906a4cf9c Added some undocumented fields to ready event 2016-04-24 23:35:37 +02:00
Bruce
b14a2ce8da Merge pull request #171 from iopred/develop
Fix unmarshall error with Invite, improve error logging.
2016-04-23 22:35:51 -05:00
Chris Rhodes
8be21fb539 Fix unmarshall error with Invite, improve error logging. 2016-04-23 11:03:07 -07:00
Bruce Marriner
bda7434f18 Moved State struct to state.go 2016-04-22 16:53:57 -05:00
Bruce
7bd2bb19d8 Merge pull request #166 from b1naryth1ef/feature/sharding
Add sharding support
2016-04-22 15:42:23 -05:00
Chris Rhodes
24e7f04e0e Add support for GuildEmbed and GuildIntegration endpoints. 2016-04-22 11:34:04 -07:00
andrei
92caf31b7f Implement Guild Sharding
This implements the upcoming change (see hammerandchisel/discord-api-docs#17)
to add guild-sharding support directly in the Discord Gateways.
2016-04-19 18:09:38 -07:00
Chris Rhodes
87b2daa832 Merge remote-tracking branch 'bwmarrin/develop' into develop 2016-04-11 22:17:26 -07:00
Bruce Marriner
1a672823a2 Lint and Cleanup 2016-04-11 18:54:19 -05:00
Bruce Marriner
836e78d3d9 Pass struct along with OnEvent event. 2016-04-11 16:56:43 -05:00
Chris Rhodes
fa63c00fa2 Add fast lookups for guilds and channels in state. 2016-04-10 16:18:29 -07:00
Bruce Marriner
92c27c7712 Because binzy was too lazy.
No seriously, this allows us see if a guild is actually being created
or just being lazy-loaded.
2016-04-08 11:51:58 -05:00
andrei
019d0fe9af Fix lazy-loading of guilds not working
We're moving to lazy-loading guilds, meaning bots now recieve a READY
packet with guilds that only have 'id' and 'unavailable' fields. Post
READY, the client then lazyily recieves GUILD_CREATE's for the rest of
the guilds it's in. Previously we assumed the first instance of the
guild we got (from ready) had all the required information, now we need
to use the GUILD_CREATE if the guild was marked as unavailable.
2016-04-04 13:45:41 -07:00
Chris Rhodes
6e568533b2 Early support for PresencesReplace 2016-03-19 16:22:36 -07:00
Bruce Marriner
88492a1dcf Add Token to user struct, and some gofmt. 2016-03-11 23:18:36 -06:00
Chris Rhodes
60b801db27 Support the new bot field on User. 2016-03-10 22:02:59 -08:00
andrei
5dc0b9f2a1 Add connect timeout, fix ChannelVoiceJoin "leaking" connections 2016-03-08 02:36:00 -08:00
andrei
b48e8c992e Track voice state changes, expose stuff, add channel changing 2016-03-07 15:41:02 -08:00
andrei
1fc0e2053b Add support for multiple voice connections
With the upcoming API changes, Discord will be allowing bot users to be
onnected to more than one voice channel at a time. This commit is a
first stab at implementing that functionality in discordgo.

Voice works pretty good right now, ideally the next step is to cleanup
some of the channel-spam and weird blocking-spots.
2016-03-05 01:05:18 -08:00
abalabahaha
0969cc3d86 Format the permission constants 2016-03-04 06:12:17 -08:00
abalabahaha
539b9d203f Fix UserChannelPermissions 2016-03-04 05:50:11 -08:00
abalabahaha
cd24674ebb Added UserChannelPermissions function 2016-03-04 08:07:57 +00:00
Nicholas Stafie
cba9b5039e
Refactor VerificationLevel consts 2016-02-27 01:22:02 +02:00
Nicholas Stafie
58fe658fa5 Add VerificationLevel value consts and a typedef for int 2016-02-27 00:28:05 +02:00
Nicholas Stafie
1a844d697d Add support for guild region and verification level 2016-02-25 00:27:13 +02:00
Chris Rhodes
a11e81fc96 Bring back discrim too. 2016-02-22 08:27:17 -08:00
Chris Rhodes
75a5d6bf62 Bring back color 2016-02-22 08:20:36 -08:00
Chris Rhodes
abc0e5b095 Work around a Discord server issue. 2016-02-22 00:11:39 -08:00
Chris Rhodes
f58410afa4 Support user guild settings update event. 2016-02-21 19:35:21 -08:00
Bruce Marriner
a24247b6e8 Added Bitrate to Channel struct, closes #116 2016-02-20 14:51:02 -06:00
Chris Rhodes
79247272ff Handler updates, no backwards incompatible API changes.
AddHandler now returns a func that can remove the handler.
The handlers map is now guarded by its own mutex.
Moved eventMap to events.go for readability.
Improved documentation.
2016-02-19 22:28:21 -08:00
Chris Rhodes
b083ce00c7 Un-expose handlers. Clean up Session struct. 2016-02-14 21:58:29 -08:00
Chris Rhodes
88335b6f54 Small performance improvement. Added tests. 2016-02-14 19:01:45 -08:00
Chris Rhodes
8ffaa85b0b Thread safety and more events. 2016-02-14 13:41:56 -08:00
Chris Rhodes
fb6ae92555 Add basic support for mapped event handlers. 2016-02-14 13:17:20 -08:00
Chris Rhodes
40b969d7c3 VoiceServerUpdate and VoiceStateUpdate 2016-02-08 08:05:08 -08:00
Bruce Marriner
9b8e880744 Optimized some structs to reduce their runtime size. 2016-01-28 11:10:12 -06:00
Bruce Marriner
edc09778a7 Linting. 2016-01-28 08:36:09 -06:00
Bruce Marriner
9c5cd00d34 Spelling. 2016-01-27 23:31:43 -06:00
Chris Rhodes
fd32614a63 Make compression optional, clean up some comments and unused fields. 2016-01-24 09:49:41 -08:00
Chris Rhodes
e94e14e9d2 Support ShouldReconnectOnError with exponential backoff up to 10 minutes. 2016-01-21 14:15:24 -08:00
Chris Rhodes
2a9538e9f1 I must stop doing last minute changes. 2016-01-20 23:01:20 -08:00
Chris Rhodes
cd55a59ff9 Refactor open/close logic. Support OnConnect and OnDisconnect. 2016-01-20 22:47:34 -08:00
Chris Rhodes
0f38b22ca1 Message state tracking. 2016-01-16 00:20:41 -08:00
Chris Rhodes
b4dfce0fee Add methods for grabbing guild images. Clean up some docs. 2016-01-12 11:14:51 -08:00
Bruce Marriner
70d420f16b Add RateLimit struct 2016-01-10 19:39:44 -06:00
Bruce Marriner
093d3be770 More improvements to voice support 2016-01-10 18:01:05 -06:00
Bruce Marriner
1b3817c7e1 First re-write of voice support. BREAKING CHANGE. 2016-01-09 20:56:30 -06:00
Chris Rhodes
ea33680562 Merge remote-tracking branch 'bwmarrin/develop' into pointers 2016-01-08 09:40:56 -08:00
Chris Rhodes
0d7b6f7e76 Convert structs and api to use pointers. 2016-01-08 09:37:34 -08:00
Bruce Marriner
6e4f495f6a Removed unused AutoMention, renamed VoiceOP2 2016-01-08 10:52:27 -06:00
Bruce Marriner
e1e20260d3 Fixed operation in Event struct so it actually works. 2016-01-08 10:46:27 -06:00
Bruce Marriner
831fb29915 Moved Message struct and related structs into message.go 2016-01-08 10:33:29 -06:00
Bruce Marriner
7fc9331e04 Created message.go to store code related to the Message struct. 2016-01-08 10:29:01 -06:00
Bruce Marriner
301fb980d3 Updated copyright year, cleaned up some comments. 2016-01-07 13:50:44 -06:00
Bruce Marriner
a3ac679d76 Merge branch 'develop' of https://github.com/bwmarrin/Discordgo into develop 2016-01-04 13:14:33 -06:00
Bruce Marriner
b329c935ac Added check to prevent data websocket Listen func from running more than one instance. 2016-01-04 13:06:09 -06:00
Bruce Marriner
666cbeb6a6 Data websocket Heartbeat now uses a chan instead of bool to track state 2016-01-04 12:49:46 -06:00
Chris Rhodes
cd01a34cdb Handle GUILD_EMOJI_UPDATE and track Emoji in state. 2016-01-03 11:56:46 -08:00
Chris Rhodes
aa4d42199a Add and Parse Emojis struct. 2016-01-03 00:38:34 -08:00
Bruce Marriner
825144012d Prevent data websocket heartbeat from running more than once, closes #43 2016-01-02 22:32:02 -06:00
Chris Rhodes
9ba6d5b7c1 Make state tracking optional. 2016-01-02 12:01:03 -08:00
Chris Rhodes
b2ef55ae9c Cleanup before mailing. 2016-01-01 22:56:32 -08:00
Chris Rhodes
4e23e5fc35 Implement state tracking.
Currently maintains a list of Guilds (Members/Channels) and PrivateChannels.
2016-01-01 22:47:19 -08:00
Bruce
43bf17c302 Merge pull request #39 from iopred/mentions
Add a method on Message to replace mentions with usernames.
2016-01-01 18:30:37 -06:00
Chris Rhodes
ce0d4e5ee3 Add a method on Message to replace mentions with usernames. 2015-12-31 18:23:05 -08:00
Chris Rhodes
f1fc2f0996 Add GuildBan handling in wsapi. Closes #24.
Also refactor event handling so error logging is unified.
2015-12-31 12:33:46 -08:00
Bruce Marriner
6991af8500 Added support for USER_SETTINGS_UPDATE websocket event, closes #11 2015-12-29 12:45:30 -06:00
Bruce Marriner
bb4f63775e Updated to support new Discord method of sending game playing data, closes #34 2015-12-23 23:51:20 -06:00
Bruce Marriner
0360acbaa0 Added support for USER_UPDATE websocket event, closes #28 2015-12-21 11:24:48 -06:00
Bruce Marriner
d9a9a765d8 Removed Cache variable from Session, as it's not used currently. 2015-12-06 18:37:13 -06:00
Bruce Marriner
dd4aef7263 Added AutoMention option to parse MessageSend for any <@ID> tags. 2015-12-06 17:04:05 -06:00
Bruce Marriner
c77f7f3ff8 Added VoiceReady, DataReady, and UDPReady flags to Session struct 2015-11-25 19:28:53 -06:00
Bruce Marriner
35e3966b91 Reworded top comment 2015-11-23 10:16:23 -06:00
Bruce Marriner
abe55ecca7 Some improvements to comments. 2015-11-23 09:45:40 -06:00
Bruce Marriner
f789b29a8d Use the right websockets. 2015-11-22 14:23:52 -06:00
Bruce Marriner
3e605c64a6 Moving all structs to structs.go for now. 2015-11-22 14:21:41 -06:00
Bruce Marriner
8ef21d2380 Fixed IDs left as ints instead of strings. THANK YOU - Pikachu 2015-11-17 21:26:24 -06:00
Bruce Marriner
4316dfe9b9 Removed "Sample" from VoiceRegions struct 2015-11-17 10:42:58 -06:00
Bruce Marriner
f655167761 Several updates to make library more idiomatic Go 2015-11-16 21:39:39 -06:00
Bruce Marriner
91207ece15 Large additions to REST API and Websocket API. 2015-11-16 13:05:56 -06:00
Bruce Marriner
4fc845b7eb Added structs for voice regions and ice 2015-11-14 11:14:30 -06:00
Bruce Marriner
2c3ca777f9 Clean up, notes 2015-11-09 14:22:36 -06:00
Bruce Marriner
e6789fde74 Inital add of Websockets 2015-11-08 21:42:16 -06:00
Bruce Marriner
f3ddf16ff7 Removed Mentions struct, as its the same as User 2015-11-07 11:31:46 -06:00
Bruce Marriner
782fbe2bc9 Added Message func to client.go to pull channel messages 2015-11-03 10:56:09 -06:00
Bruce Marriner
66da5a3ae4 Created a client.go with low level access functions and started
working on "easy access" methods in each data structure that point
to the low level client.go functions.  Added channel.go, server.go
2015-11-03 08:35:58 -06:00
Bruce Marriner
c0f68b4bd5 Refactoring stuff, moved things around :) 2015-11-02 16:43:10 -06:00
Bruce Marriner
49ca49f6de Moving structures to structs.go to clean up client file some.
Will probably move these all into individual files later
2015-11-02 11:09:52 -06:00