discorb 0.18.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build_version.yml +2 -2
- data/.rubocop.yml +12 -75
- data/Changelog.md +25 -0
- data/Gemfile +4 -4
- data/README.md +2 -1
- data/Rakefile +482 -459
- data/Steepfile +8 -6
- data/docs/application_command.md +1 -0
- data/docs/events.md +2 -2
- data/docs/voice_events.md +6 -6
- data/lib/discorb/allowed_mentions.rb +68 -72
- data/lib/discorb/app_command/command.rb +466 -394
- data/lib/discorb/app_command/common.rb +65 -25
- data/lib/discorb/app_command/handler.rb +304 -265
- data/lib/discorb/app_command.rb +5 -5
- data/lib/discorb/application.rb +198 -197
- data/lib/discorb/asset.rb +101 -101
- data/lib/discorb/attachment.rb +134 -119
- data/lib/discorb/audit_logs.rb +412 -385
- data/lib/discorb/automod.rb +279 -269
- data/lib/discorb/channel/base.rb +107 -108
- data/lib/discorb/channel/category.rb +32 -32
- data/lib/discorb/channel/container.rb +44 -44
- data/lib/discorb/channel/dm.rb +26 -28
- data/lib/discorb/channel/guild.rb +311 -246
- data/lib/discorb/channel/stage.rb +156 -140
- data/lib/discorb/channel/text.rb +430 -336
- data/lib/discorb/channel/thread.rb +374 -325
- data/lib/discorb/channel/voice.rb +85 -79
- data/lib/discorb/channel.rb +5 -5
- data/lib/discorb/client.rb +635 -623
- data/lib/discorb/color.rb +178 -182
- data/lib/discorb/common.rb +168 -164
- data/lib/discorb/components/button.rb +107 -106
- data/lib/discorb/components/select_menu.rb +157 -145
- data/lib/discorb/components/text_input.rb +103 -106
- data/lib/discorb/components.rb +68 -66
- data/lib/discorb/dictionary.rb +135 -135
- data/lib/discorb/embed.rb +404 -398
- data/lib/discorb/emoji.rb +309 -302
- data/lib/discorb/emoji_table.rb +16099 -8857
- data/lib/discorb/error.rb +131 -131
- data/lib/discorb/event.rb +360 -314
- data/lib/discorb/event_handler.rb +39 -39
- data/lib/discorb/exe/about.rb +17 -17
- data/lib/discorb/exe/irb.rb +72 -67
- data/lib/discorb/exe/new.rb +323 -315
- data/lib/discorb/exe/run.rb +69 -68
- data/lib/discorb/exe/setup.rb +57 -55
- data/lib/discorb/exe/show.rb +12 -12
- data/lib/discorb/extend.rb +25 -45
- data/lib/discorb/extension.rb +89 -83
- data/lib/discorb/flag.rb +126 -128
- data/lib/discorb/gateway.rb +984 -794
- data/lib/discorb/gateway_events.rb +670 -638
- data/lib/discorb/gateway_requests.rb +45 -48
- data/lib/discorb/guild.rb +2115 -1626
- data/lib/discorb/guild_template.rb +280 -241
- data/lib/discorb/http.rb +247 -232
- data/lib/discorb/image.rb +42 -42
- data/lib/discorb/integration.rb +169 -161
- data/lib/discorb/intents.rb +161 -163
- data/lib/discorb/interaction/autocomplete.rb +76 -62
- data/lib/discorb/interaction/command.rb +279 -224
- data/lib/discorb/interaction/components.rb +114 -104
- data/lib/discorb/interaction/modal.rb +36 -32
- data/lib/discorb/interaction/response.rb +379 -330
- data/lib/discorb/interaction/root.rb +271 -118
- data/lib/discorb/interaction.rb +5 -5
- data/lib/discorb/invite.rb +154 -153
- data/lib/discorb/member.rb +344 -311
- data/lib/discorb/message.rb +615 -544
- data/lib/discorb/message_meta.rb +197 -186
- data/lib/discorb/modules.rb +371 -290
- data/lib/discorb/permission.rb +305 -289
- data/lib/discorb/presence.rb +352 -346
- data/lib/discorb/rate_limit.rb +81 -76
- data/lib/discorb/reaction.rb +55 -54
- data/lib/discorb/role.rb +272 -240
- data/lib/discorb/shard.rb +76 -74
- data/lib/discorb/sticker.rb +193 -171
- data/lib/discorb/user.rb +205 -188
- data/lib/discorb/utils/colored_puts.rb +16 -16
- data/lib/discorb/utils.rb +12 -16
- data/lib/discorb/voice_state.rb +305 -281
- data/lib/discorb/webhook.rb +537 -507
- data/lib/discorb.rb +62 -56
- data/sig/discorb/activity.rbs +1 -0
- data/sig/discorb/allowed_mentions.rbs +1 -0
- data/sig/discorb/app_command/base.rbs +7 -1
- data/sig/discorb/application.rbs +6 -0
- data/sig/discorb/asset.rbs +2 -0
- data/sig/discorb/attachment.rbs +8 -0
- data/sig/discorb/audit_log.rbs +7 -0
- data/sig/discorb/automod.rbs +32 -6
- data/sig/discorb/avatar.rbs +1 -0
- data/sig/discorb/channel/base.rbs +8 -1
- data/sig/discorb/channel/category.rbs +1 -0
- data/sig/discorb/channel/container.rbs +4 -0
- data/sig/discorb/channel/stage.rbs +4 -0
- data/sig/discorb/channel/text.rbs +2 -2
- data/sig/discorb/channel/thread.rbs +11 -0
- data/sig/discorb/channel/voice.rbs +2 -0
- data/sig/discorb/client.rbs +21 -20
- data/sig/discorb/color.rbs +6 -0
- data/sig/discorb/component/base.rbs +1 -0
- data/sig/discorb/component/button.rbs +2 -0
- data/sig/discorb/component/select_menu.rbs +4 -0
- data/sig/discorb/component/text_input.rbs +1 -0
- data/sig/discorb/custom_emoji.rbs +5 -1
- data/sig/discorb/dictionary.rbs +2 -0
- data/sig/discorb/discord_model.rbs +2 -0
- data/sig/discorb/embed.rbs +7 -0
- data/sig/discorb/emoji.rbs +1 -0
- data/sig/discorb/event_handler.rbs +2 -1
- data/sig/discorb/extension.rbs +13 -12
- data/sig/discorb/flag.rbs +2 -0
- data/sig/discorb/gateway.rbs +5 -0
- data/sig/discorb/guild.rbs +8 -4
- data/sig/discorb/guild_template.rbs +1 -1
- data/sig/discorb/http.rbs +4 -1
- data/sig/discorb/image.rbs +2 -0
- data/sig/discorb/integration.rbs +1 -1
- data/sig/discorb/intents.rbs +4 -3
- data/sig/discorb/interaction/base.rbs +36 -0
- data/sig/discorb/interaction/message_component.rbs +1 -2
- data/sig/discorb/interaction/modal.rbs +1 -2
- data/sig/discorb/interaction/responder.rbs +49 -49
- data/sig/discorb/invite.rbs +1 -1
- data/sig/discorb/member.rbs +2 -0
- data/sig/discorb/message.rbs +8 -1
- data/sig/discorb/messageable.rbs +1 -4
- data/sig/discorb/partial_emoji.rbs +3 -0
- data/sig/discorb/permissions.rbs +7 -0
- data/sig/discorb/presence.rbs +2 -0
- data/sig/discorb/reaction.rbs +5 -1
- data/sig/discorb/role.rbs +7 -1
- data/sig/discorb/scheduled_event.rbs +2 -1
- data/sig/discorb/shard.rbs +2 -1
- data/sig/discorb/snowflake.rbs +2 -0
- data/sig/discorb/stage_instance.rbs +9 -3
- data/sig/discorb/sticker.rbs +1 -1
- data/sig/discorb/unicode_emoji.rbs +4 -0
- data/sig/discorb/user.rbs +24 -20
- data/sig/discorb/webhook.rbs +17 -6
- data/sig/discorb/welcome_screen.rbs +1 -0
- data/sig/override.rbs +2 -0
- metadata +3 -3
data/lib/discorb/sticker.rb
CHANGED
@@ -1,171 +1,193 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Discorb
|
4
|
-
#
|
5
|
-
# Represents a sticker.
|
6
|
-
#
|
7
|
-
class Sticker < DiscordModel
|
8
|
-
# @return [Discorb::Snowflake] The ID of the sticker.
|
9
|
-
attr_reader :id
|
10
|
-
# @return [String] The name of the sticker.
|
11
|
-
attr_reader :name
|
12
|
-
# @return [Array<String>] The tags of the sticker.
|
13
|
-
attr_reader :tags
|
14
|
-
# @return [:official, :guild] The type of sticker.
|
15
|
-
attr_reader :type
|
16
|
-
# @return [:png, :apng, :lottie] The format of the sticker.
|
17
|
-
attr_reader :format
|
18
|
-
# @return [String] The URL of the sticker.
|
19
|
-
attr_reader :description
|
20
|
-
# @return [Discorb::Snowflake] The ID of the sticker pack.
|
21
|
-
attr_reader :pack_id
|
22
|
-
# @return [Integer] The sort value of the sticker.
|
23
|
-
attr_reader :sort_value
|
24
|
-
# @return [Discorb::Snowflake] The ID of the guild the sticker is in.
|
25
|
-
attr_reader :guild_id
|
26
|
-
# @return [Discorb::User] The user who created the sticker.
|
27
|
-
attr_reader :user
|
28
|
-
# @return [Boolean] Whether the sticker is available.
|
29
|
-
attr_reader :available
|
30
|
-
alias available? available
|
31
|
-
|
32
|
-
# @private
|
33
|
-
# @return [{Integer => Symbol}] The mapping of sticker types.
|
34
|
-
STICKER_TYPE = {
|
35
|
-
|
36
|
-
|
37
|
-
}.
|
38
|
-
|
39
|
-
#
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
#
|
64
|
-
#
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
# @
|
74
|
-
#
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
payload =
|
85
|
-
|
86
|
-
payload[:
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
# @
|
135
|
-
|
136
|
-
# @
|
137
|
-
|
138
|
-
#
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Discorb
|
4
|
+
#
|
5
|
+
# Represents a sticker.
|
6
|
+
#
|
7
|
+
class Sticker < DiscordModel
|
8
|
+
# @return [Discorb::Snowflake] The ID of the sticker.
|
9
|
+
attr_reader :id
|
10
|
+
# @return [String] The name of the sticker.
|
11
|
+
attr_reader :name
|
12
|
+
# @return [Array<String>] The tags of the sticker.
|
13
|
+
attr_reader :tags
|
14
|
+
# @return [:official, :guild] The type of sticker.
|
15
|
+
attr_reader :type
|
16
|
+
# @return [:png, :apng, :lottie] The format of the sticker.
|
17
|
+
attr_reader :format
|
18
|
+
# @return [String] The URL of the sticker.
|
19
|
+
attr_reader :description
|
20
|
+
# @return [Discorb::Snowflake] The ID of the sticker pack.
|
21
|
+
attr_reader :pack_id
|
22
|
+
# @return [Integer] The sort value of the sticker.
|
23
|
+
attr_reader :sort_value
|
24
|
+
# @return [Discorb::Snowflake] The ID of the guild the sticker is in.
|
25
|
+
attr_reader :guild_id
|
26
|
+
# @return [Discorb::User] The user who created the sticker.
|
27
|
+
attr_reader :user
|
28
|
+
# @return [Boolean] Whether the sticker is available.
|
29
|
+
attr_reader :available
|
30
|
+
alias available? available
|
31
|
+
|
32
|
+
# @private
|
33
|
+
# @return [{Integer => Symbol}] The mapping of sticker types.
|
34
|
+
STICKER_TYPE = { 1 => :official, 2 => :guild }.freeze
|
35
|
+
|
36
|
+
# @private
|
37
|
+
# @return [{Integer => Symbol}] The mapping of sticker format.
|
38
|
+
STICKER_FORMAT = { 1 => :png, 2 => :apng, 3 => :lottie }.freeze
|
39
|
+
#
|
40
|
+
# Initialize a new sticker.
|
41
|
+
# @private
|
42
|
+
#
|
43
|
+
# @param [Discorb::Client] client The client.
|
44
|
+
# @param [Hash] data The sticker data.
|
45
|
+
#
|
46
|
+
def initialize(client, data)
|
47
|
+
@client = client
|
48
|
+
_set_data(data)
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Represents a sticker of guilds.
|
53
|
+
#
|
54
|
+
class GuildSticker < Sticker
|
55
|
+
# @!attribute [r] guild
|
56
|
+
# @macro client_cache
|
57
|
+
# @return [Discorb::Guild] The guild the sticker is in.
|
58
|
+
|
59
|
+
def guild
|
60
|
+
@client.guilds[@guild_id]
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Edits the sticker.
|
65
|
+
# @async
|
66
|
+
# @macro edit
|
67
|
+
#
|
68
|
+
# @param [String] name The new name of the sticker.
|
69
|
+
# @param [String] description The new description of the sticker.
|
70
|
+
# @param [Discorb::Emoji] tag The new tags of the sticker.
|
71
|
+
# @param [String] reason The reason for the edit.
|
72
|
+
#
|
73
|
+
# @return [Async::Task<void>] The task.
|
74
|
+
#
|
75
|
+
def edit(
|
76
|
+
name: Discorb::Unset,
|
77
|
+
description: Discorb::Unset,
|
78
|
+
tag: Discorb::Unset,
|
79
|
+
reason: Discorb::Unset
|
80
|
+
)
|
81
|
+
Async do
|
82
|
+
payload = {}
|
83
|
+
payload[:name] = name unless name == Discorb::Unset
|
84
|
+
payload[:description] = description unless description ==
|
85
|
+
Discorb::Unset
|
86
|
+
payload[:tags] = tag.name unless tag == Discorb::Unset
|
87
|
+
@client
|
88
|
+
.http
|
89
|
+
.request(
|
90
|
+
Route.new(
|
91
|
+
"/guilds/#{@guild_id}/stickers/#{@id}",
|
92
|
+
"//guilds/:guild_id/stickers/:sticker_id",
|
93
|
+
:patch
|
94
|
+
),
|
95
|
+
payload,
|
96
|
+
audit_log_reason: reason
|
97
|
+
)
|
98
|
+
.wait
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
alias modify edit
|
103
|
+
|
104
|
+
#
|
105
|
+
# Deletes the sticker.
|
106
|
+
# @async
|
107
|
+
#
|
108
|
+
# @param [String] reason The reason for the deletion.
|
109
|
+
#
|
110
|
+
def delete(reason: nil)
|
111
|
+
Async do
|
112
|
+
@client
|
113
|
+
.http
|
114
|
+
.request(
|
115
|
+
Route.new(
|
116
|
+
"/guilds/#{@guild_id}/stickers/#{@id}",
|
117
|
+
"//guilds/:guild_id/stickers/:sticker_id",
|
118
|
+
:delete
|
119
|
+
),
|
120
|
+
{},
|
121
|
+
audit_log_reason: reason
|
122
|
+
)
|
123
|
+
.wait
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
alias destroy delete
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# Represents a sticker pack.
|
132
|
+
#
|
133
|
+
class Pack < DiscordModel
|
134
|
+
# @return [Discorb::Snowflake] The ID of the sticker pack.
|
135
|
+
attr_reader :id
|
136
|
+
# @return [String] The name of the sticker pack.
|
137
|
+
attr_reader :name
|
138
|
+
# @return [Discorb::Snowflake] The cover sticker of the pack.
|
139
|
+
attr_reader :cover_sticker_id
|
140
|
+
# @return [String] The description of the pack.
|
141
|
+
attr_reader :description
|
142
|
+
# @return [Array<Discorb::Sticker>] The stickers in the pack.
|
143
|
+
attr_reader :stickers
|
144
|
+
# @return [Discorb::Asset] The banner of the pack.
|
145
|
+
attr_reader :banner
|
146
|
+
|
147
|
+
#
|
148
|
+
# Initialize a new sticker pack.
|
149
|
+
# @private
|
150
|
+
#
|
151
|
+
# @param [Discorb::Client] client The client.
|
152
|
+
# @param [Hash] data The sticker pack data.
|
153
|
+
#
|
154
|
+
def initialize(client, data)
|
155
|
+
@client = client
|
156
|
+
@id = Snowflake.new(data[:id])
|
157
|
+
@name = data[:name]
|
158
|
+
@sku_id = Snowflake.new(data[:sku_id])
|
159
|
+
@cover_sticker_id = Snowflake.new(data[:cover_sticker_id])
|
160
|
+
@description = data[:description]
|
161
|
+
@banner_asset_id = Snowflake.new(data[:banner_asset_id])
|
162
|
+
@banner =
|
163
|
+
Asset.new(
|
164
|
+
self,
|
165
|
+
data[:banner_asset_id],
|
166
|
+
path: "app-assets/710982414301790216/store"
|
167
|
+
)
|
168
|
+
@stickers = data[:stickers].map { |s| Sticker.new(@client, s) }
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
private
|
173
|
+
|
174
|
+
def _set_data(data)
|
175
|
+
@id = Snowflake.new(data[:id])
|
176
|
+
@name = data[:name]
|
177
|
+
@tags = data[:tags].split(",")
|
178
|
+
@type = STICKER_TYPE[data[:type]]
|
179
|
+
@format = STICKER_FORMAT[data[:format]]
|
180
|
+
@description = data[:description]
|
181
|
+
@available = data[:available]
|
182
|
+
if @type == :official
|
183
|
+
@pack_id = Snowflake.new(data[:guild_id])
|
184
|
+
@sort_value = data[:sort_value]
|
185
|
+
else
|
186
|
+
@guild_id = Snowflake.new(data[:guild_id])
|
187
|
+
@user =
|
188
|
+
data[:user] &&
|
189
|
+
(@client.users[data[:user][:id]] || User.new(@client, data[:user]))
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|