discorb 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +7 -0
- data/Rakefile +1 -1
- data/docs/extension.md +30 -0
- data/lib/discorb/client.rb +3 -0
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/exe/run.rb +2 -2
- data/lib/discorb/role.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f6ee34f3af585d7ddac79ba4a4e27e860d6e9bb5035fba753d05ef9051a33ae
|
4
|
+
data.tar.gz: 6bee85cd879565d96930f9bceecb0dc0f7e0f0f7a2538f95890b65d48289a7a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9ad567614fd083bf93f84291944196f6d0ef4ff20db5052ab13fef078d0ab50e5be71fb553701c0ff9332da630e6d6d6969371528db6bd8830f2a25542e1837
|
7
|
+
data.tar.gz: 450323783abfcdbdfb9db7517bda56b26c651dd7c4df18212fb11c624ff16016df01d1d8126ac9dc2cff0cd532b07afba406e16db154f917ca85d55f89f41139
|
data/Changelog.md
CHANGED
data/Rakefile
CHANGED
@@ -156,7 +156,7 @@ namespace :document do
|
|
156
156
|
Rake::Task["document:replace:html"].execute
|
157
157
|
Rake::Task["document:replace:css"].execute
|
158
158
|
Rake::Task["document:replace:eol"].execute
|
159
|
-
tags = `git tag`.force_encoding("utf-8").split("\n")
|
159
|
+
tags = `git tag`.force_encoding("utf-8").split("\n").sort_by { |t| t[1..].split(".").map(&:to_i) }
|
160
160
|
tags.each do |tag|
|
161
161
|
sh "git checkout #{tag} -f"
|
162
162
|
iputs "Building #{tag}"
|
data/docs/extension.md
CHANGED
@@ -84,3 +84,33 @@ class MyExtension < Discorb::Extension
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
```
|
87
|
+
|
88
|
+
## Receiving Arguments on load
|
89
|
+
|
90
|
+
You can receive arguments by adding some arguments to `#initialize`.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
class MyExtension < Discorb::Extension
|
94
|
+
def initialize(client, arg1, arg2)
|
95
|
+
super(client)
|
96
|
+
# @client = client will also work, but it's not recommended.
|
97
|
+
@arg1 = arg1
|
98
|
+
@arg2 = arg2
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
client.load_extension(MyExtension, "arg1", "arg2")
|
103
|
+
|
104
|
+
```
|
105
|
+
|
106
|
+
## Do something on load
|
107
|
+
|
108
|
+
You can do something on load by overriding `.loaded`. Client and arguments will be passed to it.
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
class MyExtension < Discorb::Extension
|
112
|
+
def self.loaded(client)
|
113
|
+
puts "This extension is loaded to #{client}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
```
|
data/lib/discorb/client.rb
CHANGED
@@ -401,6 +401,9 @@ module Discorb
|
|
401
401
|
cmd.define_singleton_method(:extension) { ins.name }
|
402
402
|
@commands << cmd
|
403
403
|
end
|
404
|
+
|
405
|
+
cls = ins.class
|
406
|
+
cls.loaded(self, ...) if cls.respond_to? :loaded
|
404
407
|
@bottom_commands += ins.class.bottom_commands
|
405
408
|
@extensions[ins.class.name] = ins
|
406
409
|
ins
|
data/lib/discorb/common.rb
CHANGED
@@ -4,7 +4,7 @@ module Discorb
|
|
4
4
|
# @return [String] The API base URL.
|
5
5
|
API_BASE_URL = "https://discord.com/api/v9"
|
6
6
|
# @return [String] The version of discorb.
|
7
|
-
VERSION = "0.10.
|
7
|
+
VERSION = "0.10.3"
|
8
8
|
# @return [String] The user agent for the bot.
|
9
9
|
USER_AGENT = "DiscordBot (https://discorb-lib.github.io #{VERSION}) Ruby/#{RUBY_VERSION}"
|
10
10
|
|
data/lib/discorb/exe/run.rb
CHANGED
@@ -71,9 +71,9 @@ ENV["DISCORB_CLI_TITLE"] = options[:title]
|
|
71
71
|
|
72
72
|
if File.exist? script
|
73
73
|
if options[:bundler]
|
74
|
-
|
74
|
+
exec "bundle exec ruby #{script}"
|
75
75
|
else
|
76
|
-
|
76
|
+
exec "ruby #{script}"
|
77
77
|
end
|
78
78
|
else
|
79
79
|
eputs "Could not load script: \e[31m#{script}\e[91m"
|
data/lib/discorb/role.rb
CHANGED
@@ -26,6 +26,10 @@ module Discorb
|
|
26
26
|
# @return [Boolean] Whether the role is a default role.
|
27
27
|
attr_reader :mentionable
|
28
28
|
alias mentionable? mentionable
|
29
|
+
# @return [Discorb::Asset, nil] The icon of the role.
|
30
|
+
attr_reader :custom_icon
|
31
|
+
# @return [Discorb::Emoji, nil] The emoji of the role.
|
32
|
+
attr_reader :emoji
|
29
33
|
|
30
34
|
# @!attribute [r] mention
|
31
35
|
# @return [String] The mention of the role.
|
@@ -33,6 +37,8 @@ module Discorb
|
|
33
37
|
# @return [Boolean] Whether the role has a color.
|
34
38
|
# @!attribute [r] tag
|
35
39
|
# @return [Discorb::Role::Tag] The tag of the role.
|
40
|
+
# @!attribute [r] icon
|
41
|
+
# @return [Discorb::Asset, Discorb::Emoji] The icon of the role.
|
36
42
|
|
37
43
|
include Comparable
|
38
44
|
|
@@ -44,6 +50,10 @@ module Discorb
|
|
44
50
|
_set_data(data)
|
45
51
|
end
|
46
52
|
|
53
|
+
def icon
|
54
|
+
@custom_icon || @emoji
|
55
|
+
end
|
56
|
+
|
47
57
|
#
|
48
58
|
# Compares two roles by their position.
|
49
59
|
#
|
@@ -182,6 +192,8 @@ module Discorb
|
|
182
192
|
@managed = data[:managed]
|
183
193
|
@mentionable = data[:mentionable]
|
184
194
|
@tags = data[:tags] || {}
|
195
|
+
@custom_icon = data[:icon] ? Asset.new(self, data[:icon], path: "role-icons/#{@id}") : nil
|
196
|
+
@emoji = data[:unicode_emoji] ? UnicodeEmoji.new(data[:unicode_emoji]) : nil
|
185
197
|
@guild.roles[@id] = self unless data[:no_cache]
|
186
198
|
@data.update(data)
|
187
199
|
end
|
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.10.
|
4
|
+
version: 0.10.3
|
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-10-
|
11
|
+
date: 2021-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|