discordrb-webhooks 3.2.0.1 → 3.3.0

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
- SHA1:
3
- metadata.gz: b208128ffa00e95f740a4b3e57d633943e2c5982
4
- data.tar.gz: b86a4055766282919b62ee7417f527c17befdd1c
2
+ SHA256:
3
+ metadata.gz: 6d7d23650de6d0fc87de7502249ce43f9b7ae643a5b83672bb083399f6db8f24
4
+ data.tar.gz: a315a00e995b894befd2e06c6db5467eb0613003e14b504577f452fff63d6219
5
5
  SHA512:
6
- metadata.gz: '09f60c087fcb4e1a5b432e4a9ca84a6398e9649e86635b4307dc9134d89cb4204978bfc7302780b4127ae6b45e26aa572d393d13cd71bbcdb4d96f94b5f917cb'
7
- data.tar.gz: 1bf10b016e9a3bcc26c1502f99710d960dbf87c33df23fa452087dcf14aac10ebb1c74ab5a96778835034f5b0f64c5b2aafdf829eb9af841a0c34800333cade6
6
+ metadata.gz: 3b818ca44c09515634ba48d7a52473026ad659f1bcff8ca87ceeb78a2d6ef6fa16b2334083811feacaa5586efc5843a0c243547105f74f9bdc2791afbf7b7057
7
+ data.tar.gz: 24efb99480663061578d386c11e9aaffd141c9801851949766640e7b4714ae74f10a209d9bafe3e42504ae782d61d4cdb1f5fd3202da6c48eb0c766fc25534a0
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'discordrb/webhooks/embeds'
2
4
 
3
5
  module Discordrb::Webhooks
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rest-client'
2
4
  require 'json'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Discordrb::Webhooks
2
4
  # An embed is a multipart-style attachment to a webhook message that can have a variety of different purposes and
3
5
  # appearances.
@@ -8,7 +10,7 @@ module Discordrb::Webhooks
8
10
  @description = description
9
11
  @url = url
10
12
  @timestamp = timestamp
11
- @colour = colour || color
13
+ self.colour = colour || color
12
14
  @footer = footer
13
15
  @image = image
14
16
  @thumbnail = thumbnail
@@ -18,31 +20,29 @@ module Discordrb::Webhooks
18
20
  @fields = fields
19
21
  end
20
22
 
21
- # The title of this embed that will be displayed above everything else.
22
- # @return [String]
23
+ # @return [String, nil] title of the embed that will be displayed above everything else.
23
24
  attr_accessor :title
24
25
 
25
- # The description for this embed.
26
- # @return [String]
26
+ # @return [String, nil] description for this embed
27
27
  attr_accessor :description
28
28
 
29
- # The URL the title should point to.
30
- # @return [String]
29
+ # @return [String, nil] URL the title should point to
31
30
  attr_accessor :url
32
31
 
33
- # The timestamp for this embed. Will be displayed just below the title.
34
- # @return [Time]
32
+ # @return [Time, nil] timestamp for this embed. Will be displayed just below the title.
35
33
  attr_accessor :timestamp
36
34
 
37
- # @return [Integer] the colour of the bar to the side, in decimal form.
35
+ # @return [Integer, nil] the colour of the bar to the side, in decimal form
38
36
  attr_reader :colour
39
37
  alias_method :color, :colour
40
38
 
41
39
  # Sets the colour of the bar to the side of the embed to something new.
42
- # @param value [Integer, String, {Integer, Integer, Integer}] The colour in decimal, hexadecimal, or R/G/B decimal
40
+ # @param value [Integer, String, {Integer, Integer, Integer}, #to_i, nil] The colour in decimal, hexadecimal, R/G/B decimal, or nil to clear the embeds colour
43
41
  # form.
44
42
  def colour=(value)
45
- if value.is_a? Integer
43
+ if value.nil?
44
+ @colour = nil
45
+ elsif value.is_a? Integer
46
46
  raise ArgumentError, 'Embed colour must be 24-bit!' if value >= 16_777_216
47
47
  @colour = value
48
48
  elsif value.is_a? String
@@ -50,36 +50,34 @@ module Discordrb::Webhooks
50
50
  elsif value.is_a? Array
51
51
  raise ArgumentError, 'Colour tuple must have three values!' if value.length != 3
52
52
  self.colour = value[0] << 16 | value[1] << 8 | value[2]
53
+ else
54
+ self.colour = value.to_i
53
55
  end
54
56
  end
55
57
 
56
58
  alias_method :color=, :colour=
57
59
 
58
- # The footer for this embed.
59
60
  # @example Add a footer to an embed
60
61
  # embed.footer = Discordrb::Webhooks::EmbedFooter.new(text: 'Hello', icon_url: 'https://i.imgur.com/j69wMDu.jpg')
61
- # @return [EmbedFooter]
62
+ # @return [EmbedFooter, nil] footer for this embed
62
63
  attr_accessor :footer
63
64
 
64
- # The image for this embed.
65
65
  # @see EmbedImage
66
66
  # @example Add a image to an embed
67
67
  # embed.image = Discordrb::Webhooks::EmbedImage.new(url: 'https://i.imgur.com/PcMltU7.jpg')
68
- # @return [EmbedImage]
68
+ # @return [EmbedImage, nil] image for this embed
69
69
  attr_accessor :image
70
70
 
71
- # The thumbnail for this embed.
72
71
  # @see EmbedThumbnail
73
72
  # @example Add a thumbnail to an embed
74
73
  # embed.thumbnail = Discordrb::Webhooks::EmbedThumbnail.new(url: 'https://i.imgur.com/xTG3a1I.jpg')
