mij-discord 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5fcf947865936bee821151da5e83bef481fd163
4
- data.tar.gz: 97545b505d78aae0d38a65efe7d6608d41f2cb30
3
+ metadata.gz: a986d989e1c82e40f9c1c5346b3496a402491f3e
4
+ data.tar.gz: 8db9cd45703269a7c40e03beccc2c4dcf272b0d3
5
5
  SHA512:
6
- metadata.gz: 684a85c5f4d1aea724672abe6d343eea34cc67dfca1e8cbaaa65ee6c4debb2fd9a83febfe5c98cc6586480070aed222ae9d08ce1b9ba1e287a46fd4ca07e3c2f
7
- data.tar.gz: cda5fe4edf5ee6021610c4cf637b1ca598ebe8710dd3b88c3cce9b1ea2de7783e386642b6d81ba597b4bbe741f03500d2de117f2cd35bd94d6ca83827f353d75
6
+ metadata.gz: 31147c15e9b63573c41bba6b700b9be15002be8b7262ca42c2fc50a7fc0ed7486ca08e6833a98ee53f58a4cbbdc151d05b6a43ee0da399698f291b7925100e9c
7
+ data.tar.gz: e5d0c9e7383b825b8bb513177361cb9dbd56650fd8f3563ca18c878ac3a9269f816f2b3d84e43c5d18b97ac15b41f43316e5831d69f920cf828781cb5c31686a
@@ -2,6 +2,18 @@
2
2
 
3
3
  module MijDiscord
4
4
  class Bot
