discordrb 3.4.0 → 3.4.3
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 +4 -4
- data/CHANGELOG.md +32 -0
- data/discordrb.gemspec +1 -1
- data/lib/discordrb/api/channel.rb +5 -0
- data/lib/discordrb/api/server.rb +2 -0
- data/lib/discordrb/api/user.rb +1 -0
- data/lib/discordrb/api.rb +1 -1
- data/lib/discordrb/bot.rb +13 -3
- data/lib/discordrb/commands/command_bot.rb +8 -3
- data/lib/discordrb/data/activity.rb +8 -1
- data/lib/discordrb/data/invite.rb +1 -1
- data/lib/discordrb/data/message.rb +1 -1
- data/lib/discordrb/version.rb +1 -1
- data/lib/discordrb/voice/encoder.rb +13 -4
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5c0ecfd68356ed63ea61a7b99bb5d32e358f74b23c2f729ab531e4848bc770d
|
4
|
+
data.tar.gz: 4c5917f1b7a1a3e97d875a0244a8fa8e9583bce025053505b960de9e900ca16f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09b5b31c7e7f15c7053c476ae0c2fd11839b7f5b82c4dea330764da42321c8333559df72273cdffbafe91bc9452a51a4bece945a2e6b3a8774af5fce409750fb'
|
7
|
+
data.tar.gz: 1743f21d2ad48858e8ebed88984fdf5cecb2ce5878ae0cbf32dbccc451175daa1d0f37c571efa100dadd94dcb169b17515bc691884d9583e00b40f57b45242ff
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,38 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [3.4.2] - 2020-2-5
|
8
|
+
[3.4.1]: https://github.com/shardlab/discordrb/releases/tag/v3.4.2
|
9
|
+
|
10
|
+
[View diff for this release.](https://github.com/shardlab/discordrb/compare/v3.4.1..v3.4.2)
|
11
|
+
|
12
|
+
### Summary
|
13
|
+
I failed to update rest-client dependencies properly, and discovered that you can't republish gem versions the hard way.
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
- `rest-client` has a requirement of `>= 2.0.0` on both `discordrb` and `discordrb-webhooks`
|
17
|
+
|
18
|
+
## [3.4.1] - 2020-2-4
|
19
|
+
[3.4.1]: https://github.com/shardlab/discordrb/releases/tag/v3.4.1
|
20
|
+
|
21
|
+
[View diff for this release.](https://github.com/shardlab/discordrb/compare/v3.4.0..v3.4.1)
|
22
|
+
|
23
|
+
### Summary
|
24
|
+
|
25
|
+
With 3.4.0, mistakes were made during the version bump leading to a bit of a dependency issue between `discordrb` and `discordrb-webhooks` (sorry!).
|
26
|
+
This micro bump fixes this, fixes a few other code issues, and adds a few minor features.
|
27
|
+
|
28
|
+
### Added
|
29
|
+
- Added support for `competing` activity types ([#21](https://github.com/shardlab/discordrb/pull/21), thanks @kaine119)
|
30
|
+
- Support for a callable command_does_not_exist_message ([#25](https://github.com/shardlab/discordrb/pull/25), thanks @kmcphillips)
|
31
|
+
|
32
|
+
### Fixed
|
33
|
+
- `Bot#send_temporary_message` now properly passes `message_reference` ([#17](https://github.com/shardlab/discordrb/pull/17) thanks @swarley)
|
34
|
+
- Rate limit precision is only supplied when the route requires headers ([#11](https://github.com/shardlab/discordrb/pull/11) thanks @dali546)
|
35
|
+
- Remove pointless conditional in `Invite` initializer ([#26](https://github.com/shardlab/discordrb/pull/26) thanks @swarley)
|
36
|
+
- All API methods link to their official documentation counterparts ([#12](https://github.com/shardlab/discordrb/pull/12) thanks @kaine119)
|
37
|
+
- Links to messages now work when a `guild_id` is not present in a non DM message. ([#27](https://github.com/shardlab/discordrb/pull/27) thanks @swarley)
|
38
|
+
|
7
39
|
## [3.4.0] - 2020-12-06
|
8
40
|
[3.4.0]: https://github.com/shardlab/discordrb/releases/tag/v3.3.0
|
9
41
|
|
data/discordrb.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency 'rest-client', '>= 2.0.0'
|
29
29
|
spec.add_dependency 'websocket-client-simple', '>= 0.3.0'
|
30
30
|
|
31
|
-
spec.add_dependency 'discordrb-webhooks', '~> 3.3
|
31
|
+
spec.add_dependency 'discordrb-webhooks', '~> 3.4.3'
|
32
32
|
|
33
33
|
spec.required_ruby_version = '>= 2.5'
|
34
34
|
|
@@ -331,6 +331,7 @@ module Discordrb::API::Channel
|
|
331
331
|
end
|
332
332
|
|
333
333
|
# Create an empty group channel.
|
334
|
+
# https://discord.com/developers/docs/resources/user#create-group-dm
|
334
335
|
def create_empty_group(token, bot_user_id)
|
335
336
|
Discordrb::API.request(
|
336
337
|
:users_uid_channels,
|
@@ -344,6 +345,7 @@ module Discordrb::API::Channel
|
|
344
345
|
end
|
345
346
|
|
346
347
|
# Create a group channel.
|
348
|
+
# https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
|
347
349
|
def create_group(token, pm_channel_id, user_id)
|
348
350
|
Discordrb::API.request(
|
349
351
|
:channels_cid_recipients_uid,
|
@@ -363,6 +365,7 @@ module Discordrb::API::Channel
|
|
363
365
|
end
|
364
366
|
|
365
367
|
# Add a user to a group channel.
|
368
|
+
# https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
|
366
369
|
def add_group_user(token, group_channel_id, user_id)
|
367
370
|
Discordrb::API.request(
|
368
371
|
:channels_cid_recipients_uid,
|
@@ -376,6 +379,7 @@ module Discordrb::API::Channel
|
|
376
379
|
end
|
377
380
|
|
378
381
|
# Remove a user from a group channel.
|
382
|
+
# https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient
|
379
383
|
def remove_group_user(token, group_channel_id, user_id)
|
380
384
|
Discordrb::API.request(
|
381
385
|
:channels_cid_recipients_uid,
|
@@ -388,6 +392,7 @@ module Discordrb::API::Channel
|
|
388
392
|
end
|
389
393
|
|
390
394
|
# Leave a group channel.
|
395
|
+
# https://discord.com/developers/docs/resources/channel#deleteclose-channel
|
391
396
|
def leave_group(token, group_channel_id)
|
392
397
|
Discordrb::API.request(
|
393
398
|
:channels_cid,
|
data/lib/discordrb/api/server.rb
CHANGED
@@ -46,6 +46,7 @@ module Discordrb::API::Server
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Transfer server ownership
|
49
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild
|
49
50
|
def transfer_ownership(token, server_id, user_id, reason = nil)
|
50
51
|
Discordrb::API.request(
|
51
52
|
:guilds_sid,
|
@@ -498,6 +499,7 @@ module Discordrb::API::Server
|
|
498
499
|
end
|
499
500
|
|
500
501
|
# Available voice regions for this server
|
502
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-voice-regions
|
501
503
|
def regions(token, server_id)
|
502
504
|
Discordrb::API.request(
|
503
505
|
:guilds_sid_regions,
|
data/lib/discordrb/api/user.rb
CHANGED
@@ -29,6 +29,7 @@ module Discordrb::API::User
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# Change the current bot's nickname on a server
|
32
|
+
# https://discord.com/developers/docs/resources/user#modify-current-user
|
32
33
|
def change_own_nickname(token, server_id, nick, reason = nil)
|
33
34
|
Discordrb::API.request(
|
34
35
|
:guilds_sid_members_me_nick,
|
data/lib/discordrb/api.rb
CHANGED
@@ -95,7 +95,7 @@ module Discordrb::API
|
|
95
95
|
attributes.last[:user_agent] = user_agent if attributes.last.is_a? Hash
|
96
96
|
|
97
97
|
# Specify RateLimit precision
|
98
|
-
attributes.last[:x_ratelimit_precision] = 'millisecond'
|
98
|
+
attributes.last[:x_ratelimit_precision] = 'millisecond' if attributes.last.is_a?(Hash)
|
99
99
|
|
100
100
|
# The most recent Discord rate limit requirements require the support of major parameters, where a particular route
|
101
101
|
# and major parameter combination (*not* the HTTP method) uniquely identifies a RL bucket.
|
data/lib/discordrb/bot.rb
CHANGED
@@ -385,11 +385,12 @@ module Discordrb
|
|
385
385
|
# @param embed [Hash, Discordrb::Webhooks::Embed, nil] The rich embed to append to this message.
|
386
386
|
# @param attachments [Array<File>] Files that can be referenced in embeds via `attachment://file.png`
|
387
387
|
# @param allowed_mentions [Hash, Discordrb::AllowedMentions, false, nil] Mentions that are allowed to ping on this message. `false` disables all pings
|
388
|
-
|
388
|
+
# @param message_reference [Message, String, Integer, nil] The message, or message ID, to reply to if any.
|
389
|
+
def send_temporary_message(channel, content, timeout, tts = false, embed = nil, attachments = nil, allowed_mentions = nil, message_reference = nil)
|
389
390
|
Thread.new do
|
390
391
|
Thread.current[:discordrb_name] = "#{@current_thread}-temp-msg"
|
391
392
|
|
392
|
-
message = send_message(channel, content, tts, embed, attachments, allowed_mentions)
|
393
|
+
message = send_message(channel, content, tts, embed, attachments, allowed_mentions, message_reference)
|
393
394
|
sleep(timeout)
|
394
395
|
message.delete
|
395
396
|
end
|
@@ -504,7 +505,8 @@ module Discordrb
|
|
504
505
|
# @param url [String, nil] The Twitch URL to display as a stream. nil for no stream.
|
505
506
|
# @param since [Integer] When this status was set.
|
506
507
|
# @param afk [true, false] Whether the bot is AFK.
|
507
|
-
# @param activity_type [Integer] The type of activity status to display.
|
508
|
+
# @param activity_type [Integer] The type of activity status to display.
|
509
|
+
# Can be 0 (Playing), 1 (Streaming), 2 (Listening), 3 (Watching), or 5 (Competing).
|
508
510
|
# @see Gateway#send_status_update
|
509
511
|
def update_status(status, activity, url, since = 0, afk = false, activity_type = 0)
|
510
512
|
gateway_check
|
@@ -557,6 +559,14 @@ module Discordrb
|
|
557
559
|
name
|
558
560
|
end
|
559
561
|
|
562
|
+
# Sets the currently competing status to the specified name.
|
563
|
+
# @param name [String] The name of the game to be competing in.
|
564
|
+
# @return [String] The game that is being competed in now.
|
565
|
+
def competing=(name)
|
566
|
+
gateway_check
|
567
|
+
update_status(@status, name, nil, nil, nil, 5)
|
568
|
+
end
|
569
|
+
|
560
570
|
# Sets status to online.
|
561
571
|
def online
|
562
572
|
gateway_check
|
@@ -44,9 +44,10 @@ module Discordrb::Commands
|
|
44
44
|
# @option attributes [Symbol, Array<Symbol>, false] :help_command The name of the command that displays info for
|
45
45
|
# other commands. Use an array if you want to have aliases. Default is "help". If none should be created, use
|
46
46
|
# `false` as the value.
|
47
|
-
# @option attributes [String] :command_doesnt_exist_message The message that should be displayed if a user attempts
|
47
|
+
# @option attributes [String, #call] :command_doesnt_exist_message The message that should be displayed if a user attempts
|
48
48
|
# to use a command that does not exist. If none is specified, no message will be displayed. In the message, you
|
49
|
-
# can use the string '%command%' that will be replaced with the name of the command.
|
49
|
+
# can use the string '%command%' that will be replaced with the name of the command. Anything responding to call
|
50
|
+
# such as a proc will be called with the event, and is expected to return a String or nil.
|
50
51
|
# @option attributes [String] :no_permission_message The message to be displayed when `NoPermission` error is raised.
|
51
52
|
# @option attributes [true, false] :spaces_allowed Whether spaces are allowed to occur between the prefix and the
|
52
53
|
# command. Default is false.
|
@@ -217,7 +218,11 @@ module Discordrb::Commands
|
|
217
218
|
(command && !command.attributes[:channels].nil?)
|
218
219
|
|
219
220
|
unless command
|
220
|
-
|
221
|
+
if @attributes[:command_doesnt_exist_message]
|
222
|
+
message = @attributes[:command_doesnt_exist_message]
|
223
|
+
message = message.call(event) if message.respond_to?(:call)
|
224
|
+
event.respond message.gsub('%command%', name.to_s) if message
|
225
|
+
end
|
221
226
|
return
|
222
227
|
end
|
223
228
|
return unless !check_permissions || channels?(event.channel, command.attributes[:channels])
|
@@ -17,7 +17,7 @@ module Discordrb
|
|
17
17
|
# @return [String] the activity's name
|
18
18
|
attr_reader :name
|
19
19
|
|
20
|
-
# @return [Integer, nil] activity type. Can be {GAME}, {STREAMING}, {LISTENING}, {CUSTOM}
|
20
|
+
# @return [Integer, nil] activity type. Can be {GAME}, {STREAMING}, {LISTENING}, {CUSTOM}, or {COMPETING}
|
21
21
|
attr_reader :type
|
22
22
|
|
23
23
|
# @return [String, nil] stream URL, when the activity type is {STREAMING}
|
@@ -67,6 +67,8 @@ module Discordrb
|
|
67
67
|
WATCHING = 3
|
68
68
|
# Type indicating the activity is a custom status
|
69
69
|
CUSTOM = 4
|
70
|
+
# Type indicating the activity is for a competitive game
|
71
|
+
COMPETING = 5
|
70
72
|
|
71
73
|
# @!visibility private
|
72
74
|
def initialize(data, bot)
|
@@ -260,5 +262,10 @@ module Discordrb
|
|
260
262
|
def custom_status
|
261
263
|
@activities.select { |act| act.type == Activity::CUSTOM }
|
262
264
|
end
|
265
|
+
|
266
|
+
# @return [Array<Activity>] all activities of type {Activity::COMPETING}
|
267
|
+
def competing
|
268
|
+
@activities.select { |act| act.type == Activity::COMPETING }
|
269
|
+
end
|
263
270
|
end
|
264
271
|
end
|
@@ -83,7 +83,7 @@ module Discordrb
|
|
83
83
|
@referenced_message = Message.new(data['referenced_message'], bot) if data['referenced_message']
|
84
84
|
@message_reference = data['message_reference']
|
85
85
|
|
86
|
-
@server =
|
86
|
+
@server = @channel.server
|
87
87
|
|
88
88
|
@author = if data['author']
|
89
89
|
if data['author']['discriminator'] == ZERO_DISCRIM
|
data/lib/discordrb/version.rb
CHANGED
@@ -77,7 +77,7 @@ module Discordrb::Voice
|
|
77
77
|
# @param options [String] ffmpeg options to pass after the -i flag
|
78
78
|
# @return [IO] the audio, encoded as s16le PCM
|
79
79
|
def encode_file(file, options = '')
|
80
|
-
command =
|
80
|
+
command = ffmpeg_command(input: file, options: options)
|
81
81
|
IO.popen(command)
|
82
82
|
end
|
83
83
|
|
@@ -87,14 +87,23 @@ module Discordrb::Voice
|
|
87
87
|
# @param options [String] ffmpeg options to pass after the -i flag
|
88
88
|
# @return [IO] the audio, encoded as s16le PCM
|
89
89
|
def encode_io(io, options = '')
|
90
|
-
command =
|
90
|
+
command = ffmpeg_command(options: options)
|
91
91
|
IO.popen(command, in: io)
|
92
92
|
end
|
93
93
|
|
94
94
|
private
|
95
95
|
|
96
|
-
def ffmpeg_command
|
97
|
-
|
96
|
+
def ffmpeg_command(input: '-', options: null)
|
97
|
+
[
|
98
|
+
@use_avconv ? 'avconv' : 'ffmpeg',
|
99
|
+
'-loglevel', '0',
|
100
|
+
'-i', input,
|
101
|
+
'-f', 's16le',
|
102
|
+
'-ar', '48000',
|
103
|
+
'-ac', '2',
|
104
|
+
'pipe:1',
|
105
|
+
filter_volume_argument,
|
106
|
+
].concat(options.split).reject {|segment| segment.nil? || segment == '' }
|
98
107
|
end
|
99
108
|
|
100
109
|
def filter_volume_argument
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discordrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- meew0
|
8
8
|
- swarley
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 3.3
|
76
|
+
version: 3.4.3
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 3.3
|
83
|
+
version: 3.4.3
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: bundler
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -321,7 +321,7 @@ licenses:
|
|
321
321
|
- MIT
|
322
322
|
metadata:
|
323
323
|
changelog_uri: https://github.com/shardlab/discordrb/blob/master/CHANGELOG.md
|
324
|
-
post_install_message:
|
324
|
+
post_install_message:
|
325
325
|
rdoc_options: []
|
326
326
|
require_paths:
|
327
327
|
- lib
|
@@ -336,8 +336,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
336
|
- !ruby/object:Gem::Version
|
337
337
|
version: '0'
|
338
338
|
requirements: []
|
339
|
-
rubygems_version: 3.
|
340
|
-
signing_key:
|
339
|
+
rubygems_version: 3.3.3
|
340
|
+
signing_key:
|
341
341
|
specification_version: 4
|
342
342
|
summary: Discord API for Ruby
|
343
343
|
test_files: []
|