commandrb 0.4.1 → 0.4.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/commandrb.rb +26 -16
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51288c75ab522040fdf27c3c7e065e4ce32c1d28
4
- data.tar.gz: 7e91d61b2dc09ae430b014871de04a97c57e6ccd
3
+ metadata.gz: f29c156bce33643bcf6e96cf4e3412bb2f0c7491
4
+ data.tar.gz: '084fff7142244fd4b4d5de25c7f675a86f439816'
5
5
  SHA512:
6
- metadata.gz: 54e3155a4b1a31a347e61c74a16b47e3ebfc9f383d887a9688314f2aec760dc150b55077f771b0a227990eb2e7bf54a5431a0a37e6b1db4f5999011ed0c24874
7
- data.tar.gz: 42bfc2dab44cf8f69b5959b3133cb80c399bd638b166dde36e28dc7a6a5524705f1f0bece9570ef9487f93aeec8c4ea9c9a88c1f92e1b0166ccd90d57142d1b8
6
+ metadata.gz: 24f86e1110fa38f7424d85059635f6a0fb4d8c3ced1346ce398bc139c00a296dfa60f02b380ea9a87c719a3c7235163e0400bf63bc821efba10e2f0c39d825bb
7
+ data.tar.gz: c45ceb8987737e3a2a42698df5fb1354ccd12b3466d855d1fc91d01df8661b68020deb36396899bdae896d152632c13a4ef6065ebe3f16e6102aaf3b7485af41
data/lib/commandrb.rb CHANGED
@@ -225,32 +225,42 @@ class CommandrbBot
225
225
  code_error: false
226
226
  )
227
227
  )
228
+ @finished = true
228
229
  break
229
230
  end
230
231
  end
231
232
 
232
- # If the command is configured to catch all errors, thy shall be done.
233
- if !command[:catch_errors] || @config['catch_errors']
234
- # Run the command code!
235
- command[:code].call(event, args, rawargs)
236
- else
237
- # Run the command code, but catch all errors and output accordingly.
238
- begin
239
- command[:code].call(event, args, rawargs)
240
- rescue Exception => e
241
- event.respond("❌ An error has occured!! ```ruby\n#{e}```Please contact the bot owner with the above message for assistance.")
242
- end
243
- end
244
-
245
233
  unless command[:required_permissions].nil?
246
234
  command[:required_permissions].each { |x|
247
- if event.user.on(event.server).permission?(x,event.channel)
248
- event.respond('❌ You don\'t have permission for that!')
235
+ unless event.user.on(event.server).permission?(x,event.channel)
236
+ event.channel.send_message('', false,
237
+ Helper.error_embed(
238
+ error: "You don't have permission for that!\nPermission required: `#{x.to_s}`",
239
+ footer: "Command: `#{event.message.content}`",
240
+ colour: 0xFA0E30,
241
+ code_error: false
242
+ )
243
+ )
249
244
  @finished = true
250
- next
245
+ break
251
246
  end
252
247
  }
248
+ end
249
+
250
+ unless @finished
251
+ # If the command is configured to catch all errors, thy shall be done.
252
+ if !command[:catch_errors] || @config['catch_errors']
253
+ # Run the command code!
254
+ command[:code].call(event, args, rawargs)
255
+ else
256
+ # Run the command code, but catch all errors and output accordingly.
257
+ begin
258
+ command[:code].call(event, args, rawargs)
259
+ rescue Exception => e
260
+ event.respond("❌ An error has occured!! ```ruby\n#{e}```Please contact the bot owner with the above message for assistance.")
261
+ end
253
262
  end
263
+ end
254
264
 
255
265
  # All done here.
256
266
  puts "Finished!! Executed command: #{@chosen}" if @debug_mode
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commandrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erisa Komuro (Seriel)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-31 00:00:00.000000000 Z
11
+ date: 2017-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: discordrb