5
+ class AuthInfo
6
+ attr_reader :token
7
+
8
+ attr_reader :type
9
+
10
+ def initialize(token, type)
11
+ @token, @type = token, type
12
+ end
13
+
14
+ alias_method :to_s, :token
15
+ end
16
+
5
17
  EVENTS = {
6
18
  ready: MijDiscord::Events::Ready,
7
19
  heartbeat: MijDiscord::Events::Heartbeat,
@@ -48,24 +60,13 @@ module MijDiscord
48
60
 
49
61
  UNAVAILABLE_SERVER_TIMEOUT = 10
50
62
 
51
- USER_STATUS = {
52
- online: :online,
53
- idle: :idle,
54
- away: :idle,
55
- dnd: :dnd,
56
- busy: :dnd,
57
- invisible: :invisible,
58
- hidden: :invisible,
59
- offline: :offline
60
- }.freeze
63
+ USER_STATUS = [:online, :idle, :dnd, :invisible, :offline].freeze
61
64
 
62
65
  attr_reader :name
63
66
 
64
- attr_reader :type
65
-
66
67
  attr_reader :client_id
67
68
 
68
- attr_reader :token
69
+ attr_reader :auth
69
70
 
70
71
  attr_reader :shard_key
71
72
 
@@ -77,18 +78,20 @@ module MijDiscord
77
78
 
78
79
  def initialize(client_id:, token:, type: :bot, name: nil,
79
80
  shard_id: nil, num_shards: nil, ignore_bots: false, ignore_self: true)
80
- @client_id, @type, @name = client_id.to_id, type, name || ''
81
+ @client_id, @name = client_id.to_id, name || ''
81
82
 
82
- @token = case @type
83
+ token = case type
83
84
  when :bot then "Bot #{token}"
84
85
  when :user then "#{token}"
85
86
  else raise ArgumentError, 'Invalid bot type'
86
87
  end
87
88
 
89
+ @auth = AuthInfo.new(token, type)
90
+
88
91
  @cache = MijDiscord::Cache::BotCache.new(self)
89
92
 
90
93
  @shard_key = [shard_id, num_shards] if num_shards
91
- @gateway = MijDiscord::Core::Gateway.new(self, @token, @shard_key)
94
+ @gateway = MijDiscord::Core::Gateway.new(self, @auth, @shard_key)
92
95
 
93
96
  @ignore_bots, @ignore_self, @ignored_ids = ignore_bots, ignore_self, Set.new
94
97
 
@@ -189,19 +192,19 @@ module MijDiscord
189
192
  def application
190
193
  raise 'Cannot get OAuth application for non-bot user' if @type != :bot
191
194
 
192
- response = MijDiscord::Core::API.oauth_application(@token)
195
+ response = MijDiscord::Core::API.oauth_application(@auth)
193
196
  MijDiscord::Data::Application.new(JSON.parse(response), self)
194
197
  end
195
198
 
196
199
  def invite(invite)
197
200
  code = parse_invite_code(invite)
198
- response = MijDiscord::Core::API::Invite.resolve(@token, code)
201
+ response = MijDiscord::Core::API::Invite.resolve(@auth, code)
199
202
  MijDiscord::Data::Invite.new(JSON.parse(response), self)
200
203
  end
201
204
 
202
205
  def accept_invite(invite)
203
206
  code = parse_invite_code(invite)
204
- MijDiscord::Core::API::Invite.accept(@token, code)
207
+ MijDiscord::Core::API::Invite.accept(@auth, code)
205
208
  nil
206
209
  end
207
210
 
@@ -213,7 +216,7 @@ module MijDiscord
213
216
  end
214
217
 
215
218
  def create_server(name, region = 'eu-central')
216
- response = API::Server.create(@token, name, region)
219
+ response = API::Server.create(@auth, name, region)
217
220
  id = JSON.parse(response)['id'].to_i
218
221
 
219
222
  loop do
@@ -296,7 +299,7 @@ module MijDiscord
296
299
  def change_status(status: nil, game: nil, url: nil)
297
300
  gateway_check
298
301
 
299
- status = status.nil? ? @profile.status : USER_STATUS[status]
302
+ status = status.nil? ? @profile.status : USER_STATUS.find(status)
300
303
  raise ArgumentError, "Status '#{status}' is not valid" unless status
301
304
 
302
305
  game_obj = case game
@@ -391,7 +394,7 @@ module MijDiscord
391
394
  server = @cache.remove_server(data['id'])
392
395
 
393
396
  if data['unavailable'].eql?(true)
394
- MijDiscord::LOGGER.warn('Dispatch') { "Server <#{server.id}> died due to outage" }
397
+ MijDiscord::LOGGER.warn('Dispatch') { "Server <#{data['id']}> died due to outage" }
395
398
  return
396
399
  end
397
400
 
@@ -31,7 +31,7 @@ module MijDiscord::Cache
31
31
  return nil if local
32
32
 
33
33
  begin
34
- response = MijDiscord::Core::API::Server.resolve(@bot.token, id)
34
+ response = MijDiscord::Core::API::Server.resolve(@bot.auth, id)
35
35
  rescue RestClient::ResourceNotFound
36
36
  return nil
37
37
  end
@@ -46,7 +46,7 @@ module MijDiscord::Cache
46
46
  return nil if local
47
47
 
48
48
  begin
49
- response = MijDiscord::Core::API::Channel.resolve(@bot.token, id)
49
+ response = MijDiscord::Core::API::Channel.resolve(@bot.auth, id)
50
50
  rescue RestClient::ResourceNotFound
51
51
  return nil
52
52
  rescue MijDiscord::Errors::NoPermission
@@ -69,7 +69,7 @@ module MijDiscord::Cache
69
69
  return @pm_channels[id] if @pm_channels.has_key?(id)
70
70
  return nil if local
71
71
 
72
- response = MijDiscord::Core::API::User.create_pm(@bot.token, id)
72
+ response = MijDiscord::Core::API::User.create_pm(@bot.auth, id)
73
73
  channel = MijDiscord::Data::Channel.create(JSON.parse(response), @bot, nil)
74
74
 
75
75
  @channels[channel.id] = @pm_channels[id] = channel
@@ -81,7 +81,7 @@ module MijDiscord::Cache
81
81
  return nil if local
82
82
 
83
83
  begin
84
- response = MijDiscord::Core::API::User.resolve(@bot.token, id)
84
+ response = MijDiscord::Core::API::User.resolve(@bot.auth, id)
85
85
  rescue RestClient::ResourceNotFound
86
86
  return nil
87
87
  end
@@ -175,7 +175,7 @@ module MijDiscord::Cache
175
175
  return nil if local
176
176
 
177
177
  begin
178
- response = MijDiscord::Core::API::Server.resolve_member(@bot.token, @server.id, id)
178
+ response = MijDiscord::Core::API::Server.resolve_member(@bot.auth, @server.id, id)
179
179
  rescue RestClient::ResourceNotFound
180
180
  return nil
181
181
  end
@@ -267,7 +267,7 @@ module MijDiscord::Cache
267
267
  return nil if local
268
268
 
269
269
  begin
270
- response = MijDiscord::Core::API::Channel.message(@bot.token, @channel.id, key)
270
+ response = MijDiscord::Core::API::Channel.message(@bot.auth, @channel.id, key)
271
271
  rescue RestClient::ResourceNotFound
272
272
  return nil
273
273
  end
@@ -8,8 +8,8 @@ module MijDiscord::Core::API
8
8
  class << self
9
9
  attr_accessor :bot_name
10
10
 
11
- def user_agent(kind)
12
- case kind
11
+ def user_agent(auth)
12
+ case auth&.type
13
13
  when :bot
14
14
  bot_name = @bot_name || 'generic'
15
15
  ua_base = "DiscordBot (https://github.com/Mijyuoon/mij-discord, v#{MijDiscord::VERSION})"
@@ -20,14 +20,6 @@ module MijDiscord::Core::API
20
20
  end
21
21
  end
22
22
 
23
- def token_type(token)
24
- case token
25
- when /^Bot (.+)$/ then :bot
26
- when /^mfa\.(.+)$/ then :user
27
- else :user
28
- end
29
- end
30
-
31
23
  # Make an icon URL from server and icon IDs
32
24
  def icon_url(server_id, icon_id, format = :webp)
33
25
  "#{CDN_URL}/icons/#{server_id}/#{icon_id}.#{format}"
@@ -66,100 +58,100 @@ module MijDiscord::Core::API
66
58
  end
67
59
 
68
60
  # Logout from the server
69
- def logout(token)
61
+ def logout(auth)
70
62
  request(
71
63
  :auth_logout,
72
64
  nil,
73
65
  :post,
74
66
  "#{APIBASE_URL}/auth/logout",
75
67
  nil,
76
- Authorization: token
68
+ Authorization: auth
77
69
  )
78
70
  end
79
71
 
80
72
  # Create an OAuth application
81
- def create_oauth_application(token, name, redirect_uris)
73
+ def create_oauth_application(auth, name, redirect_uris)
82
74
  request(
83
75
  :oauth2_applications,
84
76
  nil,
85
77
  :post,
86
78
  "#{APIBASE_URL}/oauth2/applications",
87
79
  { name: name, redirect_uris: redirect_uris }.to_json,
88
- Authorization: token,
80
+ Authorization: auth,
89
81
  content_type: :json
90
82
  )
91
83
  end
92
84
 
93
85
  # Change an OAuth application's properties
94
- def update_oauth_application(token, name, redirect_uris, description = '', icon = nil)
86
+ def update_oauth_application(auth, name, redirect_uris, description = '', icon = nil)
95
87
  request(
96
88
  :oauth2_applications,
97
89
  nil,
98
90
  :put,
99
91
  "#{APIBASE_URL}/oauth2/applications",
100
92
  { name: name, redirect_uris: redirect_uris, description: description, icon: icon }.to_json,
101
- Authorization: token,
93
+ Authorization: auth,
102
94
  content_type: :json
103
95
  )
104
96
  end
105
97
 
106
98
  # Get the bot's OAuth application's information
107
- def oauth_application(token)
99
+ def oauth_application(auth)
108
100
  request(
109
101
  :oauth2_applications_me,
110
102
  nil,
111
103
  :get,
112
104
  "#{APIBASE_URL}/oauth2/applications/@me",
113
- Authorization: token
105
+ Authorization: auth
114
106
  )
115
107
  end
116
108
 
117
109
  # Acknowledge that a message has been received
118
110
  # The last acknowledged message will be sent in the ready packet,
119
111
  # so this is an easy way to catch up on messages
120
- def acknowledge_message(token, channel_id, message_id)
112
+ def acknowledge_message(auth, channel_id, message_id)
121
113
  request(
122
114
  :channels_cid_messages_mid_ack,
123
115
  nil, # This endpoint is unavailable for bot accounts and thus isn't subject to its rate limit requirements.
124
116
  :post,
125
117
  "#{APIBASE_URL}/channels/#{channel_id}/messages/#{message_id}/ack",
126
118
  nil,
127
- Authorization: token
119
+ Authorization: auth
128
120
  )
129
121
  end
130
122
 
131
123
  # Get the gateway to be used
132
- def gateway(token)
124
+ def gateway(auth)
133
125
  request(
134
126
  :gateway,
135
127
  nil,
136
128
  :get,
137
129
  "#{APIBASE_URL}/gateway",
138
- Authorization: token
130
+ Authorization: auth,
139
131
  )
140
132
  end
141
133
 
142
134
  # Validate a token (this request will fail if the token is invalid)
143
- def validate_token(token)
135
+ def validate_token(auth)
144
136
  request(
145
137
  :auth_login,
146
138
  nil,
147
139
  :post,
148
140
  "#{APIBASE_URL}/auth/login",
149
141
  {}.to_json,
150
- Authorization: token,
142
+ Authorization: auth,
151
143
  content_type: :json
152
144
  )
153
145
  end
154
146
 
155
147
  # Get a list of available voice regions
156
- def voice_regions(token)
148
+ def voice_regions(auth)
157
149
  request(
158
150
  :voice_regions,
159
151
  nil,
160
152
  :get,
161
153
  "#{APIBASE_URL}/voice/regions",
162
- Authorization: token,
154
+ Authorization: auth,
163
155
  content_type: :json
164
156
  )
165
157
  end
@@ -177,8 +169,7 @@ module MijDiscord::Core::API
177
169
  ratelimit_delta, response = nil, nil
178
170
 
179
171
  if (params = attributes.last).is_a?(Hash)
180
- ua_type = token_type(params[:Authorization])
181
- params[:user_agent] = user_agent(ua_type)
172
+ params[:user_agent] = user_agent(params[:Authorization])
182
173
  ratelimit_delta = params.delete(:header_bypass_delay)
183
174
  end
184
175
 
@@ -4,19 +4,19 @@ module MijDiscord::Core::API::Channel
4
4
  class << self
5
5
  # Get a channel's data
6
6
  # https://discordapp.com/developers/docs/resources/channel#get-channel
7
- def resolve(token, channel_id)
7
+ def resolve(auth, channel_id)
8
8
  MijDiscord::Core::API.request(
9
9
  :channels_cid,
10
10
  channel_id,
11
11
  :get,
12
12
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}",
13
- Authorization: token
13
+ Authorization: auth
14
14
  )
