discorb 0.17.1 → 0.18.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/.github/workflows/lint.yml +1 -3
- data/.github/workflows/validate.yml +21 -0
- data/Changelog.md +10 -0
- data/Gemfile +6 -0
- data/Rakefile +210 -98
- data/Steepfile +28 -0
- data/docs/events.md +42 -6
- data/docs/tutorial.md +7 -7
- data/docs/voice_events.md +2 -2
- data/examples/commands/message.rb +12 -7
- data/examples/commands/permission.rb +2 -1
- data/examples/commands/slash.rb +23 -19
- data/examples/commands/user.rb +15 -12
- data/examples/components/authorization_button.rb +2 -1
- data/examples/components/select_menu.rb +4 -1
- data/examples/extension/main.rb +1 -0
- data/examples/extension/message_expander.rb +1 -0
- data/examples/sig/commands/message.rbs +5 -0
- data/examples/simple/eval.rb +1 -0
- data/examples/simple/ping_pong.rb +1 -0
- data/examples/simple/rolepanel.rb +16 -5
- data/examples/simple/shard.rb +2 -1
- data/examples/simple/wait_for_message.rb +3 -0
- data/exe/discorb +3 -3
- data/lib/discorb/allowed_mentions.rb +1 -1
- data/lib/discorb/app_command/command.rb +12 -13
- data/lib/discorb/app_command/handler.rb +20 -6
- data/lib/discorb/audit_logs.rb +6 -2
- data/lib/discorb/automod.rb +269 -0
- data/lib/discorb/channel/guild.rb +2 -1
- data/lib/discorb/channel/stage.rb +1 -1
- data/lib/discorb/channel/text.rb +11 -20
- data/lib/discorb/channel/thread.rb +15 -11
- data/lib/discorb/client.rb +12 -10
- data/lib/discorb/color.rb +37 -60
- data/lib/discorb/common.rb +1 -1
- data/lib/discorb/dictionary.rb +1 -1
- data/lib/discorb/embed.rb +4 -3
- data/lib/discorb/emoji.rb +2 -2
- data/lib/discorb/exe/about.rb +1 -1
- data/lib/discorb/exe/new.rb +1 -5
- data/lib/discorb/extension.rb +0 -4
- data/lib/discorb/flag.rb +2 -2
- data/lib/discorb/gateway.rb +21 -582
- data/lib/discorb/gateway_events.rb +638 -0
- data/lib/discorb/guild.rb +136 -17
- data/lib/discorb/guild_template.rb +1 -1
- data/lib/discorb/http.rb +47 -25
- data/lib/discorb/intents.rb +27 -18
- data/lib/discorb/interaction/command.rb +14 -10
- data/lib/discorb/interaction/response.rb +74 -14
- data/lib/discorb/member.rb +3 -3
- data/lib/discorb/message.rb +13 -11
- data/lib/discorb/message_meta.rb +2 -3
- data/lib/discorb/modules.rb +3 -2
- data/lib/discorb/presence.rb +4 -2
- data/lib/discorb/reaction.rb +2 -2
- data/lib/discorb/role.rb +1 -1
- data/lib/discorb/sticker.rb +3 -3
- data/lib/discorb/user.rb +2 -2
- data/lib/discorb/voice_state.rb +5 -5
- data/lib/discorb/webhook.rb +15 -6
- data/lib/discorb.rb +2 -2
- data/rbs_collection.lock.yaml +88 -96
- data/rbs_collection.yaml +21 -17
- data/sig/async.rbs +11 -5
- data/sig/discorb/activity.rbs +23 -0
- data/sig/discorb/allowed_mentions.rbs +44 -0
- data/sig/discorb/app_command/base.rbs +282 -0
- data/sig/discorb/app_command/handler.rbs +171 -0
- data/sig/discorb/application.rbs +142 -0
- data/sig/discorb/asset.rbs +32 -0
- data/sig/discorb/attachment.rbs +91 -0
- data/sig/discorb/audit_log.rbs +231 -0
- data/sig/discorb/automod.rbs +128 -0
- data/sig/discorb/avatar.rbs +26 -0
- data/sig/discorb/channel/base.rbs +179 -0
- data/sig/discorb/channel/category.rbs +56 -0
- data/sig/discorb/channel/container.rbs +29 -0
- data/sig/discorb/channel/dm.rbs +14 -0
- data/sig/discorb/channel/news.rbs +20 -0
- data/sig/discorb/channel/stage.rbs +77 -0
- data/sig/discorb/channel/text.rbs +158 -0
- data/sig/discorb/channel/thread.rbs +185 -0
- data/sig/discorb/channel/voice.rbs +41 -0
- data/sig/discorb/client.rbs +2495 -0
- data/sig/discorb/color.rbs +142 -0
- data/sig/discorb/component/base.rbs +28 -0
- data/sig/discorb/component/button.rbs +65 -0
- data/sig/discorb/component/select_menu.rbs +107 -0
- data/sig/discorb/component/text_input.rbs +69 -0
- data/sig/discorb/connectable.rbs +8 -0
- data/sig/discorb/custom_emoji.rbs +90 -0
- data/sig/discorb/dictionary.rbs +85 -0
- data/sig/discorb/discord_model.rbs +15 -0
- data/sig/discorb/embed.rbs +279 -0
- data/sig/discorb/emoji.rbs +13 -0
- data/sig/discorb/error.rbs +73 -0
- data/sig/discorb/event_handler.rbs +27 -0
- data/sig/discorb/extension.rbs +1734 -0
- data/sig/discorb/flag.rbs +72 -0
- data/sig/discorb/gateway.rbs +481 -0
- data/sig/discorb/guild.rbs +870 -0
- data/sig/discorb/guild_template.rbs +174 -0
- data/sig/discorb/http.rbs +147 -0
- data/sig/discorb/image.rbs +20 -0
- data/sig/discorb/integration.rbs +118 -0
- data/sig/discorb/intents.rbs +97 -0
- data/sig/discorb/interaction/autocomplete.rbs +9 -0
- data/sig/discorb/interaction/base.rbs +66 -0
- data/sig/discorb/interaction/command.rbs +66 -0
- data/sig/discorb/interaction/message_component.rbs +140 -0
- data/sig/discorb/interaction/modal.rbs +50 -0
- data/sig/discorb/interaction/responder.rbs +157 -0
- data/sig/discorb/invite.rbs +86 -0
- data/sig/discorb/member.rbs +187 -0
- data/sig/discorb/message.rbs +469 -0
- data/sig/discorb/messageable.rbs +153 -0
- data/sig/discorb/partial_emoji.rbs +35 -0
- data/sig/discorb/permissions.rbs +149 -0
- data/sig/discorb/presence.rbs +237 -0
- data/sig/discorb/reaction.rbs +33 -0
- data/sig/discorb/role.rbs +145 -0
- data/sig/discorb/scheduled_event.rbs +148 -0
- data/sig/discorb/shard.rbs +62 -0
- data/sig/discorb/snowflake.rbs +56 -0
- data/sig/discorb/stage_instance.rbs +63 -0
- data/sig/discorb/sticker.rbs +116 -0
- data/sig/discorb/system_channel_flag.rbs +17 -0
- data/sig/discorb/unicode_emoji.rbs +49 -0
- data/sig/discorb/user.rbs +93 -0
- data/sig/discorb/utils.rbs +8 -0
- data/sig/discorb/voice_region.rbs +30 -0
- data/sig/discorb/voice_state.rbs +71 -0
- data/sig/discorb/webhook.rbs +327 -0
- data/sig/discorb/welcome_screen.rbs +78 -0
- data/sig/discorb.rbs +5 -8661
- data/sig/manifest.yaml +3 -0
- data/sig/override.rbs +19 -0
- metadata +80 -3
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a permission per guild.
|
|
4
|
+
# ## Flag fields
|
|
5
|
+
#
|
|
6
|
+
# | Field | Value |
|
|
7
|
+
# |-------|-------|
|
|
8
|
+
# |`1 << 0`|`:create_instant_invite`|
|
|
9
|
+
# |`1 << 1`|`:kick_members`|
|
|
10
|
+
# |`1 << 2`|`:ban_members`|
|
|
11
|
+
# |`1 << 3`|`:administrator`|
|
|
12
|
+
# |`1 << 4`|`:manage_channels`|
|
|
13
|
+
# |`1 << 5`|`:manage_guild`|
|
|
14
|
+
# |`1 << 6`|`:add_reactions`|
|
|
15
|
+
# |`1 << 7`|`:view_audit_log`|
|
|
16
|
+
# |`1 << 8`|`:priority_speaker`|
|
|
17
|
+
# |`1 << 9`|`:stream`|
|
|
18
|
+
# |`1 << 10`|`:view_channel`|
|
|
19
|
+
# |`1 << 11`|`:send_messages`|
|
|
20
|
+
# |`1 << 12`|`:send_tts_messages`|
|
|
21
|
+
# |`1 << 13`|`:manage_messages`|
|
|
22
|
+
# |`1 << 14`|`:embed_links`|
|
|
23
|
+
# |`1 << 15`|`:attach_files`|
|
|
24
|
+
# |`1 << 16`|`:read_message_history`|
|
|
25
|
+
# |`1 << 17`|`:mention_everyone`|
|
|
26
|
+
# |`1 << 18`|`:use_external_emojis`|
|
|
27
|
+
# |`1 << 19`|`:view_guild_insights`|
|
|
28
|
+
# |`1 << 20`|`:connect`|
|
|
29
|
+
# |`1 << 21`|`:speak`|
|
|
30
|
+
# |`1 << 22`|`:mute_members`|
|
|
31
|
+
# |`1 << 23`|`:deafen_members`|
|
|
32
|
+
# |`1 << 24`|`:move_members`|
|
|
33
|
+
# |`1 << 25`|`:use_vad`|
|
|
34
|
+
# |`1 << 26`|`:change_nickname`|
|
|
35
|
+
# |`1 << 27`|`:manage_nicknames`|
|
|
36
|
+
# |`1 << 28`|`:manage_roles`|
|
|
37
|
+
# |`1 << 29`|`:manage_webhooks`|
|
|
38
|
+
# |`1 << 30`|`:manage_emojis`|
|
|
39
|
+
# |`1 << 31`|`:use_slash_commands`|
|
|
40
|
+
# |`1 << 32`|`:request_to_speak`|
|
|
41
|
+
# |`1 << 34`|`:manage_threads`|
|
|
42
|
+
# |`1 << 35`|`:use_public_threads`|
|
|
43
|
+
# |`1 << 36`|`:use_private_threads`|
|
|
44
|
+
class Permission < Discorb::Flag
|
|
45
|
+
attr_accessor create_instant_invite: bool
|
|
46
|
+
attr_accessor kick_members: bool
|
|
47
|
+
attr_accessor ban_members: bool
|
|
48
|
+
attr_accessor administrator: bool
|
|
49
|
+
attr_accessor manage_channels: bool
|
|
50
|
+
attr_accessor manage_guild: bool
|
|
51
|
+
attr_accessor add_reactions: bool
|
|
52
|
+
attr_accessor view_audit_log: bool
|
|
53
|
+
attr_accessor priority_speaker: bool
|
|
54
|
+
attr_accessor stream: bool
|
|
55
|
+
attr_accessor view_channel: bool
|
|
56
|
+
attr_accessor send_messages: bool
|
|
57
|
+
attr_accessor send_tts_messages: bool
|
|
58
|
+
attr_accessor manage_messages: bool
|
|
59
|
+
attr_accessor embed_links: bool
|
|
60
|
+
attr_accessor attach_files: bool
|
|
61
|
+
attr_accessor read_message_history: bool
|
|
62
|
+
attr_accessor mention_everyone: bool
|
|
63
|
+
attr_accessor use_external_emojis: bool
|
|
64
|
+
attr_accessor view_guild_insights: bool
|
|
65
|
+
attr_accessor connect: bool
|
|
66
|
+
attr_accessor speak: bool
|
|
67
|
+
attr_accessor mute_members: bool
|
|
68
|
+
attr_accessor deafen_members: bool
|
|
69
|
+
attr_accessor move_members: bool
|
|
70
|
+
attr_accessor use_vad: bool
|
|
71
|
+
attr_accessor change_nickname: bool
|
|
72
|
+
attr_accessor manage_nicknames: bool
|
|
73
|
+
attr_accessor manage_roles: bool
|
|
74
|
+
attr_accessor manage_webhooks: bool
|
|
75
|
+
attr_accessor manage_emojis: bool
|
|
76
|
+
attr_accessor use_slash_commands: bool
|
|
77
|
+
attr_accessor request_to_speak: bool
|
|
78
|
+
attr_accessor manage_threads: bool
|
|
79
|
+
attr_accessor use_public_threads: bool
|
|
80
|
+
attr_accessor use_private_threads: bool
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
#
|
|
84
|
+
# Represents a permission per channel.
|
|
85
|
+
class PermissionOverwrite
|
|
86
|
+
#
|
|
87
|
+
# Initializes a new PermissionOverwrite.
|
|
88
|
+
# @private
|
|
89
|
+
#
|
|
90
|
+
# @param allow [Integer] The allowed permissions.
|
|
91
|
+
# @param deny [Integer] The denied permissions.
|
|
92
|
+
def initialize: (Integer allow, Integer deny) -> void
|
|
93
|
+
|
|
94
|
+
def allow: -> Discorb::Permission
|
|
95
|
+
|
|
96
|
+
def deny: -> Discorb::Permission
|
|
97
|
+
|
|
98
|
+
def allow_value: -> Integer
|
|
99
|
+
|
|
100
|
+
def deny_value: -> Integer
|
|
101
|
+
|
|
102
|
+
def inspect: -> String
|
|
103
|
+
|
|
104
|
+
#
|
|
105
|
+
# Converts the permission overwrite to a hash.
|
|
106
|
+
#
|
|
107
|
+
# @return [Hash] The permission overwrite as a hash.
|
|
108
|
+
def to_hash: -> Hash[Symbol, bool]
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
# Union of the permission overwrites.
|
|
112
|
+
#
|
|
113
|
+
# @param [Discorb::PermissionOverwrite] other The other permission overwrite.
|
|
114
|
+
#
|
|
115
|
+
# @return [Discorb::PermissionOverwrite] The union of the permission overwrites.
|
|
116
|
+
def +: (Discorb::PermissionOverwrite other) -> Discorb::PermissionOverwrite
|
|
117
|
+
|
|
118
|
+
#
|
|
119
|
+
# Returns whether overwrite of the given field.
|
|
120
|
+
#
|
|
121
|
+
# @param [Symbol] field The field to check.
|
|
122
|
+
#
|
|
123
|
+
# @return [true, false, nil] Whether the field is allowed, denied or not set.
|
|
124
|
+
def []: (Symbol field) -> bool?
|
|
125
|
+
|
|
126
|
+
#
|
|
127
|
+
# Sets the given field to the given value.
|
|
128
|
+
#
|
|
129
|
+
# @param [Symbol] key The field to set.
|
|
130
|
+
# @param [Boolean] bool The value to set.
|
|
131
|
+
def []=: (Symbol key, bool `bool`) -> untyped
|
|
132
|
+
|
|
133
|
+
#
|
|
134
|
+
# Returns the value of the flag.
|
|
135
|
+
def method_missing: (untyped method, ?untyped `bool`) -> untyped
|
|
136
|
+
|
|
137
|
+
def respond_to_missing?: (untyped method, untyped _arg) -> bool
|
|
138
|
+
|
|
139
|
+
#
|
|
140
|
+
# Initializes a permission overwrite from a hash.
|
|
141
|
+
#
|
|
142
|
+
# @param [Hash] hash The hash to initialize the permission overwrite from.
|
|
143
|
+
#
|
|
144
|
+
# @return [Discorb::PermissionOverwrite] The permission overwrite.
|
|
145
|
+
def self.from_hash: (
|
|
146
|
+
::Hash[Symbol, bool] hash
|
|
147
|
+
) -> Discorb::PermissionOverwrite
|
|
148
|
+
end
|
|
149
|
+
end
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a presence of user.
|
|
4
|
+
class Presence < Discorb::DiscordModel
|
|
5
|
+
#
|
|
6
|
+
# Initialize a presence.
|
|
7
|
+
# @private
|
|
8
|
+
#
|
|
9
|
+
# @param [Discorb::Client] client The client.
|
|
10
|
+
# @param [Hash] data The data of the presence.
|
|
11
|
+
def initialize: (Discorb::Client client, Discorb::json data) -> void
|
|
12
|
+
|
|
13
|
+
def inspect: -> String
|
|
14
|
+
|
|
15
|
+
# @return [:online, :idle, :dnd, :offline] The status of the user.
|
|
16
|
+
attr_reader status: Symbol
|
|
17
|
+
|
|
18
|
+
# @return [Array<Discorb::Presence::Activity>] The activities of the user.
|
|
19
|
+
attr_reader activities: ::Array[Discorb::Presence::Activity]
|
|
20
|
+
|
|
21
|
+
# @return [Discorb::Presence::ClientStatus] The client status of the user.
|
|
22
|
+
attr_reader client_status: Discorb::Presence::ClientStatus
|
|
23
|
+
|
|
24
|
+
# @return [Discorb::User] The user of the presence.
|
|
25
|
+
attr_reader user: Discorb::User
|
|
26
|
+
|
|
27
|
+
# @return [Discorb::Guild] The guild of the presence.
|
|
28
|
+
attr_reader guild: Discorb::Guild
|
|
29
|
+
|
|
30
|
+
# @return [Discorb::Presence::Activity] The activity of the presence.
|
|
31
|
+
attr_reader activity: Discorb::Presence::Activity
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
# Represents an activity of a user.
|
|
35
|
+
class Activity < Discorb::DiscordModel
|
|
36
|
+
ACTIVITY_TYPES: untyped
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# Initialize the activity.
|
|
40
|
+
# @private
|
|
41
|
+
#
|
|
42
|
+
# @param [Hash] data The activity data.
|
|
43
|
+
def initialize: (Discorb::json data) -> void
|
|
44
|
+
|
|
45
|
+
#
|
|
46
|
+
# Convert the activity to a string.
|
|
47
|
+
#
|
|
48
|
+
# @return [String] The string representation of the activity.
|
|
49
|
+
def to_s: -> String
|
|
50
|
+
|
|
51
|
+
# @return [String] The name of the activity.
|
|
52
|
+
attr_reader name: String
|
|
53
|
+
|
|
54
|
+
# @return [:game, :streaming, :listening, :watching, :custom, :competing] The type of the activity.
|
|
55
|
+
attr_reader type: Symbol
|
|
56
|
+
|
|
57
|
+
# @return [String] The url of the activity.
|
|
58
|
+
attr_reader url: String
|
|
59
|
+
|
|
60
|
+
# @return [Time] The time the activity was created.
|
|
61
|
+
attr_reader created_at: Time
|
|
62
|
+
|
|
63
|
+
# @return [Discorb::Presence::Activity::Timestamps] The timestamps of the activity.
|
|
64
|
+
attr_reader timestamps: Discorb::Presence::Activity::Timestamps
|
|
65
|
+
|
|
66
|
+
# @return [Discorb::Snowflake] The application id of the activity.
|
|
67
|
+
attr_reader application_id: Discorb::Snowflake
|
|
68
|
+
|
|
69
|
+
# @return [String] The details of the activity.
|
|
70
|
+
attr_reader details: String
|
|
71
|
+
|
|
72
|
+
# @return [String] The state of party.
|
|
73
|
+
attr_reader state: String
|
|
74
|
+
|
|
75
|
+
# @return [Discorb::Emoji] The emoji of the activity.
|
|
76
|
+
attr_reader emoji: Discorb::emoji?
|
|
77
|
+
|
|
78
|
+
# @return [Discorb::Presence::Activity::Party] The party of the activity.
|
|
79
|
+
# @return [nil] If the activity is not a party activity.
|
|
80
|
+
attr_reader party: Discorb::Presence::Activity::Party?
|
|
81
|
+
|
|
82
|
+
# @return [Discorb::Presence::Activity::Asset] The assets of the activity.
|
|
83
|
+
# @return [nil] If the activity has no assets.
|
|
84
|
+
attr_reader assets: Discorb::Presence::Activity::Asset?
|
|
85
|
+
|
|
86
|
+
# @return [Discorb::StageInstance] The instance of the activity.
|
|
87
|
+
# @return [nil] If the activity is not a stage activity.
|
|
88
|
+
attr_reader instance: Discorb::StageInstance?
|
|
89
|
+
|
|
90
|
+
# @return [Array<Discorb::Presence::Activity::Button>] The buttons of the activity.
|
|
91
|
+
# @return [nil] If the activity has no buttons.
|
|
92
|
+
attr_reader buttons: ::Array[Discorb::Presence::Activity::Button]?
|
|
93
|
+
|
|
94
|
+
# @return [Discorb::Presence::Activity::Flag] The flags of the activity.
|
|
95
|
+
attr_reader flags: Discorb::Presence::Activity::Flag
|
|
96
|
+
|
|
97
|
+
#
|
|
98
|
+
# Represents the timestamps of an activity.
|
|
99
|
+
class Timestamps < Discorb::DiscordModel
|
|
100
|
+
#
|
|
101
|
+
# Initialize the timestamps.
|
|
102
|
+
# @private
|
|
103
|
+
#
|
|
104
|
+
# @param [Hash] data The timestamps data.
|
|
105
|
+
def initialize: (Discorb::json data) -> void
|
|
106
|
+
|
|
107
|
+
# @return [Time] The start time of the activity.
|
|
108
|
+
attr_reader start: Time
|
|
109
|
+
|
|
110
|
+
# @return [Time] The end time of the activity.
|
|
111
|
+
attr_reader end: Time
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
#
|
|
115
|
+
# Represents the party of an activity.
|
|
116
|
+
class Party < Discorb::DiscordModel
|
|
117
|
+
#
|
|
118
|
+
# Initialize the party.
|
|
119
|
+
# @private
|
|
120
|
+
#
|
|
121
|
+
# @param [Hash] data The party data.
|
|
122
|
+
def initialize: (Discorb::json data) -> void
|
|
123
|
+
|
|
124
|
+
# @return [String] The id of the party.
|
|
125
|
+
attr_reader id: String
|
|
126
|
+
|
|
127
|
+
# @return [Integer] The current size of the party.
|
|
128
|
+
attr_reader current_size: Integer
|
|
129
|
+
|
|
130
|
+
# @return [Integer] The max size of the party.
|
|
131
|
+
attr_reader max_size: Integer
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
#
|
|
135
|
+
# Represents the assets of an activity.
|
|
136
|
+
class Asset < Discorb::DiscordModel
|
|
137
|
+
def initialize: (untyped data) -> void
|
|
138
|
+
|
|
139
|
+
# @return [String] The large image ID or URL of the asset.
|
|
140
|
+
attr_reader large_image: String
|
|
141
|
+
|
|
142
|
+
# @return [String] The large text of the activity.
|
|
143
|
+
attr_reader large_text: String
|
|
144
|
+
|
|
145
|
+
# @return [String] The small image ID or URL of the activity.
|
|
146
|
+
attr_reader small_image: String
|
|
147
|
+
|
|
148
|
+
# @return [String] The small text of the activity.
|
|
149
|
+
attr_reader small_text: String
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
#
|
|
153
|
+
# Represents the flags of an activity.
|
|
154
|
+
# ## Flag fields
|
|
155
|
+
# |`1 << 0`|`:instance`|
|
|
156
|
+
# |`1 << 1`|`:join`|
|
|
157
|
+
# |`1 << 2`|`:spectate`|
|
|
158
|
+
# |`1 << 3`|`:join_request`|
|
|
159
|
+
# |`1 << 4`|`:sync`|
|
|
160
|
+
# |`1 << 5`|`:play`|
|
|
161
|
+
class Flag < Discorb::Flag
|
|
162
|
+
attr_accessor instance: bool
|
|
163
|
+
attr_accessor join: bool
|
|
164
|
+
attr_accessor spectate: bool
|
|
165
|
+
attr_accessor join_request: bool
|
|
166
|
+
attr_accessor sync: bool
|
|
167
|
+
attr_accessor play: bool
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
#
|
|
171
|
+
# Represents a secrets of an activity.
|
|
172
|
+
class Secrets < Discorb::DiscordModel
|
|
173
|
+
#
|
|
174
|
+
# Initialize the secrets.
|
|
175
|
+
# @private
|
|
176
|
+
#
|
|
177
|
+
# @param [Hash] data The secrets data.
|
|
178
|
+
def initialize: (Discorb::json data) -> void
|
|
179
|
+
|
|
180
|
+
# @return [String] The join secret of the activity.
|
|
181
|
+
attr_reader join: String
|
|
182
|
+
|
|
183
|
+
# @return [String] The spectate secret of the activity.
|
|
184
|
+
attr_reader spectate: String
|
|
185
|
+
|
|
186
|
+
# @return [String] The match secret of the activity.
|
|
187
|
+
attr_reader match: String
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
#
|
|
191
|
+
# Represents a button of an activity.
|
|
192
|
+
class Button < Discorb::DiscordModel
|
|
193
|
+
#
|
|
194
|
+
# Initialize the button.
|
|
195
|
+
# @private
|
|
196
|
+
#
|
|
197
|
+
# @param [Hash] data The button data.
|
|
198
|
+
def initialize: (Discorb::json data) -> void
|
|
199
|
+
|
|
200
|
+
# @return [String] The text of the button.
|
|
201
|
+
attr_reader label: String
|
|
202
|
+
|
|
203
|
+
# @return [String] The URL of the button.
|
|
204
|
+
attr_reader url: String
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
#
|
|
209
|
+
# Represents a user's client status.
|
|
210
|
+
class ClientStatus < Discorb::DiscordModel
|
|
211
|
+
#
|
|
212
|
+
# Initialize the client status.
|
|
213
|
+
# @private
|
|
214
|
+
#
|
|
215
|
+
# @param [Hash] data The client status data.
|
|
216
|
+
def initialize: (Discorb::json data) -> void
|
|
217
|
+
|
|
218
|
+
# @return [Symbol] The desktop status of the user.
|
|
219
|
+
attr_reader desktop: Symbol
|
|
220
|
+
|
|
221
|
+
# @return [Symbol] The mobile status of the user.
|
|
222
|
+
attr_reader mobile: Symbol
|
|
223
|
+
|
|
224
|
+
# @return [Symbol] The web status of the user.
|
|
225
|
+
attr_reader web: Symbol
|
|
226
|
+
|
|
227
|
+
# @return [Boolean] Whether the user is not offline on desktop.
|
|
228
|
+
attr_reader desktop?: bool
|
|
229
|
+
|
|
230
|
+
# @return [Boolean] Whether the user is not offline on mobile.
|
|
231
|
+
attr_reader mobile?: bool
|
|
232
|
+
|
|
233
|
+
# @return [Boolean] Whether the user is not offline on web.
|
|
234
|
+
attr_reader web?: bool
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a reaction to a message.
|
|
4
|
+
class Reaction < Discorb::DiscordModel
|
|
5
|
+
#
|
|
6
|
+
# Initialize a new reaction.
|
|
7
|
+
# @private
|
|
8
|
+
#
|
|
9
|
+
# @param [Discorb::Message] message The message that this reaction is on.
|
|
10
|
+
# @param [Hash] data The data of the reaction.
|
|
11
|
+
def initialize: (Discorb::Message message, Discorb::json data) -> void
|
|
12
|
+
|
|
13
|
+
#
|
|
14
|
+
# Fetch the user that reacted with this emoji.
|
|
15
|
+
#
|
|
16
|
+
# @param (see Message#fetch_reacted_users)
|
|
17
|
+
#
|
|
18
|
+
# @return [Async::Task<Array<Discorb::User>>] The users that reacted with this emoji.
|
|
19
|
+
def fetch_users: -> Async::Task[::Array[Discorb::User]]
|
|
20
|
+
|
|
21
|
+
# @return [Integer] The number of users that have reacted with this emoji.
|
|
22
|
+
attr_reader count: Integer
|
|
23
|
+
|
|
24
|
+
# @return [Discorb::Emoji, Discorb::PartialEmoji] The emoji that was reacted with.
|
|
25
|
+
attr_reader emoji: Discorb::emoji
|
|
26
|
+
|
|
27
|
+
# @return [Discorb::Message] The message that this reaction is on.
|
|
28
|
+
attr_reader message: Discorb::Message
|
|
29
|
+
|
|
30
|
+
# @return [Boolean] Whether client user reacted with this emoji.
|
|
31
|
+
attr_reader me: bool
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents a role in the guild.
|
|
4
|
+
class Role < Discorb::DiscordModel
|
|
5
|
+
include Comparable
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Initializes a new role.
|
|
9
|
+
# @private
|
|
10
|
+
#
|
|
11
|
+
# @param [Discorb::Client] client The client.
|
|
12
|
+
# @param [Discorb::Guild] guild The guild the role belongs to.
|
|
13
|
+
# @param [Hash] data The data of the role.
|
|
14
|
+
def initialize: (
|
|
15
|
+
Discorb::Client client,
|
|
16
|
+
Discorb::Guild guild,
|
|
17
|
+
Discorb::json data
|
|
18
|
+
) -> void
|
|
19
|
+
|
|
20
|
+
def icon: -> (Discorb::Asset | Discorb::emoji | nil)
|
|
21
|
+
|
|
22
|
+
#
|
|
23
|
+
# Compares two roles by their position.
|
|
24
|
+
#
|
|
25
|
+
# @param [Discorb::Role] other The role to compare to.
|
|
26
|
+
#
|
|
27
|
+
# @return [Integer] -1 if the other role is higher, 0 if they are equal, 1 if the other role is lower.
|
|
28
|
+
def <=>: (Discorb::Role other) -> Integer?
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# Formats the role as a string.
|
|
32
|
+
#
|
|
33
|
+
# @return [String] The formatted string.
|
|
34
|
+
def to_s: -> String
|
|
35
|
+
|
|
36
|
+
def mention: -> String
|
|
37
|
+
|
|
38
|
+
def color?: -> bool
|
|
39
|
+
|
|
40
|
+
def inspect: -> String
|
|
41
|
+
|
|
42
|
+
#
|
|
43
|
+
# Moves the role to a new position.
|
|
44
|
+
# @async
|
|
45
|
+
#
|
|
46
|
+
# @param [Integer] position The new position.
|
|
47
|
+
# @param [String] reason The reason for moving the role.
|
|
48
|
+
#
|
|
49
|
+
# @return [Async::Task<void>] The task.
|
|
50
|
+
def move: (Integer position, ?reason: String?) -> Async::Task[void]
|
|
51
|
+
|
|
52
|
+
#
|
|
53
|
+
# Edits the role.
|
|
54
|
+
# @async
|
|
55
|
+
# @macro edit
|
|
56
|
+
#
|
|
57
|
+
# @param [String] name The new name of the role.
|
|
58
|
+
# @param [Integer] position The new position of the role.
|
|
59
|
+
# @param [Discorb::Color] color The new color of the role.
|
|
60
|
+
# @param [Boolean] hoist Whether the role should be hoisted.
|
|
61
|
+
# @param [Boolean] mentionable Whether the role should be mentionable.
|
|
62
|
+
# @param [Discorb::Image, Discorb::UnicodeEmoji] icon The new icon or emoji of the role.
|
|
63
|
+
# @param [String] reason The reason for editing the role.
|
|
64
|
+
#
|
|
65
|
+
# @return [Async::Task<void>] The task.
|
|
66
|
+
def edit: (
|
|
67
|
+
?name: String,
|
|
68
|
+
?position: Integer,
|
|
69
|
+
?color: Discorb::Color,
|
|
70
|
+
?hoist: bool,
|
|
71
|
+
?mentionable: bool,
|
|
72
|
+
?icon: Discorb::Image | Discorb::UnicodeEmoji,
|
|
73
|
+
?reason: String?
|
|
74
|
+
) -> Async::Task[void]
|
|
75
|
+
|
|
76
|
+
#
|
|
77
|
+
# Deletes the role.
|
|
78
|
+
#
|
|
79
|
+
# @param [String] reason The reason for deleting the role.
|
|
80
|
+
#
|
|
81
|
+
# @return [Async::Task<void>] The task.
|
|
82
|
+
def delete!: (?reason: String?) -> Async::Task[void]
|
|
83
|
+
|
|
84
|
+
def tag: -> Discorb::Role::Tag
|
|
85
|
+
|
|
86
|
+
# @return [Discorb::Snowflake] The ID of the role.
|
|
87
|
+
attr_reader id: Discorb::Snowflake
|
|
88
|
+
|
|
89
|
+
# @return [String] The name of the role.
|
|
90
|
+
attr_reader name: String
|
|
91
|
+
|
|
92
|
+
# @return [Discorb::Color] The color of the role.
|
|
93
|
+
attr_reader color: Discorb::Color
|
|
94
|
+
|
|
95
|
+
# @return [Discorb::Permission] The permissions of the role.
|
|
96
|
+
attr_reader permissions: Discorb::Permission
|
|
97
|
+
|
|
98
|
+
# @return [Integer] The position of the role.
|
|
99
|
+
attr_reader position: Integer
|
|
100
|
+
|
|
101
|
+
# @return [Discorb::Guild] The guild this role belongs to.
|
|
102
|
+
attr_reader guild: Discorb::Guild
|
|
103
|
+
|
|
104
|
+
# @return [Boolean] Whether the role is hoisted.
|
|
105
|
+
attr_reader hoist: bool
|
|
106
|
+
|
|
107
|
+
# @return [Boolean] Whether the role is managed.
|
|
108
|
+
attr_reader managed: bool
|
|
109
|
+
|
|
110
|
+
# @return [Boolean] Whether the role is a default role.
|
|
111
|
+
attr_reader mentionable: bool
|
|
112
|
+
|
|
113
|
+
# @return [Discorb::Asset, nil] The icon of the role.
|
|
114
|
+
attr_reader custom_icon: Discorb::Asset?
|
|
115
|
+
|
|
116
|
+
# @return [Discorb::Emoji, nil] The emoji of the role.
|
|
117
|
+
attr_reader emoji: Discorb::Emoji?
|
|
118
|
+
|
|
119
|
+
#
|
|
120
|
+
# Represents a tag of a role.
|
|
121
|
+
class Tag < Discorb::DiscordModel
|
|
122
|
+
#
|
|
123
|
+
# Initializes a new tag.
|
|
124
|
+
# @private
|
|
125
|
+
#
|
|
126
|
+
# @param [Hash] data The data of the tag.
|
|
127
|
+
def initialize: (json data) -> void
|
|
128
|
+
|
|
129
|
+
# @return [Discorb::Snowflake] The ID of the bot that owns the role.
|
|
130
|
+
attr_reader bot_id: Discorb::Snowflake
|
|
131
|
+
|
|
132
|
+
# @return [Discorb::Snowflake] The ID of the integration.
|
|
133
|
+
attr_reader integration_id: Discorb::Snowflake
|
|
134
|
+
|
|
135
|
+
# @return [Boolean] Whether the tag is a premium subscriber role.
|
|
136
|
+
attr_reader premium_subscriber: bool
|
|
137
|
+
|
|
138
|
+
# @return [Boolean] Whether the role is a bot role.
|
|
139
|
+
attr_reader bot?: bool
|
|
140
|
+
|
|
141
|
+
# @return [Boolean] Whether the role is an integration role.
|
|
142
|
+
attr_reader integration?: bool
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
module Discorb
|
|
2
|
+
#
|
|
3
|
+
# Represents an event in guild.
|
|
4
|
+
class ScheduledEvent < Discorb::DiscordModel
|
|
5
|
+
PRIVACY_LEVEL: untyped
|
|
6
|
+
STATUS: untyped
|
|
7
|
+
ENTITY_TYPE: untyped
|
|
8
|
+
|
|
9
|
+
# @!visibility private
|
|
10
|
+
def initialize: (untyped client, untyped data) -> void
|
|
11
|
+
|
|
12
|
+
#
|
|
13
|
+
# Create a scheduled event for the guild.
|
|
14
|
+
# @async
|
|
15
|
+
#
|
|
16
|
+
# @param [:stage_instance, :voice, :external] type The type of event to create.
|
|
17
|
+
# @param [String] name The name of the event.
|
|
18
|
+
# @param [String] description The description of the event.
|
|
19
|
+
# @param [Time] start_time The start time of the event.
|
|
20
|
+
# @param [Time, nil] end_time The end time of the event. Defaults to `nil`.
|
|
21
|
+
# @param [Discorb::Channel, Discorb::Snowflake, nil] channel The channel to run the event in.
|
|
22
|
+
# @param [String, nil] location The location of the event. Defaults to `nil`.
|
|
23
|
+
# @param [:guild_only] privacy_level The privacy level of the event. This must be `:guild_only`.
|
|
24
|
+
# @param [:active, :completed, :canceled] status The status of the event.
|
|
25
|
+
#
|
|
26
|
+
# @return [Async::Task<Discorb::ScheduledEvent>] The event that was created.
|
|
27
|
+
#
|
|
28
|
+
# @see Event#start
|
|
29
|
+
# @see Event#cancel
|
|
30
|
+
# @see Event#complete
|
|
31
|
+
def edit: (
|
|
32
|
+
?type: Symbol,
|
|
33
|
+
?name: String,
|
|
34
|
+
?description: String,
|
|
35
|
+
?start_time: Time,
|
|
36
|
+
?end_time: Time?,
|
|
37
|
+
?privacy_level: Symbol,
|
|
38
|
+
?location: String?,
|
|
39
|
+
?channel: (Discorb::Channel | Discorb::Snowflake)?,
|
|
40
|
+
?status: Symbol
|
|
41
|
+
) -> Async::Task[Discorb::ScheduledEvent]
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Starts the event. Shortcut for `edit(status: :active)`.
|
|
45
|
+
def start: -> untyped
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# Completes the event. Shortcut for `edit(status: :completed)`.
|
|
49
|
+
def complete: -> untyped
|
|
50
|
+
|
|
51
|
+
#
|
|
52
|
+
# Cancels the event. Shortcut for `edit(status: :canceled)`.
|
|
53
|
+
def cancel: -> untyped
|
|
54
|
+
|
|
55
|
+
#
|
|
56
|
+
# Deletes the event.
|
|
57
|
+
# @async
|
|
58
|
+
#
|
|
59
|
+
# @return [Async::Task<void>] The task.
|
|
60
|
+
def delete!: -> Async::Task[void]
|
|
61
|
+
|
|
62
|
+
#
|
|
63
|
+
# Fetches the event users.
|
|
64
|
+
# @async
|
|
65
|
+
#
|
|
66
|
+
# @note You can fetch all of members by not specifying a parameter.
|
|
67
|
+
#
|
|
68
|
+
# @param [Integer] limit The maximum number of users to fetch. Defaults to `100`.
|
|
69
|
+
# @param [#to_s] after The ID of the user to start fetching from. Defaults to `nil`.
|
|
70
|
+
# @param [#to_s] before The ID of the user to stop fetching at. Defaults to `nil`.
|
|
71
|
+
# @param [Boolean] with_member Whether to include the member object of the event. Defaults to `false`.
|
|
72
|
+
# This should be used for manual fetching of members.
|
|
73
|
+
#
|
|
74
|
+
# @return [Async::Task<Array<Discorb::Member>>] The event users.
|
|
75
|
+
def fetch_users: (
|
|
76
|
+
?Integer? limit,
|
|
77
|
+
?before: untyped,
|
|
78
|
+
?after: untyped,
|
|
79
|
+
?with_member: bool
|
|
80
|
+
) -> Async::Task[::Array[Discorb::Member]]
|
|
81
|
+
|
|
82
|
+
# @return [Discorb::Snowflake] The ID of the event.
|
|
83
|
+
attr_reader id: Discorb::Snowflake
|
|
84
|
+
|
|
85
|
+
# @return [String] The name of the event.
|
|
86
|
+
attr_reader name: String
|
|
87
|
+
|
|
88
|
+
# @return [String] The description of the event.
|
|
89
|
+
attr_reader description: String
|
|
90
|
+
|
|
91
|
+
# @return [Time] The time the event starts.
|
|
92
|
+
attr_reader scheduled_start_time: Time
|
|
93
|
+
|
|
94
|
+
# @return [Time] The time the event ends.
|
|
95
|
+
attr_reader scheduled_end_time: Time
|
|
96
|
+
|
|
97
|
+
# @return [:guild_only] The privacy level of the event.
|
|
98
|
+
attr_reader privacy_level: Symbol
|
|
99
|
+
|
|
100
|
+
# @return [:scheduled, :active, :completed, :canceled] The status of the event.
|
|
101
|
+
attr_reader status: Symbol
|
|
102
|
+
|
|
103
|
+
# @return [:stage_instance, :voice, :external] The type of the event.
|
|
104
|
+
attr_reader entity_type: Symbol
|
|
105
|
+
|
|
106
|
+
# @return [Discorb::Snowflake] The ID of the entity the event is for.
|
|
107
|
+
attr_reader entity_id: Discorb::Snowflake
|
|
108
|
+
|
|
109
|
+
# @return [Discorb::ScheduledEvent::Metadata] The metadata of the event.
|
|
110
|
+
attr_reader metadata: Discorb::ScheduledEvent::Metadata
|
|
111
|
+
|
|
112
|
+
# @return [Integer] The user count of the event.
|
|
113
|
+
attr_reader user_count: Integer
|
|
114
|
+
|
|
115
|
+
# @!attribute [r] guild
|
|
116
|
+
# @return [Discorb::Guild, nil] The guild of the event.
|
|
117
|
+
# @!attribute [r] channel
|
|
118
|
+
# @return [Discorb::Channel, nil] The channel of the event.
|
|
119
|
+
# Only present if the event will do in stage instance or voice channel.
|
|
120
|
+
# @!attribute [r] creator
|
|
121
|
+
# @return [Discorb::User] The user who created the event.#
|
|
122
|
+
# @!attribute [r] time
|
|
123
|
+
# @return [Range<Time>] The time range of the event.
|
|
124
|
+
attr_reader guild: untyped
|
|
125
|
+
|
|
126
|
+
# @return [Discorb::Channel, nil] The channel of the event.
|
|
127
|
+
# Only present if the event will do in stage instance or voice channel.
|
|
128
|
+
attr_reader channel: Discorb::Channel?
|
|
129
|
+
|
|
130
|
+
# @return [Discorb::User] The user who created the event.#
|
|
131
|
+
attr_reader creator: Discorb::User
|
|
132
|
+
|
|
133
|
+
# @return [Range<Time>] The time range of the event.
|
|
134
|
+
attr_reader time: ::Range[Time]
|
|
135
|
+
|
|
136
|
+
#
|
|
137
|
+
# Represents the metadata of the event.
|
|
138
|
+
class Metadata
|
|
139
|
+
# @!visibility private
|
|
140
|
+
def initialize: (untyped data) -> void
|
|
141
|
+
|
|
142
|
+
def inspect: -> String
|
|
143
|
+
|
|
144
|
+
# @return [String, nil] The location of the event. Only present if the event is a external event.
|
|
145
|
+
attr_reader location: String?
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|