discorb 0.16.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +1 -0
  3. data/.github/workflows/build_main.yml +2 -2
  4. data/.github/workflows/build_version.yml +1 -1
  5. data/.github/workflows/codeql-analysis.yml +1 -1
  6. data/.github/workflows/lint-push.yml +3 -5
  7. data/.github/workflows/lint.yml +2 -4
  8. data/.github/workflows/spec.yml +33 -0
  9. data/.github/workflows/validate.yml +21 -0
  10. data/.gitignore +2 -0
  11. data/.lefthook/commit-msg/validator.rb +5 -0
  12. data/.rspec +2 -0
  13. data/.rspec_parallel +2 -0
  14. data/.rubocop.yml +43 -6
  15. data/Changelog.md +30 -1
  16. data/Gemfile +20 -8
  17. data/Rakefile +226 -98
  18. data/Steepfile +28 -0
  19. data/bin/console +3 -3
  20. data/docs/Examples.md +1 -1
  21. data/docs/application_command.md +156 -47
  22. data/docs/cli/irb.md +2 -2
  23. data/docs/cli/new.md +14 -9
  24. data/docs/cli/run.md +7 -11
  25. data/docs/cli.md +17 -10
  26. data/docs/events.md +247 -213
  27. data/docs/extension.md +1 -2
  28. data/docs/faq.md +0 -1
  29. data/docs/tutorial.md +18 -18
  30. data/docs/voice_events.md +106 -106
  31. data/examples/commands/message.rb +68 -0
  32. data/examples/commands/permission.rb +19 -0
  33. data/examples/commands/slash.rb +48 -0
  34. data/examples/commands/user.rb +54 -0
  35. data/examples/components/authorization_button.rb +4 -3
  36. data/examples/components/select_menu.rb +6 -3
  37. data/examples/extension/main.rb +2 -1
  38. data/examples/extension/message_expander.rb +6 -2
  39. data/examples/sig/commands/message.rbs +5 -0
  40. data/examples/simple/eval.rb +3 -2
  41. data/examples/simple/ping_pong.rb +2 -1
  42. data/examples/simple/rolepanel.rb +17 -6
  43. data/examples/simple/shard.rb +3 -2
  44. data/examples/simple/wait_for_message.rb +4 -1
  45. data/exe/discorb +33 -18
  46. data/lefthook.yml +45 -0
  47. data/lib/discorb/allowed_mentions.rb +2 -1
  48. data/lib/discorb/app_command/command.rb +130 -72
  49. data/lib/discorb/app_command/common.rb +25 -0
  50. data/lib/discorb/app_command/handler.rb +130 -33
  51. data/lib/discorb/app_command.rb +2 -1
  52. data/lib/discorb/application.rb +1 -0
  53. data/lib/discorb/asset.rb +1 -2
  54. data/lib/discorb/attachment.rb +1 -1
  55. data/lib/discorb/audit_logs.rb +19 -10
  56. data/lib/discorb/automod.rb +269 -0
  57. data/lib/discorb/channel/base.rb +108 -0
  58. data/lib/discorb/channel/category.rb +32 -0
  59. data/lib/discorb/channel/container.rb +44 -0
  60. data/lib/discorb/channel/dm.rb +28 -0
  61. data/lib/discorb/channel/guild.rb +246 -0
  62. data/lib/discorb/channel/stage.rb +140 -0
  63. data/lib/discorb/channel/text.rb +336 -0
  64. data/lib/discorb/channel/thread.rb +325 -0
  65. data/lib/discorb/channel/voice.rb +79 -0
  66. data/lib/discorb/channel.rb +2 -1165
  67. data/lib/discorb/client.rb +50 -36
  68. data/lib/discorb/color.rb +37 -60
  69. data/lib/discorb/common.rb +2 -1
  70. data/lib/discorb/components/button.rb +2 -1
  71. data/lib/discorb/components/select_menu.rb +4 -2
  72. data/lib/discorb/components/text_input.rb +12 -2
  73. data/lib/discorb/components.rb +1 -1
  74. data/lib/discorb/dictionary.rb +1 -1
  75. data/lib/discorb/embed.rb +26 -10
  76. data/lib/discorb/emoji.rb +31 -4
  77. data/lib/discorb/emoji_table.rb +4969 -3
  78. data/lib/discorb/event.rb +29 -4
  79. data/lib/discorb/exe/about.rb +2 -1
  80. data/lib/discorb/exe/irb.rb +2 -4
  81. data/lib/discorb/exe/new.rb +89 -26
  82. data/lib/discorb/exe/run.rb +8 -22
  83. data/lib/discorb/exe/setup.rb +25 -12
  84. data/lib/discorb/exe/show.rb +4 -3
  85. data/lib/discorb/extend.rb +1 -0
  86. data/lib/discorb/extension.rb +6 -7
  87. data/lib/discorb/flag.rb +13 -2
  88. data/lib/discorb/gateway.rb +79 -589
  89. data/lib/discorb/gateway_events.rb +638 -0
  90. data/lib/discorb/guild.rb +318 -67
  91. data/lib/discorb/guild_template.rb +11 -5
  92. data/lib/discorb/http.rb +53 -24
  93. data/lib/discorb/integration.rb +4 -1
  94. data/lib/discorb/intents.rb +28 -19
  95. data/lib/discorb/interaction/autocomplete.rb +28 -16
  96. data/lib/discorb/interaction/command.rb +42 -14
  97. data/lib/discorb/interaction/components.rb +5 -2
  98. data/lib/discorb/interaction/modal.rb +0 -1
  99. data/lib/discorb/interaction/response.rb +125 -26
  100. data/lib/discorb/interaction/root.rb +13 -13
  101. data/lib/discorb/interaction.rb +1 -0
  102. data/lib/discorb/invite.rb +5 -2
  103. data/lib/discorb/member.rb +28 -8
  104. data/lib/discorb/message.rb +60 -25
  105. data/lib/discorb/message_meta.rb +3 -3
  106. data/lib/discorb/modules.rb +59 -16
  107. data/lib/discorb/presence.rb +2 -0
  108. data/lib/discorb/rate_limit.rb +7 -2
  109. data/lib/discorb/reaction.rb +2 -2
  110. data/lib/discorb/role.rb +20 -5
  111. data/lib/discorb/shard.rb +1 -1
  112. data/lib/discorb/sticker.rb +9 -8
  113. data/lib/discorb/user.rb +4 -3
  114. data/lib/discorb/utils/colored_puts.rb +1 -0
  115. data/lib/discorb/voice_state.rb +6 -2
  116. data/lib/discorb/webhook.rb +64 -31
  117. data/lib/discorb.rb +7 -5
  118. data/po/yard.pot +20 -20
  119. data/rbs_collection.lock.yaml +88 -0
  120. data/rbs_collection.yaml +21 -0
  121. data/sig/async.rbs +11 -0
  122. data/sig/discorb/activity.rbs +23 -0
  123. data/sig/discorb/allowed_mentions.rbs +44 -0
  124. data/sig/discorb/app_command/base.rbs +282 -0
  125. data/sig/discorb/app_command/handler.rbs +171 -0
  126. data/sig/discorb/application.rbs +142 -0
  127. data/sig/discorb/asset.rbs +32 -0
  128. data/sig/discorb/attachment.rbs +91 -0
  129. data/sig/discorb/audit_log.rbs +231 -0
  130. data/sig/discorb/automod.rbs +128 -0
  131. data/sig/discorb/avatar.rbs +26 -0
  132. data/sig/discorb/channel/base.rbs +179 -0
  133. data/sig/discorb/channel/category.rbs +56 -0
  134. data/sig/discorb/channel/container.rbs +29 -0
  135. data/sig/discorb/channel/dm.rbs +14 -0
  136. data/sig/discorb/channel/news.rbs +20 -0
  137. data/sig/discorb/channel/stage.rbs +77 -0
  138. data/sig/discorb/channel/text.rbs +158 -0
  139. data/sig/discorb/channel/thread.rbs +185 -0
  140. data/sig/discorb/channel/voice.rbs +41 -0
  141. data/sig/discorb/client.rbs +2495 -0
  142. data/sig/discorb/color.rbs +142 -0
  143. data/sig/discorb/component/base.rbs +28 -0
  144. data/sig/discorb/component/button.rbs +65 -0
  145. data/sig/discorb/component/select_menu.rbs +107 -0
  146. data/sig/discorb/component/text_input.rbs +69 -0
  147. data/sig/discorb/connectable.rbs +8 -0
  148. data/sig/discorb/custom_emoji.rbs +90 -0
  149. data/sig/discorb/dictionary.rbs +85 -0
  150. data/sig/discorb/discord_model.rbs +15 -0
  151. data/sig/discorb/embed.rbs +279 -0
  152. data/sig/discorb/emoji.rbs +13 -0
  153. data/sig/discorb/error.rbs +73 -0
  154. data/sig/discorb/event_handler.rbs +27 -0
  155. data/sig/discorb/extension.rbs +1734 -0
  156. data/sig/discorb/flag.rbs +72 -0
  157. data/sig/discorb/gateway.rbs +481 -0
  158. data/sig/discorb/guild.rbs +870 -0
  159. data/sig/discorb/guild_template.rbs +174 -0
  160. data/sig/discorb/http.rbs +147 -0
  161. data/sig/discorb/image.rbs +20 -0
  162. data/sig/discorb/integration.rbs +118 -0
  163. data/sig/discorb/intents.rbs +97 -0
  164. data/sig/discorb/interaction/autocomplete.rbs +9 -0
  165. data/sig/discorb/interaction/base.rbs +66 -0
  166. data/sig/discorb/interaction/command.rbs +66 -0
  167. data/sig/discorb/interaction/message_component.rbs +140 -0
  168. data/sig/discorb/interaction/modal.rbs +50 -0
  169. data/sig/discorb/interaction/responder.rbs +157 -0
  170. data/sig/discorb/invite.rbs +86 -0
  171. data/sig/discorb/member.rbs +187 -0
  172. data/sig/discorb/message.rbs +469 -0
  173. data/sig/discorb/messageable.rbs +153 -0
  174. data/sig/discorb/partial_emoji.rbs +35 -0
  175. data/sig/discorb/permissions.rbs +149 -0
  176. data/sig/discorb/presence.rbs +237 -0
  177. data/sig/discorb/reaction.rbs +33 -0
  178. data/sig/discorb/role.rbs +145 -0
  179. data/sig/discorb/scheduled_event.rbs +148 -0
  180. data/sig/discorb/shard.rbs +62 -0
  181. data/sig/discorb/snowflake.rbs +56 -0
  182. data/sig/discorb/stage_instance.rbs +63 -0
  183. data/sig/discorb/sticker.rbs +116 -0
  184. data/sig/discorb/system_channel_flag.rbs +17 -0
  185. data/sig/discorb/unicode_emoji.rbs +49 -0
  186. data/sig/discorb/user.rbs +93 -0
  187. data/sig/discorb/utils.rbs +8 -0
  188. data/sig/discorb/voice_region.rbs +30 -0
  189. data/sig/discorb/voice_state.rbs +71 -0
  190. data/sig/discorb/webhook.rbs +327 -0
  191. data/sig/discorb/welcome_screen.rbs +78 -0
  192. data/sig/discorb.rbs +6 -7230
  193. data/sig/manifest.yaml +3 -0
  194. data/sig/override.rbs +19 -0
  195. data/template-replace/files/css/common.css +4 -0
  196. metadata +102 -6
  197. data/examples/commands/bookmarker.rb +0 -42
  198. data/examples/commands/hello.rb +0 -10
  199. data/examples/commands/inspect.rb +0 -25
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "discorb"
3
4
 