15
15
  end
16
16
 
17
17
  # Update a channel's data
18
18
  # https://discordapp.com/developers/docs/resources/channel#modify-channel
19
- def update(token, channel_id, name, topic, nsfw, parent_id, position, bitrate, user_limit, overwrites, reason = nil)
19
+ def update(auth, channel_id, name, topic, nsfw, parent_id, position, bitrate, user_limit, overwrites, reason = nil)
20
20
  MijDiscord::Core::API.request(
21
21
  :channels_cid,
22
22
  channel_id,
@@ -28,7 +28,7 @@ module MijDiscord::Core::API::Channel
28
28
  bitrate: bitrate, user_limit: user_limit,
29
29
  permission_overwrites: overwrites
30
30
  }.delete_if {|_, v| v.nil? }.to_json,
31
- Authorization: token,
31
+ Authorization: auth,
32
32
  content_type: :json,
33
33
  'X-Audit-Log-Reason': reason
34
34
  )
@@ -36,51 +36,51 @@ module MijDiscord::Core::API::Channel
36
36
 
37
37
  # Delete a channel
38
38
  # https://discordapp.com/developers/docs/resources/channel#deleteclose-channel
39
- def delete(token, channel_id, reason = nil)
39
+ def delete(auth, channel_id, reason = nil)
40
40
  MijDiscord::Core::API.request(
41
41
  :channels_cid,
42
42
  channel_id,
43
43
  :delete,
44
44
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}",
45
- Authorization: token,
45
+ Authorization: auth,
46
46
  'X-Audit-Log-Reason': reason
