discorb 0.0.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +32 -1
- data/Gemfile +0 -1
- data/Gemfile.lock +1 -2
- data/README.md +1 -1
- data/docs/application_command.md +251 -0
- data/docs/discord_irb.md +39 -0
- data/docs/events.md +60 -64
- data/docs/extension.md +53 -0
- data/docs/voice_events.md +32 -32
- data/examples/commands/bookmarker.rb +41 -0
- data/examples/commands/hello.rb +9 -0
- data/examples/commands/inspect.rb +24 -0
- data/examples/components/authorization_button.rb +3 -3
- data/examples/components/select_menu.rb +3 -3
- data/examples/extension/message_expander.rb +1 -1
- data/examples/simple/eval.rb +2 -2
- data/examples/simple/ping_pong.rb +1 -1
- data/examples/simple/rolepanel.rb +3 -3
- data/examples/simple/wait_for_message.rb +1 -1
- data/exe/discord-irb +60 -0
- data/lib/discorb/asset.rb +34 -0
- data/lib/discorb/channel.rb +4 -4
- data/lib/discorb/client.rb +58 -16
- data/lib/discorb/command.rb +393 -0
- data/lib/discorb/common.rb +5 -5
- data/lib/discorb/dictionary.rb +1 -1
- data/lib/discorb/embed.rb +7 -7
- data/lib/discorb/emoji.rb +6 -1
- data/lib/discorb/emoji_table.rb +9 -2
- data/lib/discorb/error.rb +4 -1
- data/lib/discorb/extension.rb +5 -2
- data/lib/discorb/gateway.rb +490 -481
- data/lib/discorb/http.rb +1 -1
- data/lib/discorb/interaction.rb +131 -19
- data/lib/discorb/log.rb +1 -1
- data/lib/discorb/member.rb +10 -1
- data/lib/discorb/message.rb +33 -6
- data/lib/discorb/modules.rb +77 -4
- data/lib/discorb/user.rb +8 -3
- data/lib/discorb/webhook.rb +14 -3
- data/lib/discorb.rb +7 -7
- metadata +12 -3
data/lib/discorb/user.rb
CHANGED
@@ -21,6 +21,8 @@ module Discorb
|
|
21
21
|
# @return [Boolean] Whether the user is a bot.
|
22
22
|
attr_reader :bot
|
23
23
|
alias bot? bot
|
24
|
+
# @return [Time] The time the user was created.
|
25
|
+
attr_reader :created_at
|
24
26
|
|
25
27
|
include Discorb::Messageable
|
26
28
|
|
@@ -41,6 +43,8 @@ module Discorb
|
|
41
43
|
"#{@username}##{@discriminator}"
|
42
44
|
end
|
43
45
|
|
46
|
+
alias to_s_user to_s
|
47
|
+
|
44
48
|
def inspect
|
45
49
|
"#<#{self.class} #{self}>"
|
46
50
|
end
|
@@ -70,13 +74,13 @@ module Discorb
|
|
70
74
|
alias app_owner? bot_owner?
|
71
75
|
|
72
76
|
# @!visibility private
|
73
|
-
def
|
77
|
+
def channel_id
|
74
78
|
Async do
|
75
79
|
next @dm_channel_id if @dm_channel_id
|
76
80
|
|
77
81
|
dm_channel = @client.http.post("/users/#{@id}/channels", { recipient_id: @client.user.id }).wait
|
78
82
|
@dm_channel_id = dm_channel[:id]
|
79
|
-
|
83
|
+
@dm_channel_id
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
@@ -123,10 +127,11 @@ module Discorb
|
|
123
127
|
@id = Snowflake.new(data[:id])
|
124
128
|
@flag = User::Flag.new(data[:public_flags] | (data[:flags] || 0))
|
125
129
|
@discriminator = data[:discriminator]
|
126
|
-
@avatar = Asset.new(self, data[:avatar])
|
130
|
+
@avatar = data[:avatar] ? Asset.new(self, data[:avatar]) : DefaultAvatar.new(data[:discriminator])
|
127
131
|
@bot = data[:bot]
|
128
132
|
@raw_data = data
|
129
133
|
@client.users[@id] = self if !data[:no_cache] && data.is_a?(User)
|
134
|
+
@created_at = @id.timestamp
|
130
135
|
@data.update(data)
|
131
136
|
end
|
132
137
|
end
|
data/lib/discorb/webhook.rb
CHANGED
@@ -62,7 +62,7 @@ module Discorb
|
|
62
62
|
#
|
63
63
|
def post(content = nil, tts: false, embed: nil, embeds: nil, allowed_mentions: nil,
|
64
64
|
file: nil, files: nil, username: nil, avatar_url: :unset, wait: true)
|
65
|
-
Async do
|
65
|
+
Async do
|
66
66
|
payload = {}
|
67
67
|
payload[:content] = content if content
|
68
68
|
payload[:tts] = tts
|
@@ -102,7 +102,7 @@ module Discorb
|
|
102
102
|
# @param [Discorb::GuildChannel] channel The new channel of the webhook.
|
103
103
|
#
|
104
104
|
def edit(name: :unset, avatar: :unset, channel: :unset)
|
105
|
-
Async do
|
105
|
+
Async do
|
106
106
|
payload = {}
|
107
107
|
payload[:name] = name if name != :unset
|
108
108
|
payload[:avatar] = avatar if avatar != :unset
|
@@ -377,9 +377,20 @@ module Discorb
|
|
377
377
|
@bot = data[:bot]
|
378
378
|
@id = Snowflake.new(data[:id])
|
379
379
|
@username = data[:username]
|
380
|
-
@avatar = data[:avatar]
|
380
|
+
@avatar = data[:avatar] ? Asset.new(self, data[:avatar]) : DefaultAvatar.new(data[:discriminator])
|
381
381
|
@discriminator = data[:discriminator]
|
382
382
|
end
|
383
|
+
|
384
|
+
#
|
385
|
+
# Format author with `Name#Discriminator` style.
|
386
|
+
#
|
387
|
+
# @return [String] Formatted author.
|
388
|
+
#
|
389
|
+
def to_s
|
390
|
+
"#{@username}##{@discriminator}"
|
391
|
+
end
|
392
|
+
|
393
|
+
alias to_s_user to_s
|
383
394
|
end
|
384
395
|
end
|
385
396
|
|
data/lib/discorb.rb
CHANGED
@@ -24,17 +24,17 @@ module Discorb
|
|
24
24
|
#
|
25
25
|
def macro
|
26
26
|
# NOTE: this method is only for YARD.
|
27
|
-
puts
|
27
|
+
puts "Wow, You found the easter egg!\n"
|
28
28
|
red = "\e[31m"
|
29
29
|
reset = "\e[m"
|
30
30
|
puts <<~"EASTEREGG"
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
. #{red} #{reset}
|
32
|
+
| #{red} | #{reset}
|
33
|
+
__| | __ __ _ #{red} _ |__ #{reset}
|
34
|
+
/ | | (__ / / \\ #{red}|/ | \\ #{reset}
|
35
35
|
\\__| | __) \\__ \\_/ #{red}| |__/ #{reset}
|
36
36
|
|
37
|
-
|
37
|
+
Thank you for using this library!
|
38
38
|
EASTEREGG
|
39
39
|
end
|
40
40
|
end
|
@@ -44,7 +44,7 @@ require_order = %w[common flag dictionary error http intents emoji_table modules
|
|
44
44
|
%w[application audit_logs color components event extension] +
|
45
45
|
%w[file guild_template image integration interaction invite log permission] +
|
46
46
|
%w[presence reaction role sticker utils voice_state webhook] +
|
47
|
-
%w[gateway_requests gateway] +
|
47
|
+
%w[gateway_requests gateway command] +
|
48
48
|
%w[asset client extend]
|
49
49
|
require_order.each do |name|
|
50
50
|
require_relative "discorb/#{name}.rb"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discorb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sevenc-nanashi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -69,7 +69,8 @@ dependencies:
|
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- sevenc-nanashi@sevenbot.jp
|
72
|
-
executables:
|
72
|
+
executables:
|
73
|
+
- discord-irb
|
73
74
|
extensions: []
|
74
75
|
extra_rdoc_files: []
|
75
76
|
files:
|
@@ -85,8 +86,14 @@ files:
|
|
85
86
|
- bin/setup
|
86
87
|
- discorb.gemspec
|
87
88
|
- docs/Examples.md
|
89
|
+
- docs/application_command.md
|
90
|
+
- docs/discord_irb.md
|
88
91
|
- docs/events.md
|
92
|
+
- docs/extension.md
|
89
93
|
- docs/voice_events.md
|
94
|
+
- examples/commands/bookmarker.rb
|
95
|
+
- examples/commands/hello.rb
|
96
|
+
- examples/commands/inspect.rb
|
90
97
|
- examples/components/authorization_button.rb
|
91
98
|
- examples/components/select_menu.rb
|
92
99
|
- examples/extension/main.rb
|
@@ -95,6 +102,7 @@ files:
|
|
95
102
|
- examples/simple/ping_pong.rb
|
96
103
|
- examples/simple/rolepanel.rb
|
97
104
|
- examples/simple/wait_for_message.rb
|
105
|
+
- exe/discord-irb
|
98
106
|
- lib/discorb.rb
|
99
107
|
- lib/discorb/application.rb
|
100
108
|
- lib/discorb/asset.rb
|
@@ -102,6 +110,7 @@ files:
|
|
102
110
|
- lib/discorb/channel.rb
|
103
111
|
- lib/discorb/client.rb
|
104
112
|
- lib/discorb/color.rb
|
113
|
+
- lib/discorb/command.rb
|
105
114
|
- lib/discorb/common.rb
|
106
115
|
- lib/discorb/components.rb
|
107
116
|
- lib/discorb/dictionary.rb
|