4
5
  client = Discorb::Client.new
@@ -28,7 +29,7 @@ client.on :message do |message|
28
29
  components: [
29
30
  Discorb::Button.new(
30
31
  "Get role", custom_id: "auth:#{role.id}",
31
- )
32
+ ),
32
33
  ],
33
34
  )
34
35
  end
@@ -36,9 +37,9 @@ end
36
37
  client.on :button_click do |response|
37
38
  if response.custom_id.start_with?("auth:")
38
39
  id = response.custom_id.delete_prefix("auth:")
39
- response.fired_by.add_role(id).wait
40
+ response.user.add_role(id).wait
40
41
  response.post("You got your role!\nHere's your role: <@&#{id}>", ephemeral: true)
41
42
  end
42
43
  end
43
44
 
44
- client.run(ENV["DISCORD_BOT_TOKEN"])
45
+ client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "discorb"
3
4
 
4
5
  client = Discorb::Client.new
@@ -22,7 +23,7 @@ SECTIONS = [
22
23
  > So I decided to make it.
23
24
  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.
24
25
  WIKI
25
- ["First publication", <<~WIKI]
26
+ ["First publication", <<~WIKI],
26
27
  The first public release of Ruby 0.95 was announced on Japanese domestic newsgroups on December 21, 1995.
27
28
  Subsequently, three more versions of Ruby were released in two days.
28
29
  The release coincided with the launch of the Japanese-language ruby-list mailing list, which was the first mailing list for the new language.
@@ -41,7 +42,9 @@ client.on :message do |message|
41
42
  next if message.author.bot?
42
43
  next unless message.content == "!ruby"
43
44
 
44
- options = SECTIONS.map.with_index { |section, i| Discorb::SelectMenu::Option.new("Page #{i + 1}", "sections:#{i}", description: section[0]) }
45
+ options = SECTIONS.map.with_index do |section, i|
46
+ Discorb::SelectMenu::Option.new("Page #{i + 1}", "sections:#{i}", description: section[0])
47
+ end
45
48
  message.channel.post(
46
49
  "Select a section", components: [Discorb::SelectMenu.new("sections", options)],
47
50
  )
@@ -59,4 +62,4 @@ client.on :select_menu_select do |response|
59
62
  )