75
- # @return [EmbedThumbnail]
74
+ # @return [EmbedThumbnail, nil] thumbnail for this embed
76
75
  attr_accessor :thumbnail
77
76
 
78
- # The author for this embed.
79
77
  # @see EmbedAuthor
80
78
  # @example Add a author to an embed
81
79
  # embed.author = Discordrb::Webhooks::EmbedAuthor.new(name: 'meew0', url: 'https://github.com/meew0', icon_url: 'https://avatars2.githubusercontent.com/u/3662915?v=3&s=466')
82
- # @return [EmbedAuthor]
80
+ # @return [EmbedAuthor, nil] author for this embed
83
81
  attr_accessor :author
84
82
 
85
83
  # Add a field object to this embed.
@@ -100,7 +98,7 @@ module Discordrb::Webhooks
100
98
  end
101
99
 
102
100
  # @return [Array<EmbedField>] the fields attached to this embed.
103
- attr_reader :fields
101
+ attr_accessor :fields
104
102
 
105
103
  # @return [Hash] a hash representation of this embed, to be converted to JSON.
106
104
  def to_hash
@@ -124,6 +122,12 @@ module Discordrb::Webhooks
124
122
  # An embed's footer will be displayed at the very bottom of an embed, together with the timestamp. An icon URL can be
125
123
  # set together with some text to be displayed.
126
124
  class EmbedFooter
125
+ # @return [String, nil] text to be displayed in the footer
126
+ attr_accessor :text
127
+
128
+ # @return [String, nil] URL to an icon to be showed alongside the text
129
+ attr_accessor :icon_url
130
+
127
131
  # Creates a new footer object.
128
132
  # @param text [String, nil] The text to be displayed in the footer.
129
133
  # @param icon_url [String, nil] The URL to an icon to be showed alongside the text.
@@ -143,6 +147,9 @@ module Discordrb::Webhooks
143
147
 
144
148
  # An embed's image will be displayed at the bottom, in large format. It will replace a footer icon URL if one is set.
145
149
  class EmbedImage
150
+ # @return [String, nil] URL of the image
151
+ attr_accessor :url
152
+
146
153
  # Creates a new image object.
147
154
  # @param url [String, nil] The URL of the image.
148
155
  def initialize(url: nil)
@@ -160,6 +167,9 @@ module Discordrb::Webhooks
160
167
  # An embed's thumbnail will be displayed at the right of the message, next to the description and fields. When clicked
161
168
  # it will point to the embed URL.
162
169
  class EmbedThumbnail
170
+ # @return [String, nil] URL of the thumbnail
171
+ attr_accessor :url
172
+
163
173
  # Creates a new thumbnail object.
164
174
  # @param url [String, nil] The URL of the thumbnail.
165
175
  def initialize(url: nil)
@@ -176,6 +186,15 @@ module Discordrb::Webhooks
176
186
 
177
187
  # An embed's author will be shown at the top to indicate who "authored" the particular event the webhook was sent for.
178
188
  class EmbedAuthor
189
+ # @return [String, nil] name of the author
190
+ attr_accessor :name
191
+
192
+ # @return [String, nil] URL the name should link to
193
+ attr_accessor :url
194
+
195
+ # @return [String, nil] URL of the icon to be displayed next to the author
196
+ attr_accessor :icon_url
197
+
179
198
  # Creates a new author object.
180
199
  # @param name [String, nil] The name of the author.
181
200
  # @param url [String, nil] The URL the name should link to.
@@ -198,11 +217,20 @@ module Discordrb::Webhooks
198
217
 
199
218
  # A field is a small block of text with a header that can be relatively freely layouted with other fields.
200
219
  class EmbedField
220
+ # @return [String, nil] name of the field, displayed in bold at the top of the field.
221
+ attr_accessor :name
222
+
223
+ # @return [String, nil] value of the field, displayed in normal text below the name.
224
+ attr_accessor :value
225
+
226
+ # @return [true, false] whether the field should be displayed inline with other fields.
227
+ attr_accessor :inline
228
+
201
229
  # Creates a new field object.
202
- # @param name [String, nil] The name of the field, displayed in bold at the top.
230
+ # @param name [String, nil] The name of the field, displayed in bold at the top of the field.
203
231
  # @param value [String, nil] The value of the field, displayed in normal text below the name.
204
- # @param inline [true, false] Whether the field should be displayed in-line with other fields.
205
- def initialize(name: nil, value: nil, inline: nil)
232
+ # @param inline [true, false] Whether the field should be displayed inline with other fields.
233
+ def initialize(name: nil, value: nil, inline: false)
206
234
  @name = name
207
235
  @value = value
208
236
  @inline = inline
@@ -4,6 +4,6 @@
4
4
  module Discordrb
5
5
  module Webhooks
6
6
  # The current version of discordrb-webhooks.
7
- VERSION = '3.2.0.1'.freeze
7
+ VERSION = '3.3.0'.freeze
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discordrb-webhooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - meew0
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-29 00:00:00.000000000 Z
11
+ date: 2018-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.1.0.rc1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 2.1.0.rc1
27
27
  description: A client for Discord's webhooks to fit alongside [discordrb](https://rubygems.org/gems/discordrb).
28
28
  email:
29
29
  - ''
@@ -56,9 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  version: '0'
57
57
  requirements: []
58
58
  rubyforge_project:
59
- rubygems_version: 2.6.10
59
+ rubygems_version: 2.7.7
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Webhook client for discordrb
63
63
  test_files: []
64
- has_rdoc: