discorb 0.13.4 → 0.14.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 +4 -4
- data/.gitattributes +2 -0
- data/.github/workflows/codeql-analysis.yml +70 -0
- data/.github/workflows/lint-push.yml +18 -0
- data/.github/workflows/lint.yml +16 -0
- data/.rubocop.yml +70 -0
- data/Changelog.md +12 -0
- data/Gemfile +7 -3
- data/Rakefile +22 -22
- data/discorb.gemspec +1 -0
- data/examples/commands/bookmarker.rb +2 -1
- data/examples/commands/hello.rb +1 -0
- data/examples/commands/inspect.rb +3 -2
- data/examples/components/authorization_button.rb +2 -1
- data/examples/components/select_menu.rb +2 -1
- data/examples/extension/main.rb +1 -0
- data/examples/extension/message_expander.rb +1 -0
- data/examples/simple/eval.rb +3 -2
- data/examples/simple/ping_pong.rb +1 -0
- data/examples/simple/rolepanel.rb +1 -0
- data/examples/simple/wait_for_message.rb +4 -3
- data/exe/discorb +8 -7
- data/lib/discorb/allowed_mentions.rb +64 -0
- data/lib/discorb/app_command/command.rb +274 -0
- data/lib/discorb/app_command/handler.rb +168 -0
- data/lib/discorb/app_command.rb +2 -426
- data/lib/discorb/asset.rb +2 -0
- data/lib/discorb/audit_logs.rb +3 -3
- data/lib/discorb/channel.rb +19 -4
- data/lib/discorb/client.rb +30 -27
- data/lib/discorb/common.rb +4 -26
- data/lib/discorb/components/button.rb +106 -0
- data/lib/discorb/components/select_menu.rb +157 -0
- data/lib/discorb/components/text_input.rb +96 -0
- data/lib/discorb/components.rb +11 -276
- data/lib/discorb/dictionary.rb +3 -0
- data/lib/discorb/embed.rb +2 -2
- data/lib/discorb/emoji.rb +19 -3
- data/lib/discorb/emoji_table.rb +1 -1
- data/lib/discorb/error.rb +4 -6
- data/lib/discorb/event.rb +9 -7
- data/lib/discorb/exe/about.rb +1 -0
- data/lib/discorb/exe/irb.rb +4 -3
- data/lib/discorb/exe/new.rb +6 -7
- data/lib/discorb/exe/run.rb +2 -1
- data/lib/discorb/exe/setup.rb +8 -5
- data/lib/discorb/exe/show.rb +1 -0
- data/lib/discorb/extend.rb +19 -14
- data/lib/discorb/extension.rb +5 -1
- data/lib/discorb/gateway.rb +28 -30
- data/lib/discorb/guild.rb +11 -13
- data/lib/discorb/guild_template.rb +2 -2
- data/lib/discorb/http.rb +15 -17
- data/lib/discorb/integration.rb +1 -1
- data/lib/discorb/intents.rb +1 -1
- data/lib/discorb/interaction/autocomplete.rb +4 -3
- data/lib/discorb/interaction/command.rb +34 -9
- data/lib/discorb/interaction/components.rb +5 -2
- data/lib/discorb/interaction/modal.rb +33 -0
- data/lib/discorb/interaction/response.rb +33 -4
- data/lib/discorb/interaction/root.rb +1 -0
- data/lib/discorb/interaction.rb +2 -1
- data/lib/discorb/log.rb +1 -1
- data/lib/discorb/member.rb +1 -3
- data/lib/discorb/message.rb +26 -277
- data/lib/discorb/message_meta.rb +205 -0
- data/lib/discorb/modules.rb +1 -1
- data/lib/discorb/permission.rb +2 -2
- data/lib/discorb/presence.rb +4 -1
- data/lib/discorb/rate_limit.rb +2 -4
- data/lib/discorb/user.rb +1 -1
- data/lib/discorb/utils/colored_puts.rb +1 -0
- data/lib/discorb/voice_state.rb +3 -0
- data/lib/discorb/webhook.rb +1 -1
- data/lib/discorb.rb +1 -0
- data/template-replace/scripts/arrow.rb +1 -0
- data/template-replace/scripts/favicon.rb +1 -0
- data/template-replace/scripts/index.rb +2 -1
- data/template-replace/scripts/locale_ja.rb +5 -4
- data/template-replace/scripts/sidebar.rb +1 -0
- data/template-replace/scripts/version.rb +7 -10
- data/template-replace/scripts/yard_replace.rb +5 -4
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 810e9b14c77e49e9fca7afc4fe6b98389b26cb17dc1617213f38d7655b990a49
|
4
|
+
data.tar.gz: bbaa999265ac212f90ab60d57ec772fe7ade0e47f264a136130c679b85a46952
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 120828736edcf7eef9d78410914651edeb41ae85eadef012050b105b03c80f07f835d812105d3cfe954c7237e344b3bbc540af8840a7dde1a69f590b008a759e
|
7
|
+
data.tar.gz: f29b0399c65f180b05bf6c0c3d5f253689ff08c734f60ee7681b57c060d99e36dd85fc275f9652354933478b8139aa76c8ad854f6963fd1c074a8a260ffb6bde
|
data/.gitattributes
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
2
|
+
# to commit it to your repository.
|
3
|
+
#
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
+
# or to provide custom queries or build logic.
|
6
|
+
#
|
7
|
+
# ******** NOTE ********
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
+
# supported CodeQL languages.
|
11
|
+
#
|
12
|
+
name: "CodeQL"
|
13
|
+
|
14
|
+
on:
|
15
|
+
push:
|
16
|
+
branches: [ main ]
|
17
|
+
pull_request:
|
18
|
+
# The branches below must be a subset of the branches above
|
19
|
+
branches: [ main ]
|
20
|
+
schedule:
|
21
|
+
- cron: '20 10 * * 3'
|
22
|
+
|
23
|
+
jobs:
|
24
|
+
analyze:
|
25
|
+
name: Analyze
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
permissions:
|
28
|
+
actions: read
|
29
|
+
contents: read
|
30
|
+
security-events: write
|
31
|
+
|
32
|
+
strategy:
|
33
|
+
fail-fast: false
|
34
|
+
matrix:
|
35
|
+
language: [ 'ruby' ]
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
37
|
+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
38
|
+
|
39
|
+
steps:
|
40
|
+
- name: Checkout repository
|
41
|
+
uses: actions/checkout@v2
|
42
|
+
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
44
|
+
- name: Initialize CodeQL
|
45
|
+
uses: github/codeql-action/init@v1
|
46
|
+
with:
|
47
|
+
languages: ${{ matrix.language }}
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
52
|
+
|
53
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
54
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
55
|
+
- name: Autobuild
|
56
|
+
uses: github/codeql-action/autobuild@v1
|
57
|
+
|
58
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
59
|
+
# 📚 https://git.io/JvXDl
|
60
|
+
|
61
|
+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
62
|
+
# and modify them (or add more) to build your code if your project
|
63
|
+
# uses a compiled language
|
64
|
+
|
65
|
+
#- run: |
|
66
|
+
# make bootstrap
|
67
|
+
# make release
|
68
|
+
|
69
|
+
- name: Perform CodeQL Analysis
|
70
|
+
uses: github/codeql-action/analyze@v1
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: Lint with RuboCop
|
2
|
+
on:
|
3
|
+
- push
|
4
|
+
jobs:
|
5
|
+
rubocop:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- name: Checkout repository
|
9
|
+
uses: actions/checkout@v2
|
10
|
+
- uses: ruby/setup-ruby@v1
|
11
|
+
with:
|
12
|
+
ruby-version: 3.0.0
|
13
|
+
- name: Install gems
|
14
|
+
run: |
|
15
|
+
gem install rubocop
|
16
|
+
- name: Run rubocop
|
17
|
+
run: |
|
18
|
+
rubocop lib
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: Lint with RuboCop
|
2
|
+
on:
|
3
|
+
- pull_request
|
4
|
+
jobs:
|
5
|
+
rubocop:
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
steps:
|
8
|
+
- name: Checkout repository
|
9
|
+
uses: actions/checkout@v2
|
10
|
+
- uses: ruby/setup-ruby@v1
|
11
|
+
with:
|
12
|
+
ruby-version: 3.0.0
|
13
|
+
- name: rubocop
|
14
|
+
uses: reviewdog/action-rubocop@v2
|
15
|
+
with:
|
16
|
+
rubocop_version: 1.25
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
TargetRubyVersion: 3.0
|
4
|
+
Exclude:
|
5
|
+
- examples/**/*.rb
|
6
|
+
|
7
|
+
Layout:
|
8
|
+
Enabled: false
|
9
|
+
Metrics:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/TrailingCommaInHashLiteral: # Disabled for rufo
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/StringLiterals: # Disabled for rufo
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/TrailingCommaInArguments: # Disabled for rufo
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/StringLiteralsInInterpolation: # Disabled for rufo
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/StringConcatenation: # + looks better
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Lint/MissingSuper: # For abstract classes
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Lint/AssignmentInCondition: # Looks bad
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/PerlBackrefs: # It will be longer
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/RedundantSelf: # Looks local variable
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Naming/VariableNumber: # Discord API docs naming
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Style/ParallelAssignment: # It will be longer
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Style/RedundantInterpolation: # For make it extendable
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Style/Next: # For make it extendable
|
49
|
+
Enabled: false
|
50
|
+
|
51
|
+
Lint/ShadowedException: # False positive
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Lint/AmbiguousOperatorPrecedence: # Not needed
|
55
|
+
Enabled: false
|
56
|
+
|
57
|
+
Style/GlobalVars: # For /exe
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Lint/Debugger: # For /exe
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
Style/GuardClause: # For make it extendable
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
Layout/EndOfLine: # For git
|
67
|
+
EnforcedStyle: lf
|
68
|
+
|
69
|
+
Lint/ScriptPermission: # For GitHub Actions
|
70
|
+
Enabled: false
|
data/Changelog.md
CHANGED
@@ -4,6 +4,18 @@
|
|
4
4
|
|
5
5
|
# Changelog
|
6
6
|
|
7
|
+
## v0.14
|
8
|
+
|
9
|
+
### v0.14.0
|
10
|
+
|
11
|
+
- Add: Support Modal interaction
|
12
|
+
- Add: Support attachment option type in slash command
|
13
|
+
- Fix: Connections will no longer stacked
|
14
|
+
- Fix: Fix Client#fetch_nitro_sticker_packs returning 404
|
15
|
+
- Fix: Fix `self` reference in subcommand of extension
|
16
|
+
- Refactor: Refactored many things
|
17
|
+
- Refactor: Add Rubocop
|
18
|
+
|
7
19
|
## v0.13
|
8
20
|
|
9
21
|
### v0.13.4
|
data/Gemfile
CHANGED
@@ -13,9 +13,13 @@ group :development, optional: true do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
group :docs, optional: true do
|
16
|
-
gem "redcarpet"
|
17
|
-
gem "yard", "~> 0.9.26"
|
18
|
-
gem "gettext", "~> 3.4.1"
|
19
16
|
gem "crowdin-api", "~> 1.0"
|
17
|
+
gem "gettext", "~> 3.4.1"
|
18
|
+
gem "redcarpet"
|
20
19
|
gem "rubyzip", "~> 2.3"
|
20
|
+
gem "yard", "~> 0.9.26"
|
21
|
+
end
|
22
|
+
|
23
|
+
group :lint, optional: true do
|
24
|
+
gem "rubocop", "~> 1.25"
|
21
25
|
end
|
data/Rakefile
CHANGED
@@ -5,15 +5,14 @@ require_relative "lib/discorb/utils/colored_puts"
|
|
5
5
|
task default: %i[]
|
6
6
|
|
7
7
|
# @private
|
8
|
-
def
|
8
|
+
def current_version
|
9
9
|
require_relative "lib/discorb/common"
|
10
10
|
tag = `git tag --points-at HEAD`.force_encoding("utf-8").strip
|
11
11
|
if tag.empty?
|
12
|
-
|
12
|
+
"main"
|
13
13
|
else
|
14
|
-
|
14
|
+
Discorb::VERSION
|
15
15
|
end
|
16
|
-
version
|
17
16
|
end
|
18
17
|
|
19
18
|
desc "Build emoji_table.rb"
|
@@ -63,8 +62,7 @@ end
|
|
63
62
|
|
64
63
|
desc "Generate document and replace"
|
65
64
|
namespace :document do
|
66
|
-
version =
|
67
|
-
|
65
|
+
version = current_version
|
68
66
|
desc "Just generate document"
|
69
67
|
task :yard do
|
70
68
|
sh "bundle exec yardoc -o doc/#{version} --locale #{ENV["rake_locale"] or "en"}"
|
@@ -86,12 +84,12 @@ namespace :document do
|
|
86
84
|
|
87
85
|
desc "Replace HTML"
|
88
86
|
task :html do
|
89
|
-
require_relative "template-replace/scripts/sidebar
|
90
|
-
require_relative "template-replace/scripts/version
|
91
|
-
require_relative "template-replace/scripts/index
|
92
|
-
require_relative "template-replace/scripts/yard_replace
|
93
|
-
require_relative "template-replace/scripts/favicon
|
94
|
-
require_relative "template-replace/scripts/arrow
|
87
|
+
require_relative "template-replace/scripts/sidebar"
|
88
|
+
require_relative "template-replace/scripts/version"
|
89
|
+
require_relative "template-replace/scripts/index"
|
90
|
+
require_relative "template-replace/scripts/yard_replace"
|
91
|
+
require_relative "template-replace/scripts/favicon"
|
92
|
+
require_relative "template-replace/scripts/arrow"
|
95
93
|
iputs "Resetting changes"
|
96
94
|
Dir.glob("doc/#{version}/**/*.html") do |f|
|
97
95
|
next if (m = f.match(/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?/)) && m[0] != version
|
@@ -143,20 +141,18 @@ namespace :document do
|
|
143
141
|
replace_locale("doc/main")
|
144
142
|
end
|
145
143
|
end
|
146
|
-
task :
|
144
|
+
task replace: %i[replace:css replace:html replace:eol]
|
147
145
|
|
148
146
|
desc "Build all versions"
|
149
147
|
task :build_all do
|
150
148
|
require "fileutils"
|
151
149
|
|
152
|
-
class Bundler::Definition
|
153
|
-
def validate_platforms!
|
154
|
-
# noop
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
150
|
iputs "Building all versions"
|
159
|
-
|
151
|
+
begin
|
152
|
+
FileUtils.rm_rf("doc")
|
153
|
+
rescue StandardError
|
154
|
+
nil
|
155
|
+
end
|
160
156
|
FileUtils.cp_r("./template-replace/.", "./tmp-template-replace")
|
161
157
|
Rake::Task["document:yard"].execute
|
162
158
|
Rake::Task["document:replace:html"].execute
|
@@ -181,7 +177,7 @@ namespace :document do
|
|
181
177
|
FileUtils.cp_r("./tmp-doc/.", "./doc")
|
182
178
|
FileUtils.cp_r("./doc/#{tags.last.delete_prefix("v")}/.", "./doc")
|
183
179
|
sputs "Successfully built all versions"
|
184
|
-
rescue => e
|
180
|
+
rescue StandardError => e
|
185
181
|
sh "git switch main -f"
|
186
182
|
raise e
|
187
183
|
end
|
@@ -322,4 +318,8 @@ task :rbs do
|
|
322
318
|
File.write("sig/discorb.rbs", base)
|
323
319
|
end
|
324
320
|
|
325
|
-
task :
|
321
|
+
task document: %i[document:yard document:replace]
|
322
|
+
|
323
|
+
task :lint do
|
324
|
+
sh "rubocop lib"
|
325
|
+
end
|
data/discorb.gemspec
CHANGED
@@ -46,4 +46,5 @@ Gem::Specification.new do |spec|
|
|
46
46
|
spec.add_dependency "mime-types", "~> 3.3"
|
47
47
|
# For more information and examples about making a new gem, checkout our
|
48
48
|
# guide at: https://bundler.io/guides/creating_gem.html
|
49
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
49
50
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "discorb"
|
2
3
|
require "json"
|
3
4
|
|
@@ -20,7 +21,7 @@ def build_embed_from_message(message)
|
|
20
21
|
embed
|
21
22
|
end
|
22
23
|
|
23
|
-
client.message_command("Bookmark", guild_ids: [
|
24
|
+
client.message_command("Bookmark", guild_ids: [857_373_681_096_327_180]) do |interaction, message|
|
24
25
|
unless channel = bookmark_channel(interaction.guild)
|
25
26
|
interaction.post("Bookmark channel not found. Please create one called `bookmarks`.", ephemeral: true)
|
26
27
|
next
|
data/examples/commands/hello.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "discorb"
|
2
3
|
|
3
4
|
client = Discorb::Client.new
|
@@ -6,7 +7,7 @@ client.once :standby do
|
|
6
7
|
puts "Logged in as #{client.user}"
|
7
8
|
end
|
8
9
|
|
9
|
-
client.user_command("Info", guild_ids: [
|
10
|
+
client.user_command("Info", guild_ids: [857_373_681_096_327_180]) do |interaction|
|
10
11
|
interaction.post(embed: Discorb::Embed.new(
|
11
12
|
"Information of #{interaction.target.to_s_user}",
|
12
13
|
fields: [
|
@@ -14,7 +15,7 @@ client.user_command("Info", guild_ids: [857373681096327180]) do |interaction|
|
|
14
15
|
Discorb::Embed::Field.new("ID", interaction.target.id),
|
15
16
|
Discorb::Embed::Field.new("Bot", interaction.target.bot? ? "Yes" : "No"),
|
16
17
|
Discorb::Embed::Field.new("Joined at", interaction.target.joined_at.to_df("F")),
|
17
|
-
Discorb::Embed::Field.new("Created at", interaction.target.created_at.to_df("F"))
|
18
|
+
Discorb::Embed::Field.new("Created at", interaction.target.created_at.to_df("F"))
|
18
19
|
],
|
19
20
|
thumbnail: interaction.target.avatar&.url,
|
20
21
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "discorb"
|
2
3
|
|
3
4
|
client = Discorb::Client.new
|
@@ -21,7 +22,7 @@ SECTIONS = [
|
|
21
22
|
> So I decided to make it.
|
22
23
|
Matsumoto describes the design of Ruby as being like a simple Lisp language at its core, with an object system like that of Smalltalk, blocks inspired by higher-order functions, and practical utility like that of Perl.
|
23
24
|
WIKI
|
24
|
-
["First publication", <<~WIKI]
|
25
|
+
["First publication", <<~WIKI]
|
25
26
|
The first public release of Ruby 0.95 was announced on Japanese domestic newsgroups on December 21, 1995.
|
26
27
|
Subsequently, three more versions of Ruby were released in two days.
|
27
28
|
The release coincided with the launch of the Japanese-language ruby-list mailing list, which was the first mailing list for the new language.
|
data/examples/extension/main.rb
CHANGED
data/examples/simple/eval.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "discorb"
|
2
3
|
|
3
4
|
client = Discorb::Client.new
|
@@ -24,8 +25,8 @@ client.on :message do |message|
|
|
24
25
|
res = res.wait if res.is_a? Async::Task
|
25
26
|
message.channel.post("```rb\n#{res.inspect[...1990]}\n```")
|
26
27
|
end
|
27
|
-
rescue Exception =>
|
28
|
-
message.reply embed: Discorb::Embed.new("Error!", "```rb\n#{
|
28
|
+
rescue Exception => e
|
29
|
+
message.reply embed: Discorb::Embed.new("Error!", "```rb\n#{e.full_message(highlight: false)[...1990]}\n```",
|
29
30
|
color: Discorb::Color[:red])
|
30
31
|
end
|
31
32
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "discorb"
|
2
3
|
|
3
4
|
client = Discorb::Client.new
|
@@ -10,16 +11,16 @@ client.on :message do |message|
|
|
10
11
|
next if message.author.bot?
|
11
12
|
next unless message.content == "!quiz"
|
12
13
|
|
13
|
-
operator = [
|
14
|
+
operator = %i[+ - *].sample
|
14
15
|
num1 = rand(1..10)
|
15
16
|
num2 = rand(1..10)
|
16
17
|
|
17
18
|
val = num1.send(operator, num2)
|
18
19
|
message.channel.post("Quiz: `#{num1} #{operator} #{num2}`")
|
19
20
|
begin
|
20
|
-
msg = client.event_lock(:message, 30)
|
21
|
+
msg = client.event_lock(:message, 30) do |m|
|
21
22
|
m.content == val.to_s && m.channel == message.channel
|
22
|
-
|
23
|
+
end.wait
|
23
24
|
rescue Discorb::TimeoutError
|
24
25
|
message.channel.post("No one answered...")
|
25
26
|
else
|
data/exe/discorb
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
script = ARGV[0]
|
4
5
|
|
5
6
|
if script.nil?
|
6
7
|
puts "\e[94mThis is a tool for discorb. Currently these tools are available:\e[m"
|
7
8
|
|
8
|
-
discorb_path =
|
9
|
+
discorb_path = $LOAD_PATH.find { |path| File.directory?(path + "/discorb") }
|
9
10
|
scripts = {}
|
10
|
-
Dir.glob(discorb_path + "/discorb/exe/*.rb") do |
|
11
|
-
name = File.basename(
|
12
|
-
description = File.read(
|
11
|
+
Dir.glob(discorb_path + "/discorb/exe/*.rb") do |exe_script|
|
12
|
+
name = File.basename(exe_script, ".rb")
|
13
|
+
description = File.read(exe_script).match(/# description: (.+)/)&.[](1) || "No description"
|
13
14
|
scripts[name] = description
|
14
15
|
end
|
15
|
-
max_length = scripts.keys.map
|
16
|
+
max_length = scripts.keys.map(&:length).max
|
16
17
|
scripts.sort.each do |name, description|
|
17
18
|
puts "\e[90m#{name.rjust(max_length)}\e[m - #{description}"
|
18
19
|
end
|
19
20
|
|
20
|
-
puts "\e[94m\nTo run a tool, type:\e[m\n"
|
21
|
-
|
21
|
+
puts "\e[94m\nTo run a tool, type:\e[m\n" \
|
22
|
+
"\e[34m discorb [script]\e[m"
|
22
23
|
|
23
24
|
exit 1
|
24
25
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Discorb
|
3
|
+
#
|
4
|
+
# Represents a allowed mentions in a message.
|
5
|
+
#
|
6
|
+
class AllowedMentions
|
7
|
+
# @return [Boolean] Whether to allow @everyone or @here.
|
8
|
+
attr_accessor :everyone
|
9
|
+
# @return [Boolean, Array<Discorb::Role>] The roles to allow, or false to disable.
|
10
|
+
attr_accessor :roles
|
11
|
+
# @return [Boolean, Array<Discorb::User>] The users to allow, or false to disable.
|
12
|
+
attr_accessor :users
|
13
|
+
# @return [Boolean] Whether to ping the user that sent the message to reply.
|
14
|
+
attr_accessor :replied_user
|
15
|
+
|
16
|
+
#
|
17
|
+
# Initializes a new instance of the AllowedMentions class.
|
18
|
+
#
|
19
|
+
# @param [Boolean] everyone Whether to allow @everyone or @here.
|
20
|
+
# @param [Boolean, Array<Discorb::Role>] roles The roles to allow, or false to disable.
|
21
|
+
# @param [Boolean, Array<Discorb::User>] users The users to allow, or false to disable.
|
22
|
+
# @param [Boolean] replied_user Whether to ping the user that sent the message to reply.
|
23
|
+
#
|
24
|
+
def initialize(everyone: nil, roles: nil, users: nil, replied_user: nil)
|
25
|
+
@everyone = everyone
|
26
|
+
@roles = roles
|
27
|
+
@users = users
|
28
|
+
@replied_user = replied_user
|
29
|
+
end
|
30
|
+
|
31
|
+
def inspect
|
32
|
+
"#<#{self.class} @everyone=#{@everyone} @roles=#{@roles} @users=#{@users} @replied_user=#{@replied_user}>"
|
33
|
+
end
|
34
|
+
|
35
|
+
# @private
|
36
|
+
def to_hash(other = nil)
|
37
|
+
payload = {
|
38
|
+
parse: %w[everyone roles users],
|
39
|
+
}
|
40
|
+
replied_user = nil_merge(@replied_user, other&.replied_user)
|
41
|
+
everyone = nil_merge(@everyone, other&.everyone)
|
42
|
+
roles = nil_merge(@roles, other&.roles)
|
43
|
+
users = nil_merge(@users, other&.users)
|
44
|
+
payload[:replied_user] = replied_user
|
45
|
+
payload[:parse].delete("everyone") if everyone == false
|
46
|
+
if (roles == false) || roles.is_a?(Array)
|
47
|
+
payload[:roles] = roles.map { |u| u.id.to_s } if roles.is_a? Array
|
48
|
+
payload[:parse].delete("roles")
|
49
|
+
end
|
50
|
+
if (users == false) || users.is_a?(Array)
|
51
|
+
payload[:users] = users.map { |u| u.id.to_s } if users.is_a? Array
|
52
|
+
payload[:parse].delete("users")
|
53
|
+
end
|
54
|
+
payload
|
55
|
+
end
|
56
|
+
|
57
|
+
def nil_merge(*args)
|
58
|
+
args.each do |a|
|
59
|
+
return a unless a.nil?
|
60
|
+
end
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|