47
47
  )
48
48
  end
49
49
 
50
50
  # Get a list of messages from a channel's history
51
51
  # https://discordapp.com/developers/docs/resources/channel#get-channel-messages
52
- def messages(token, channel_id, amount, before = nil, after = nil, around = nil)
52
+ def messages(auth, channel_id, amount, before = nil, after = nil, around = nil)
53
53
  MijDiscord::Core::API.request(
54
54
  :channels_cid_messages,
55
55
  channel_id,
56
56
  :get,
57
57
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages?limit=#{amount}#{"&before=#{before}" if before}#{"&after=#{after}" if after}#{"&around=#{around}" if around}",
58
- Authorization: token
58
+ Authorization: auth
59
59
  )
60
60
  end
61
61
 
62
62
  # Get a single message from a channel's history by id
63
63
  # https://discordapp.com/developers/docs/resources/channel#get-channel-message
64
- def message(token, channel_id, message_id)
64
+ def message(auth, channel_id, message_id)
65
65
  MijDiscord::Core::API.request(
66
66
  :channels_cid_messages_mid,
67
67
  channel_id,
68
68
  :get,
69
69
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages/#{message_id}",
70
- Authorization: token
70
+ Authorization: auth
71
71
  )
72
72
  end
73
73
 
74
74
  # Send a message to a channel