60
63
  end
61
64
 
62
- client.run(ENV["DISCORD_BOT_TOKEN"])
65
+ client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "discorb"
3
4
  require_relative "message_expander"
4
5
 
@@ -10,4 +11,4 @@ end
10
11
 
11
12
  client.load_extension(MessageExpander)
12
13
 
13
- client.run(ENV["DISCORD_BOT_TOKEN"])
14
+ client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
@@ -1,10 +1,14 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "discorb"
3
4
 
5
+ #
6
+ # Class for expanding message URL.
7
+ #
4
8
  class MessageExpander
5
9
  include Discorb::Extension
6
10
 
7
- @@message_regex = Regexp.new(
11
+ MESSAGE_PATTERN = Regexp.new(
8
12
  '(?!<)https://(?:ptb\.|canary\.)?discord(?:app)?\.com/channels/' \
9
13
  "(?<guild>[0-9]{18})/(?<channel>[0-9]{18})/(?<message>[0-9]{18})(?!>)"
10
14
  )
@@ -12,7 +16,7 @@ class MessageExpander
12
16
  event :message do |message|
13
17
  next if message.author.bot?
14
18
 
15
- message.content.to_enum(:scan, @@message_regex).map { Regexp.last_match }.each do |match|
19
+ message.content.to_enum(:scan, MESSAGE_PATTERN).map { Regexp.last_match }.each do |match|
16
20
  ch = @client.channels[match[:channel]]
17
21
  next if ch.nil?
18
22
 
@@ -0,0 +1,5 @@
1
+ class Object
2
+ def build_embed_from_message: (Discorb::Message message) -> Discorb::Embed
3
+
4
+ def bookmark_channel: (Discorb::Guild guild) -> Discorb::TextChannel?
5
+ end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "discorb"
3
4
 
4
5
  client = Discorb::Client.new
@@ -25,9 +26,9 @@ client.on :message do |message|
25
26
  res = res.wait if res.is_a? Async::Task
26
27
  message.channel.post("```rb\n#{res.inspect[...1990]}\n```")
27
28
  end
28
- rescue Exception => e
29
+ rescue Exception => e # rubocop:disable Lint/RescueException
29
30
  message.reply embed: Discorb::Embed.new("Error!", "```rb\n#{e.full_message(highlight: false)[...1990]}\n```",
30
31
  color: Discorb::Color[:red])
31
32
  end
32
33
 
33
- client.run(ENV["discord_bot_token"])
34
+ client.run(ENV.fetch("discord_bot_token", nil))
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "discorb"
3
4
 
4
5
  client = Discorb::Client.new
@@ -14,4 +15,4 @@ client.on :message do |message|
14
15
  message.channel.post("Pong!")
15
16
  end
16
17
 
17
- client.run(ENV["DISCORD_BOT_TOKEN"])
18
+ client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "discorb"
3
4
  intents = Discorb::Intents.new
4
5
  intents.members = true
6
+
5
7
  client = Discorb::Client.new(intents: intents)
6
8
 
7
9
  def convert_role(guild, string)
@@ -15,6 +17,8 @@ client.once :standby do
15
17
  end
16
18
 
17
19
  client.on :reaction_add do |event|
20
+ next unless event.guild
21
+ next unless event.member
18
22
  next unless event.emoji.value.end_with?(0x0000fe0f.chr("utf-8") + 0x000020e3.chr("utf-8"))
19
23
  next if event.member.bot?
20
24
 
@@ -31,6 +35,7 @@ end
31
35
 
32
36
  client.on :reaction_remove do |event|
33
37
  next unless event.emoji.value.end_with?(0x0000fe0f.chr("utf-8") + 0x000020e3.chr("utf-8"))
38
+ next unless event.member
34
39
  next if event.member.bot?
35
40
 
36
41
  msg = event.fetch_message.wait
@@ -49,18 +54,24 @@ client.on :message do |message|
49
54
  next if message.author.bot?
50
55
 
51
56
  message.reply("Too many roles.") if message.content.split.length > 10
52
- roles = message.content.delete_prefix("/rp ").split.map.with_index { |raw_role, index| [index, convert_role(message.guild, raw_role), raw_role] }
57
+ roles = message.content.delete_prefix("/rp ").split.map.with_index do |raw_role, index|
58
+ [index, convert_role(message.guild, raw_role), raw_role]
59
+ end
53
60
  if (convert_fails = roles.filter { |r| r[1].nil? }).length.positive?
54
61
  message.reply("#{convert_fails.map { |r| r[2] }.join(", ")} is not a role.")
55
62
  next
56
63
  end
57
- rp_msg = message.channel.post(embed: Discorb::Embed.new(
58
- "Role panel",
59
- roles.map.with_index(1) { |r, index| "#{index}\ufe0f\u20e3#{r[1].mention}" }.join("\n")
60
- )).wait
64
+ rp_msg = message.channel.post(
65
+ embed: Discorb::Embed.new(
66
+ "Role panel",
67
+ roles.map.with_index(1) do |r, index|
68
+ "#{index}\ufe0f\u20e3#{r[1].mention}"
69
+ end.join("\n")
70
+ ),
71
+ ).wait
61
72
  1.upto(roles.length).each do |i|
62
73
  rp_msg.add_reaction(Discorb::UnicodeEmoji["#{i}\ufe0f\u20e3"]).wait
63
74
  end
64
75
  end
65
76
 
66
- client.run(ENV["DISCORD_BOT_TOKEN"])
77
+ client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "discorb"
3
4
 
4
- client = Discorb::Client.new(log: Logger.new($stdout))
5
+ client = Discorb::Client.new(logger: Logger.new($stderr))
5
6
 
6
7
  client.once :standby do
7
8
  puts "Logged in as #{client.user}"
@@ -14,4 +15,4 @@ client.on :message do |message|
14
15
  message.channel.post("I'm #{client.user}, running on shard #{client.shard_id}!")
15
16
  end
16
17
 
17
- client.run(ENV["DISCORD_BOT_TOKEN"], shards: [0, 1], shard_count: 2)
18
+ client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil), shards: [0, 1], shard_count: 2)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "discorb"
3
4
 
