discorb 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +1 -0
- data/.github/workflows/build_main.yml +2 -2
- data/.github/workflows/build_version.yml +1 -1
- data/.github/workflows/codeql-analysis.yml +1 -1
- data/.github/workflows/lint-push.yml +3 -5
- data/.github/workflows/lint.yml +1 -1
- data/.github/workflows/spec.yml +30 -0
- data/.lefthook/commit-msg/validator.rb +5 -0
- data/.rspec +2 -0
- data/.rspec_parallel +2 -0
- data/.rubocop.yml +43 -6
- data/Changelog.md +14 -1
- data/Gemfile +14 -8
- data/Rakefile +41 -26
- data/bin/console +3 -3
- data/docs/Examples.md +1 -1
- data/docs/application_command.md +138 -46
- data/docs/cli/irb.md +2 -2
- data/docs/cli/new.md +14 -9
- data/docs/cli/run.md +7 -11
- data/docs/cli.md +17 -10
- data/docs/events.md +209 -211
- data/docs/extension.md +1 -2
- data/docs/faq.md +0 -1
- data/docs/tutorial.md +12 -12
- data/docs/voice_events.md +106 -106
- data/examples/commands/message.rb +63 -0
- data/examples/commands/permission.rb +18 -0
- data/examples/commands/slash.rb +44 -0
- data/examples/commands/user.rb +51 -0
- data/examples/components/authorization_button.rb +2 -2
- data/examples/components/select_menu.rb +2 -2
- data/examples/extension/main.rb +1 -1
- data/examples/extension/message_expander.rb +5 -2
- data/examples/simple/eval.rb +2 -2
- data/examples/simple/ping_pong.rb +1 -1
- data/examples/simple/rolepanel.rb +1 -1
- data/examples/simple/shard.rb +1 -1
- data/examples/simple/wait_for_message.rb +1 -1
- data/exe/discorb +31 -16
- data/lefthook.yml +45 -0
- data/lib/discorb/allowed_mentions.rb +1 -0
- data/lib/discorb/app_command/command.rb +127 -65
- data/lib/discorb/app_command/common.rb +25 -0
- data/lib/discorb/app_command/handler.rb +115 -33
- data/lib/discorb/app_command.rb +2 -1
- data/lib/discorb/application.rb +1 -0
- data/lib/discorb/asset.rb +1 -2
- data/lib/discorb/attachment.rb +1 -1
- data/lib/discorb/audit_logs.rb +11 -8
- data/lib/discorb/channel/base.rb +108 -0
- data/lib/discorb/channel/category.rb +32 -0
- data/lib/discorb/channel/container.rb +44 -0
- data/lib/discorb/channel/dm.rb +28 -0
- data/lib/discorb/channel/guild.rb +245 -0
- data/lib/discorb/channel/stage.rb +140 -0
- data/lib/discorb/channel/text.rb +345 -0
- data/lib/discorb/channel/thread.rb +321 -0
- data/lib/discorb/channel/voice.rb +79 -0
- data/lib/discorb/channel.rb +2 -1165
- data/lib/discorb/client.rb +38 -26
- data/lib/discorb/common.rb +2 -1
- data/lib/discorb/components/button.rb +2 -1
- data/lib/discorb/components/select_menu.rb +4 -2
- data/lib/discorb/components/text_input.rb +12 -2
- data/lib/discorb/components.rb +1 -1
- data/lib/discorb/embed.rb +22 -7
- data/lib/discorb/emoji.rb +30 -3
- data/lib/discorb/emoji_table.rb +4969 -3
- data/lib/discorb/event.rb +29 -4
- data/lib/discorb/exe/about.rb +1 -0
- data/lib/discorb/exe/irb.rb +2 -4
- data/lib/discorb/exe/new.rb +90 -23
- data/lib/discorb/exe/run.rb +8 -22
- data/lib/discorb/exe/setup.rb +25 -12
- data/lib/discorb/exe/show.rb +4 -3
- data/lib/discorb/extend.rb +1 -0
- data/lib/discorb/extension.rb +6 -3
- data/lib/discorb/flag.rb +11 -0
- data/lib/discorb/gateway.rb +67 -19
- data/lib/discorb/guild.rb +188 -56
- data/lib/discorb/guild_template.rb +10 -4
- data/lib/discorb/http.rb +16 -9
- data/lib/discorb/integration.rb +4 -1
- data/lib/discorb/intents.rb +1 -1
- data/lib/discorb/interaction/autocomplete.rb +28 -16
- data/lib/discorb/interaction/command.rb +36 -12
- data/lib/discorb/interaction/components.rb +5 -2
- data/lib/discorb/interaction/modal.rb +0 -1
- data/lib/discorb/interaction/response.rb +61 -22
- data/lib/discorb/interaction/root.rb +13 -13
- data/lib/discorb/interaction.rb +1 -0
- data/lib/discorb/invite.rb +5 -2
- data/lib/discorb/member.rb +25 -5
- data/lib/discorb/message.rb +47 -14
- data/lib/discorb/message_meta.rb +1 -0
- data/lib/discorb/modules.rb +56 -14
- data/lib/discorb/presence.rb +2 -2
- data/lib/discorb/rate_limit.rb +7 -2
- data/lib/discorb/reaction.rb +4 -4
- data/lib/discorb/role.rb +19 -4
- data/lib/discorb/shard.rb +1 -1
- data/lib/discorb/sticker.rb +8 -7
- data/lib/discorb/user.rb +2 -1
- data/lib/discorb/utils/colored_puts.rb +1 -0
- data/lib/discorb/voice_state.rb +10 -6
- data/lib/discorb/webhook.rb +36 -24
- data/lib/discorb.rb +5 -3
- data/po/yard.pot +9 -9
- data/sig/discorb.rbs +7232 -7235
- metadata +21 -5
- data/examples/commands/bookmarker.rb +0 -42
- data/examples/commands/hello.rb +0 -10
- data/examples/commands/inspect.rb +0 -25
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Discorb
|
4
|
+
#
|
5
|
+
# Represents a voice channel.
|
6
|
+
#
|
7
|
+
class VoiceChannel < GuildChannel
|
8
|
+
# @return [Integer] The bitrate of the voice channel.
|
9
|
+
attr_reader :bitrate
|
10
|
+
# @return [Integer] The user limit of the voice channel.
|
11
|
+
# @return [nil] If the user limit is not set.
|
12
|
+
attr_reader :user_limit
|
13
|
+
|
14
|
+
# @!attribute [r] members
|
15
|
+
# @return [Array<Discorb::Member>] The members in the voice channel.
|
16
|
+
# @!attribute [r] voice_states
|
17
|
+
# @return [Array<Discorb::VoiceState>] The voice states associated with the voice channel.
|
18
|
+
|
19
|
+
include Connectable
|
20
|
+
include Messageable
|
21
|
+
|
22
|
+
@channel_type = 2
|
23
|
+
#
|
24
|
+
# Edit the voice channel.
|
25
|
+
# @async
|
26
|
+
# @macro edit
|
27
|
+
#
|
28
|
+
# @param [String] name The name of the voice channel.
|
29
|
+
# @param [Integer] position The position of the voice channel.
|
30
|
+
# @param [Integer] bitrate The bitrate of the voice channel.
|
31
|
+
# @param [Integer] user_limit The user limit of the voice channel.
|
32
|
+
# @param [Symbol] rtc_region The region of the voice channel.
|
33
|
+
# @param [String] reason The reason of editing the voice channel.
|
34
|
+
#
|
35
|
+
# @return [Async::Task<self>] The edited voice channel.
|
36
|
+
#
|
37
|
+
def edit(
|
38
|
+
name: Discorb::Unset,
|
39
|
+
position: Discorb::Unset,
|
40
|
+
bitrate: Discorb::Unset,
|
41
|
+
user_limit: Discorb::Unset,
|
42
|
+
rtc_region: Discorb::Unset,
|
43
|
+
reason: nil
|
44
|
+
)
|
45
|
+
Async do
|
46
|
+
payload = {}
|
47
|
+
payload[:name] = name if name != Discorb::Unset
|
48
|
+
payload[:position] = position if position != Discorb::Unset
|
49
|
+
payload[:bitrate] = bitrate if bitrate != Discorb::Unset
|
50
|
+
payload[:user_limit] = user_limit if user_limit != Discorb::Unset
|
51
|
+
payload[:rtc_region] = rtc_region if rtc_region != Discorb::Unset
|
52
|
+
|
53
|
+
@client.http.request(Route.new("/channels/#{@id}", "//channels/:channel_id", :patch), payload,
|
54
|
+
audit_log_reason: reason).wait
|
55
|
+
self
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
alias modify edit
|
60
|
+
|
61
|
+
def voice_states
|
62
|
+
guild.voice_states.select { |state| state.channel&.id == @id }
|
63
|
+
end
|
64
|
+
|
65
|
+
def members
|
66
|
+
voice_states.map(&:member)
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def _set_data(data)
|
72
|
+
@bitrate = data[:bitrate]
|
73
|
+
@user_limit = (data[:user_limit]).zero? ? nil : data[:user_limit]
|
74
|
+
@rtc_region = data[:rtc_region]&.to_sym
|
75
|
+
@video_quality_mode = data[:video_quality_mode] == 1 ? :auto : :full
|
76
|
+
super
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|