discorb 0.0.6 → 0.2.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.
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 base_url
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
- "/channels/#{@dm_channel_id}"
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
@@ -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 |_task|
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 |_task|
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 'Wow, You found the easter egg!\n\n'
27
+ puts "Wow, You found the easter egg!\n"
28
28
  red = "\e[31m"
29
29
  reset = "\e[m"
30
30
  puts <<~"EASTEREGG"
31
- | . #{red} | #{reset}
32
- __| #{red} |__ #{reset}
33
- / | | __ __ _ #{red} _ | \\ #{reset}
34
- ( | | (__ / / \\ #{red}|/ | ) #{reset}
31
+ . #{red} #{reset}
32
+ | #{red} | #{reset}
33
+ __| | __ __ _ #{red} _ |__ #{reset}
34
+ / | | (__ / / \\ #{red}|/ | \\ #{reset}
35
35
  \\__| | __) \\__ \\_/ #{red}| |__/ #{reset}
36
36
 
37
- https://github.com/discorb-lib/discorb
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.6
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-08-29 00:00:00.000000000 Z
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