4
5
  client = Discorb::Client.new
@@ -12,6 +13,8 @@ client.on :message do |message|
12
13
  next unless message.content == "!quiz"
13
14
 
14
15
  operator = %i[+ - *].sample
16
+ next unless operator
17
+
15
18
  num1 = rand(1..10)
16
19
  num2 = rand(1..10)
17
20
 
@@ -28,4 +31,4 @@ client.on :message do |message|
28
31
  end
29
32
  end
30
33
 
31
- client.run(ENV["DISCORD_BOT_TOKEN"])
34
+ client.run(ENV.fetch("DISCORD_BOT_TOKEN", nil))
data/exe/discorb CHANGED
@@ -1,32 +1,47 @@
1
1
  #! /usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- script = ARGV[0]
4
+ require "optparse"
5
5
 
6
- if script.nil?
7
- puts "\e[94mThis is a tool for discorb. Currently these tools are available:\e[m"
8
-
9
- discorb_path = $LOAD_PATH.find { |path| File.directory?(path + "/discorb") }
10
- scripts = {}
6
+ options = {
7
+ bundler: true,
8
+ }
9
+ discorb_paths = $LOAD_PATH.filter { |path| File.directory?(path + "/discorb") }
10
+ scripts = {}
11
+ discorb_paths.each do |discorb_path|
11
12
  Dir.glob(discorb_path + "/discorb/exe/*.rb") do |exe_script|