75
75
  # https://discordapp.com/developers/docs/resources/channel#create-message
76
- def create_message(token, channel_id, message, tts = false, embed = nil, mentions = [])
76
+ def create_message(auth, channel_id, message, tts = false, embed = nil, mentions = [])
77
77
  MijDiscord::Core::API.request(
78
78
  :channels_cid_messages_mid,
79
79
  channel_id,
80
80
  :post,
81
81
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages",
82
82
  { content: message, mentions: mentions, tts: tts, embed: embed }.to_json,
83
- Authorization: token,
83
+ Authorization: auth,
84
84
  content_type: :json
85
85
  )
86
86
  rescue RestClient::BadRequest => e
@@ -93,60 +93,60 @@ module MijDiscord::Core::API::Channel
93
93
 
94
94
  # Send a file as a message to a channel
95
95
  # https://discordapp.com/developers/docs/resources/channel#upload-file
96
- def upload_file(token, channel_id, file, caption = nil, tts = false)
96
+ def upload_file(auth, channel_id, file, caption = nil, tts = false)
97
97
  MijDiscord::Core::API.request(
98
98
  :channels_cid_messages_mid,
99
99
  channel_id,
100
100
  :post,
101
101
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages",
102
102
  { file: file, content: caption, tts: tts },
103
- Authorization: token
103
+ Authorization: auth
104
104
  )
105
105
  end
106
106
 
107
107
  # Edit a message
108
108
  # https://discordapp.com/developers/docs/resources/channel#edit-message
109
- def edit_message(token, channel_id, message_id, message, mentions = [], embed = nil)
109
+ def edit_message(auth, channel_id, message_id, message, mentions = [], embed = nil)
110
110
  MijDiscord::Core::API.request(
111
111
  :channels_cid_messages_mid,
112
112
  channel_id,
113
113
  :patch,
114
114
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages/#{message_id}",
115
115
  { content: message, mentions: mentions, embed: embed }.to_json,
116
- Authorization: token,
116
+ Authorization: auth,
117
117
  content_type: :json
118
118
  )
119
119
  end
120
120
 
121
121
  # Delete a message
122
122
  # https://discordapp.com/developers/docs/resources/channel#delete-message
123
- def delete_message(token, channel_id, message_id)
123
+ def delete_message(auth, channel_id, message_id)
124
124
  MijDiscord::Core::API.request(
125
125
  :channels_cid_messages_mid,
126
126
  channel_id,
127
127
  :delete,
128
128
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages/#{message_id}",
129
- Authorization: token
129
+ Authorization: auth
130
130
  )
131
131
  end
132
132
 
133
133
  # Delete messages in bulk
134
134
  # https://discordapp.com/developers/docs/resources/channel#bulk-delete-messages
135
- def bulk_delete_messages(token, channel_id, messages = [])
135
+ def bulk_delete_messages(auth, channel_id, messages = [])
136
136
  MijDiscord::Core::API.request(
137
137
  :channels_cid_messages_bulk_delete,
138
138
  channel_id,
139
139
  :post,
140
140
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages/bulk-delete",
141
141
  { messages: messages }.to_json,
142
- Authorization: token,
142
+ Authorization: auth,
143
143
  content_type: :json
144
144
  )
145
145
  end
146
146
 
147
147
  # Create a reaction on a message using this client
148
148
  # https://discordapp.com/developers/docs/resources/channel#create-reaction