12
13
  name = File.basename(exe_script, ".rb")
13
14
  description = File.read(exe_script).match(/# description: (.+)/)&.[](1) || "No description"
14
15
  scripts[name] = description
15
16
  end
16
- max_length = scripts.keys.map(&:length).max
17
- scripts.sort.each do |name, description|
18
- puts "\e[90m#{name.rjust(max_length)}\e[m - #{description}"
17
+ end
18
+ max_length = scripts.keys.map(&:length).max
19
+ global = OptionParser.new do |opts|
20
+ opts.banner = "Usage: discorb [options] [subcommand [options]]"
21
+ opts.on("-b", "--[no-]bundler", "Whether to use bundler.") do |v|
22
+ options[:bundler] = v
19
23
  end
24
+ opts.separator ""
25
+ commands = +"Subcommands:\n"
26
+ commands << scripts.sort.map do |name, description|
27
+ " #{name.rjust(max_length)} - #{description}"
28
+ end.join("\n")
29
+ commands << "\n\nYou can run `discorb [subcommand] --help` for more information."
30
+ opts.separator commands
31
+ end
32
+ global.order!(ARGV)
20
33
 
21
- puts "\e[94m\nTo run a tool, type:\e[m\n" \
22
- "\e[34m discorb [script]\e[m"
23
-
24
- exit 1
34
+ if ARGV.empty?
35
+ puts global
36
+ abort
25
37
  end
26
38
 
27
- begin
28
- require "discorb/exe/#{script}"
29
- rescue LoadError
30
- puts "\e[91mThis tool is not available: \e[90m#{script}\e[m"
31
- exit 1
39
+ require "bundler/setup" if options[:bundler]
40
+
41
+ command = ARGV.shift
42
+
43
+ unless $LOAD_PATH.resolve_feature_path("discorb/exe/#{command}.rb")
44
+ warn "Unknown subcommand: #{command}"
45
+ abort
32
46
  end
47
+ require "discorb/exe/#{command}"
data/lefthook.yml ADDED
@@ -0,0 +1,45 @@
1
+ # EXAMPLE USAGE
2
+ # Refer for explanation to following link:
3
+ # https://github.com/evilmartians/lefthook/blob/master/docs/full_guide.md
4
+ #
5
+ # pre-push:
6
+ # commands:
7
+ # packages-audit:
8
+ # tags: frontend security
9
+ # run: yarn audit
10
+ # gems-audit:
11
+ # tags: backend security
12
+ # run: bundle audit
13
+ #
14
+ # pre-commit:
15
+ # parallel: true
16
+ # commands:
17
+ # eslint:
18
+ # glob: "*.{js,ts}"
19
+ # run: yarn eslint {staged_files}
20
+ # rubocop:
21
+ # tags: backend style
22
+ # glob: "*.rb"
23
+ # exclude: "application.rb|routes.rb"
24
+ # run: bundle exec rubocop --force-exclusion {all_files}
25
+ # govet:
26
+ # tags: backend style
27
+ # files: git ls-files -m
28
+ # glob: "*.go"
29
+ # run: go vet {files}
30
+ # scripts:
31
+ # "hello.js":
32
+ # runner: node
33
+ # "any.go":
34
+ # runner: go run
35
+ pre-commit:
36
+ parallel: true
37
+ commands:
38
+ linting:
39
+ glob: "*.rb"
40
+ run: rubocop {staged_files}
41
+
42
+ commit-msg:
43
+ scripts:
44
+ "validator.rb":
45
+ runner: ruby
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Discorb
3
4
  #
4
5
  # Represents a allowed mentions in a message.
@@ -22,7 +23,7 @@ module Discorb
22
23
  # @param [Boolean] replied_user Whether to ping the user that sent the message to reply.
23
24
  #
24
25
  def initialize(everyone: nil, roles: nil, users: nil, replied_user: nil)
25
- @everyone = everyone
26
+ @everyone = !everyone.nil?
26
27
  @roles = roles
27
28
  @users = users
28
29
  @replied_user = replied_user