149
- def create_reaction(token, channel_id, message_id, emoji)
149
+ def create_reaction(auth, channel_id, message_id, emoji)
150
150
  emoji = URI.encode(emoji) unless emoji.ascii_only?
151
151
  MijDiscord::Core::API.request(
152
152
  :channels_cid_messages_mid_reactions_emoji_me,
@@ -154,7 +154,7 @@ module MijDiscord::Core::API::Channel
154
154
  :put,
155
155
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}/@me",
156
156
  nil,
157
- Authorization: token,
157
+ Authorization: auth,
158
158
  content_type: :json,
159
159
  header_bypass_delay: 0.25
160
160
  )
@@ -162,67 +162,67 @@ module MijDiscord::Core::API::Channel
162
162
 
163
163
  # Delete this client's own reaction on a message
164
164
  # https://discordapp.com/developers/docs/resources/channel#delete-own-reaction
165
- def delete_own_reaction(token, channel_id, message_id, emoji)
165
+ def delete_own_reaction(auth, channel_id, message_id, emoji)
166
166
  emoji = URI.encode(emoji) unless emoji.ascii_only?
167
167
  MijDiscord::Core::API.request(
168
168
  :channels_cid_messages_mid_reactions_emoji_me,
169
169
  channel_id,
170
170
  :delete,
171
171
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}/@me",
172
- Authorization: token,
172
+ Authorization: auth,
173
173
  header_bypass_delay: 0.25
174
174
  )
175
175
  end
176
176
 
177
177
  # Delete another client's reaction on a message
178
178
  # https://discordapp.com/developers/docs/resources/channel#delete-user-reaction
179
- def delete_user_reaction(token, channel_id, message_id, emoji, user_id)
179
+ def delete_user_reaction(auth, channel_id, message_id, emoji, user_id)
180
180
  emoji = URI.encode(emoji) unless emoji.ascii_only?
181
181
  MijDiscord::Core::API.request(
182
182
  :channels_cid_messages_mid_reactions_emoji_uid,
183
183
  channel_id,
184
184
  :delete,
185
185
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}/#{user_id}",
186
- Authorization: token,
186
+ Authorization: auth,
187
187
  header_bypass_delay: 0.25
188
188
  )
189
189
  end
190
190
 
191
191
  # Get a list of clients who reacted with a specific reaction on a message
192
192
  # https://discordapp.com/developers/docs/resources/channel#get-reactions
193
- def get_reactions(token, channel_id, message_id, emoji)
193
+ def get_reactions(auth, channel_id, message_id, emoji)
194
194
  emoji = URI.encode(emoji) unless emoji.ascii_only?
195
195
  MijDiscord::Core::API.request(
196
196
  :channels_cid_messages_mid_reactions_emoji,
197
197
  channel_id,
198
198
  :get,
199
199
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}",
200
- Authorization: token
200
+ Authorization: auth
201
201
  )
202
202
  end
203
203
 
204
204
  # Deletes all reactions on a message from all clients
205
205
  # https://discordapp.com/developers/docs/resources/channel#delete-all-reactions
206
- def delete_all_reactions(token, channel_id, message_id)
206
+ def delete_all_reactions(auth, channel_id, message_id)
207
207
  MijDiscord::Core::API.request(
208
208
  :channels_cid_messages_mid_reactions,
209
209
  channel_id,
210
210
  :delete,
211
211
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/messages/#{message_id}/reactions",
212
- Authorization: token
212
+ Authorization: auth
213
213
  )
214
214
  end
215
215
 
216
216
  # Update a channels permission for a role or member
217
217
  # https://discordapp.com/developers/docs/resources/channel#edit-channel-permissions
218
- def update_permission(token, channel_id, overwrite_id, allow, deny, type, reason = nil)
218
+ def update_permission(auth, channel_id, overwrite_id, allow, deny, type, reason = nil)
219
219
  MijDiscord::Core::API.request(
220
220
  :channels_cid_permissions_oid,
221
221
  channel_id,
222
222
  :put,
223
223
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/permissions/#{overwrite_id}",
224
224
  { type: type, id: overwrite_id, allow: allow, deny: deny }.to_json,
225
- Authorization: token,
225
+ Authorization: auth,
226
226
  content_type: :json,
227
227
  'X-Audit-Log-Reason': reason
228
228
  )
@@ -230,26 +230,26 @@ module MijDiscord::Core::API::Channel
230
230
 
231
231
  # Get a channel's invite list
232
232
  # https://discordapp.com/developers/docs/resources/channel#get-channel-invites
233
- def invites(token, channel_id)
233
+ def invites(auth, channel_id)
234
234
  MijDiscord::Core::API.request(
235
235
  :channels_cid_invites,
236
236
  channel_id,
237
237
  :get,
238
238
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/invites",
239
- Authorization: token
239
+ Authorization: auth
240
240
  )
241
241
  end
242
242
 
243
243
  # Create an instant invite from a server or a channel id
244
244
  # https://discordapp.com/developers/docs/resources/channel#create-channel-invite
245
- def create_invite(token, channel_id, max_age = 0, max_uses = 0, temporary = false, unique = false, reason = nil)
245
+ def create_invite(auth, channel_id, max_age = 0, max_uses = 0, temporary = false, unique = false, reason = nil)
246
246
  MijDiscord::Core::API.request(
247
247
  :channels_cid_invites,
248
248
  channel_id,
249
249
  :post,
250
250
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/invites",
251
251
  { max_age: max_age, max_uses: max_uses, temporary: temporary, unique: unique }.to_json,
252
- Authorization: token,
252
+ Authorization: auth,
253
253
  content_type: :json,
254
254
  'X-Audit-Log-Reason': reason
255
255
  )
@@ -257,89 +257,89 @@ module MijDiscord::Core::API::Channel
257
257
 
258
258
  # Delete channel permission
259
259
  # https://discordapp.com/developers/docs/resources/channel#delete-channel-permission
260
- def delete_permission(token, channel_id, overwrite_id, reason = nil)
260
+ def delete_permission(auth, channel_id, overwrite_id, reason = nil)
261
261
  MijDiscord::Core::API.request(
262
262
  :channels_cid_permissions_oid,
263
263
  channel_id,
264
264
  :delete,
265
265
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/permissions/#{overwrite_id}",
266
- Authorization: token,
266
+ Authorization: auth,
267
267
  'X-Audit-Log-Reason': reason
268
268
  )
269
269
  end
270
270
 
271
271
  # Start typing (needs to be resent every 5 seconds to keep up the typing)
272
272
  # https://discordapp.com/developers/docs/resources/channel#trigger-typing-indicator
273
- def start_typing(token, channel_id)
273
+ def start_typing(auth, channel_id)
274
274
  MijDiscord::Core::API.request(
275
275
  :channels_cid_typing,
276
276
  channel_id,
277
277
  :post,
278
278
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/typing",
279
279
  nil,
280
- Authorization: token
280
+ Authorization: auth
281
281
  )
282
282
  end
283
283
 
284
284
  # Get a list of pinned messages in a channel
285
285
  # https://discordapp.com/developers/docs/resources/channel#get-pinned-messages
286
- def pinned_messages(token, channel_id)
286
+ def pinned_messages(auth, channel_id)
287
287
  MijDiscord::Core::API.request(
288
288
  :channels_cid_pins,
289
289
  channel_id,
290
290
  :get,
291
291
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/pins",
292
- Authorization: token
292
+ Authorization: auth
293
293
  )
294
294
  end
295
295
 
296
296
  # Pin a message
297
297
  # https://discordapp.com/developers/docs/resources/channel#add-pinned-channel-message
298
- def pin_message(token, channel_id, message_id)
298
+ def pin_message(auth, channel_id, message_id)
299
299
  MijDiscord::Core::API.request(
300
300
  :channels_cid_pins_mid,
301
301
  channel_id,
302
302
  :put,
303
303
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/pins/#{message_id}",
304
304
  nil,
305
- Authorization: token
305
+ Authorization: auth
306
306
  )
307
307
  end
308
308
 
309
309
  # Unpin a message
310
310
  # https://discordapp.com/developers/docs/resources/channel#delete-pinned-channel-message
311
- def unpin_message(token, channel_id, message_id)
311
+ def unpin_message(auth, channel_id, message_id)
312
312
  MijDiscord::Core::API.request(
313
313
  :channels_cid_pins_mid,
314
314
  channel_id,
315
315
  :delete,
316
316
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/pins/#{message_id}",
317
- Authorization: token
317
+ Authorization: auth
318
318
  )
319
319
  end
320
320
 
321
321
  # Create an empty group channel.
322
- def create_empty_group(token, bot_user_id)
322
+ def create_empty_group(auth, bot_user_id)
323
323
  MijDiscord::Core::API.request(
324
324
  :users_uid_channels,
325
325
  nil,
326
326
  :post,
327
327
  "#{MijDiscord::Core::API::APIBASE_URL}/users/#{bot_user_id}/channels",
328
328
  {}.to_json,
329
- Authorization: token,
329
+ Authorization: auth,
330
330
  content_type: :json
331
331
  )
332
332
  end
333
333
 
334
334
  # Create a group channel.
335
- def create_group(token, pm_channel_id, user_id)
335
+ def create_group(auth, pm_channel_id, user_id)
336
336
  MijDiscord::Core::API.request(
337
337
  :channels_cid_recipients_uid,
338
338
  nil,
339
339
  :put,
340
340
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{pm_channel_id}/recipients/#{user_id}",
341
341
  {}.to_json,
342
- Authorization: token,
342
+ Authorization: auth,
343
343
  content_type: :json
344
344
  )
345
345
  rescue RestClient::InternalServerError
@@ -351,52 +351,52 @@ module MijDiscord::Core::API::Channel
351
351
  end
352
352
 
353
353
  # Add a user to a group channel.
354
- def add_group_user(token, group_channel_id, user_id)
354
+ def add_group_user(auth, group_channel_id, user_id)
355
355
  MijDiscord::Core::API.request(
356
356
  :channels_cid_recipients_uid,
357
357
  nil,
358
358
  :put,
359
359
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{group_channel_id}/recipients/#{user_id}",
360
360
  {}.to_json,
361
- Authorization: token,
361
+ Authorization: auth,
362
362
  content_type: :json
363
363
  )
364
364
  end
365
365
 
366
366
  # Remove a user from a group channel.
367
- def remove_group_user(token, group_channel_id, user_id)
367
+ def remove_group_user(auth, group_channel_id, user_id)
368
368
  MijDiscord::Core::API.request(
369
369
  :channels_cid_recipients_uid,
370
370
  nil,
371
371
  :delete,
372
372
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{group_channel_id}/recipients/#{user_id}",
373
- Authorization: token,
373
+ Authorization: auth,
374
374
  content_type: :json
375
375
  )
376
376
  end
377
377
 
378
378
  # Leave a group channel.
379
- def leave_group(token, group_channel_id)
379
+ def leave_group(auth, group_channel_id)
380
380
  MijDiscord::Core::API.request(
381
381
  :channels_cid,
382
382
  nil,
383
383
  :delete,
384
384
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{group_channel_id}",
385
- Authorization: token,
385
+ Authorization: auth,
386
386
  content_type: :json
387
387
  )
388
388
  end
389
389
 
390
390
  # Create a webhook
391
391
  # https://discordapp.com/developers/docs/resources/webhook#create-webhook
392
- def create_webhook(token, channel_id, name, avatar = nil, reason = nil)
392
+ def create_webhook(auth, channel_id, name, avatar = nil, reason = nil)
393
393
  MijDiscord::Core::API.request(
394
394
  :channels_cid_webhooks,
395
395
  channel_id,
396
396
  :post,
397
397
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/webhooks",
398
398
  { name: name, avatar: avatar }.to_json,
399
- Authorization: token,
399
+ Authorization: auth,
400
400
  content_type: :json,
401
401
  'X-Audit-Log-Reason': reason
402
402
  )
@@ -404,13 +404,13 @@ module MijDiscord::Core::API::Channel
404
404
 
405
405
  # Get channel webhooks
406
406
  # https://discordapp.com/developers/docs/resources/webhook#get-channel-webhooks
407
- def webhooks(token, channel_id)
407
+ def webhooks(auth, channel_id)
408
408
  MijDiscord::Core::API.request(
409
409
  :channels_cid_webhooks,
410
410
  channel_id,
411
411
  :get,
412
412
  "#{MijDiscord::Core::API::APIBASE_URL}/channels/#{channel_id}/webhooks",
413
- Authorization: token
413
+ Authorization: auth
414
414
  )
415
415
  end
416
416
  end