lib_discord 0.1.2 → 1.0.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +88 -0
  3. data/README.md +39 -65
  4. data/lib/lib_discord/client.rb +2665 -138
  5. data/lib/lib_discord/formatter.rb +108 -0
  6. data/lib/lib_discord/maps.rb +731 -0
  7. data/lib/lib_discord/permissions.rb +85 -0
  8. data/lib/lib_discord/urls.rb +3 -12
  9. data/lib/lib_discord/version.rb +1 -4
  10. data/lib/lib_discord.rb +3 -5
  11. metadata +10 -119
  12. data/CHANGELOG.md +0 -142
  13. data/lib/lib_discord/application.rb +0 -43
  14. data/lib/lib_discord/application_command.rb +0 -341
  15. data/lib/lib_discord/application_role_connection_metadata.rb +0 -52
  16. data/lib/lib_discord/audit_log.rb +0 -36
  17. data/lib/lib_discord/auto_moderation.rb +0 -106
  18. data/lib/lib_discord/channel.rb +0 -716
  19. data/lib/lib_discord/emoji.rb +0 -106
  20. data/lib/lib_discord/errors.rb +0 -31
  21. data/lib/lib_discord/guild.rb +0 -830
  22. data/lib/lib_discord/guild_scheduled_event.rb +0 -133
  23. data/lib/lib_discord/guild_template.rb +0 -128
  24. data/lib/lib_discord/interaction.rb +0 -163
  25. data/lib/lib_discord/invite.rb +0 -47
  26. data/lib/lib_discord/mappers/application_command_option_types.rb +0 -22
  27. data/lib/lib_discord/mappers/application_command_permission_types.rb +0 -14
  28. data/lib/lib_discord/mappers/application_command_types.rb +0 -14
  29. data/lib/lib_discord/mappers/application_integration_types.rb +0 -13
  30. data/lib/lib_discord/mappers/application_role_connection_metadata_types.rb +0 -19
  31. data/lib/lib_discord/mappers/audit_log_events.rb +0 -67
  32. data/lib/lib_discord/mappers/auto_moderation_action_types.rb +0 -14
  33. data/lib/lib_discord/mappers/auto_moderation_event_types.rb +0 -12
  34. data/lib/lib_discord/mappers/auto_moderation_keyword_preset_types.rb +0 -14
  35. data/lib/lib_discord/mappers/auto_moderation_trigger_types.rb +0 -15
  36. data/lib/lib_discord/mappers/channel_forum_layout_types.rb +0 -14
  37. data/lib/lib_discord/mappers/channel_message_activity_types.rb +0 -15
  38. data/lib/lib_discord/mappers/channel_message_types.rb +0 -42
  39. data/lib/lib_discord/mappers/channel_sort_order_types.rb +0 -13
  40. data/lib/lib_discord/mappers/channel_types.rb +0 -24
  41. data/lib/lib_discord/mappers/channel_video_quality_modes.rb +0 -13
  42. data/lib/lib_discord/mappers/guild_default_message_notification_levels.rb +0 -13
  43. data/lib/lib_discord/mappers/guild_explicit_content_filter_levels.rb +0 -14
  44. data/lib/lib_discord/mappers/guild_integration_expire_behaviors.rb +0 -13
  45. data/lib/lib_discord/mappers/guild_mfa_levels.rb +0 -13
  46. data/lib/lib_discord/mappers/guild_nsfw_levels.rb +0 -15
  47. data/lib/lib_discord/mappers/guild_onboarding_modes.rb +0 -13
  48. data/lib/lib_discord/mappers/guild_premium_tiers.rb +0 -15
  49. data/lib/lib_discord/mappers/guild_prompt_types.rb +0 -13
  50. data/lib/lib_discord/mappers/guild_scheduled_event_entity_types.rb +0 -14
  51. data/lib/lib_discord/mappers/guild_scheduled_event_privacy_levels.rb +0 -12
  52. data/lib/lib_discord/mappers/guild_scheduled_event_statuses.rb +0 -15
  53. data/lib/lib_discord/mappers/guild_verification_levels.rb +0 -16
  54. data/lib/lib_discord/mappers/interaction_callback_types.rb +0 -19
  55. data/lib/lib_discord/mappers/interaction_context_types.rb +0 -14
  56. data/lib/lib_discord/mappers/interaction_types.rb +0 -16
  57. data/lib/lib_discord/mappers/invite_target_types.rb +0 -13
  58. data/lib/lib_discord/mappers/message_component_button_styles.rb +0 -16
  59. data/lib/lib_discord/mappers/message_component_text_input_styles.rb +0 -13
  60. data/lib/lib_discord/mappers/message_component_types.rb +0 -19
  61. data/lib/lib_discord/mappers/poll_layout_types.rb +0 -12
  62. data/lib/lib_discord/mappers/stage_instance_privacy_levels.rb +0 -13
  63. data/lib/lib_discord/mappers/sticker_format_types.rb +0 -15
  64. data/lib/lib_discord/mappers/sticker_types.rb +0 -13
  65. data/lib/lib_discord/mappers/user_premium_types.rb +0 -15
  66. data/lib/lib_discord/mappers/user_visibility_types.rb +0 -13
  67. data/lib/lib_discord/mappers/webhooks_types.rb +0 -14
  68. data/lib/lib_discord/mappers.rb +0 -87
  69. data/lib/lib_discord/poll.rb +0 -62
  70. data/lib/lib_discord/resource.rb +0 -133
  71. data/lib/lib_discord/response.rb +0 -43
  72. data/lib/lib_discord/stage_instance.rb +0 -79
  73. data/lib/lib_discord/sticker.rb +0 -132
  74. data/lib/lib_discord/types.rb +0 -47
  75. data/lib/lib_discord/user.rb +0 -174
  76. data/lib/lib_discord/voice.rb +0 -29
  77. data/lib/lib_discord/webhook.rb +0 -299
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee336f29f9c16524420b8b087cd245de9cc80f35ee27c1d0036c0983b2042d18
4
- data.tar.gz: bca8789409c439b82d3bec3b69122c992672b89f35318ee91a1e173fd3ce8589
3
+ metadata.gz: c1a0beb8d0144d659fc3dbfc1f33edb87d7fdfc771e36980b42e43c78ed4de32
4
+ data.tar.gz: fefe8a73bf5e0dac39f00fa071f4dfb6e68b465cdf4c51d009483de458b646b3
5
5
  SHA512:
6
- metadata.gz: 0d3c5d14694598880a30b2b061079dedba3ce3911bc64b1c58f340ab8812e97651d25bff73b62c358ad7501203d6d3c1d0394c89f939c3e6a50cd6fbf6db6da7
7
- data.tar.gz: b4c989d2ded1f3a95bd037f7ca111cb3258e54df90eac9de3342d4d348546ca2ef63a503dc1c35895f63af382669d3eb967eb5a4db80a8659cdaa09f166d31ec
6
+ metadata.gz: a0a767f10119c2a8b0904fc9ae4e1323ac336de28f5d7b2cfb37adc01bf5770f860152fcfd24677ed476a9d4e1dec77a17978a7bd62f7196d95b0e752fc30e5f
7
+ data.tar.gz: 94ef92b3286e644d5e5f810968fe1c2a31a8c1a9c6dd99e24edcdacd1928c5ca519134fd231a2dda337a285966a284d63b3149e4fbf89a71d456ba4588c39c43
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,88 @@
1
+ # CONTRIBUTING
2
+
3
+ [project]: https://sr.ht/~komidore64/lib_discord
4
+ [sources]: https://sr.ht/~komidore64/lib_discord/sources
5
+ [mailing lists]: https://sr.ht/~komidore64/lib_discord/lists
6
+ [bug tracker]: https://todo.sr.ht/~komidore64/lib_discord
7
+
8
+ Bug reports and patch submissions are welcome on SourceHut via the [bug
9
+ tracker] and [mailing lists], respectively.
10
+
11
+ ## Code of Conduct
12
+
13
+ Everyone interacting in the lib_discord project's codebases, bug trackers, chat
14
+ rooms, and mailing lists is expected to follow the [code of
15
+ conduct](https://git.sr.ht/~komidore64/lib_discord/tree/main/item/CODE_OF_CONDUCT.md).
16
+
17
+ ## Necessary Development Tools
18
+
19
+ ### Ruby Runtime
20
+
21
+ lib_discord is written in Ruby. A Ruby runtime is required. Our recommendation
22
+ is to use [asdf](https://asdf-vm.com/) and
23
+ [asdf-ruby](https://github.com/asdf-vm/asdf-ruby) to manage your local ruby
24
+ installation.
25
+
26
+ ## Code Style
27
+
28
+ This project adheres to [Standard Ruby](https://github.com/standardrb/standard)
29
+ style rules.
30
+
31
+ Additionally, we strive for an 80 character line length, but it's not a
32
+ hard-and-fast rule. There are occasions where breaking an expression across
33
+ multiple lines makes it more difficult to understand. In these instances the
34
+ line breaks do nothing more than appease a linter. As such, there is no
35
+ automated tooling to enforce an 80 character line length. Favor readability.
36
+
37
+ ## Submitting Patches
38
+
39
+ We respect the intellectual property rights of others and want to ensure all
40
+ incoming contributions are attributed and licensed. The DCO is a declaration
41
+ attached to every contribution made by every developer. In the commit message,
42
+ the developer adds a `Signed-off-by` trailer ([`git commit -s`]) to sign that
43
+ they agree to the DCO. The contents of the agreement can be found below, or at
44
+ [DeveloperCertificate.org](https://developercertificate.org/).
45
+
46
+ [`git commit -s`]: https://git-scm.com/docs/git-commit#Documentation/git-commit.txt--s
47
+
48
+ ```
49
+ Developer Certificate of Origin
50
+ Version 1.1
51
+
52
+ Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
53
+
54
+ Everyone is permitted to copy and distribute verbatim copies of this
55
+ license document, but changing it is not allowed.
56
+
57
+
58
+ Developer's Certificate of Origin 1.1
59
+
60
+ By making a contribution to this project, I certify that:
61
+
62
+ (a) The contribution was created in whole or in part by me and I
63
+ have the right to submit it under the open source license
64
+ indicated in the file; or
65
+
66
+ (b) The contribution is based upon previous work that, to the best
67
+ of my knowledge, is covered under an appropriate open source
68
+ license and I have the right under that license to submit that
69
+ work with modifications, whether created in whole or in part
70
+ by me, under the same open source license (unless I am
71
+ permitted to submit under a different license), as indicated
72
+ in the file; or
73
+
74
+ (c) The contribution was provided directly to me by some other
75
+ person who certified (a), (b) or (c) and I have not modified
76
+ it.
77
+
78
+ (d) I understand and agree that this project and the contribution
79
+ are public and that a record of the contribution (including all
80
+ personal information I submit with it, including my sign-off) is
81
+ maintained indefinitely and may be redistributed consistent with
82
+ this project or the open source license(s) involved.
83
+ ```
84
+
85
+ We require that every contribution to lib_discord is signed with a Developer
86
+ Certificate of Origin. Please use your real name or a pseudonym, and an email
87
+ address at which you may be contacted in the future if the (unlikely) need
88
+ arises. Patches submitted without a signed DCO **will not be accepted**.
data/README.md CHANGED
@@ -5,19 +5,20 @@
5
5
  [mailing lists]: https://sr.ht/~komidore64/lib_discord/lists
6
6
  [bug tracker]: https://todo.sr.ht/~komidore64/lib_discord
7
7
 
8
- Unfancy Ruby-bindings to interact with Discord's HTTPS/REST web API.
8
+ Straightforward Ruby-bindings to interact with Discord's Web API.
9
9
 
10
10
  [project] -- [sources] -- [mailing lists] -- [bug tracker]
11
11
 
12
+ [![Please don't upload to GitHub](https://nogithub.codeberg.page/badge.svg)](https://nogithub.codeberg.page)
12
13
  [![builds.sr.ht status](https://builds.sr.ht/~komidore64/lib_discord/commits/main/.build.yml.svg)](https://builds.sr.ht/~komidore64/lib_discord/commits/main/.build.yml)
13
14
  [![Gem Version](https://badge.fury.io/rb/lib_discord.svg)](https://rubygems.org/gems/lib_discord)
14
15
 
15
16
  ## Installation
16
17
 
17
18
  `lib_discord` requires an installed [Ruby runtime](https://www.ruby-lang.org/)
18
- `>= 3.2`.
19
+ `>= 3.3`.
19
20
 
20
- Install the gem and add to the application's Gemfile by executing:
21
+ Install the gem and add it to your application's Gemfile by executing:
21
22
 
22
23
  ```sh
23
24
  bundle add lib_discord
@@ -32,91 +33,64 @@ gem install lib_discord
32
33
 
33
34
  ## Usage
34
35
 
36
+ Use the Client for communicating with Discord's web endpoints
37
+
35
38
  ```ruby
36
39
  require "lib_discord"
37
- client = LibDiscord::Client.new("Bot my.amazing.bot.token")
40
+
41
+ client = LibDiscord.client("Bot my.amazing.bot.token") # => LibDiscord::Client
42
+ resp = client.create_message("<channel_id>", {content: "Hi, Mom!"}) # => LibDiscord::Response
43
+ resp.success? # => true
38
44
  ```
39
45
 
40
- Access resource types with `#[]` syntax:
46
+ Compare permissions:
41
47
 
42
48
  ```ruby
43
- client.keys
44
- # =>
45
- # ["application",
46
- # "application_command",
47
- # "application_role_connection_metadata",
48
- # "audit_log",
49
- # "auto_moderation",
50
- # "channel",
51
- # "emoji",
52
- # "guild",
53
- # "guild_scheduled_event",
54
- # "guild_template",
55
- # "interaction",
56
- # "invite",
57
- # "poll",
58
- # "stage_instance",
59
- # "sticker",
60
- # "user",
61
- # "voice",
62
- # "webhook"]
63
-
64
- client["application"]
65
- # => #<LibDiscord::Application: ... >
66
- ```
49
+ p = LibDiscord.permissions # => Hash
67
50
 
68
- Use resources to make requests to Discord's API. LibDiscord resources are
69
- mapped to the "Resources" described in [Discord's developer documentation].
51
+ my_permissions = p[:SEND_MESSAGES] + p[:ADD_REACTIONS] # => 2112
70
52
 
71
- ```ruby
72
- resp = client["guild"].get_guild_channels(guild_id: "12345678901234567890")
53
+ # Check for permission flags that are set.
54
+ my_permissions & p[:SEND_MESSAGES] == p[:SEND_MESSAGES] # => true
73
55
 
74
- resp.code
75
- # => 200
56
+ # Check for permission flags that are not set.
57
+ my_permissions & p[:KICK_MEMBERS] == p[:KICK_MEMBERS] # => false
58
+ ```
59
+
60
+ Use maps for Discord's encoded values:
76
61
 
77
- resp.headers
78
- # => Hash of HTTP response headers
62
+ ```ruby
63
+ aco_types = LibDiscord.maps[:ApplicationCommand][:OptionTypes] # => Hash
64
+ aco_types[:CHANNEL] # => 7
65
+ ```
79
66
 
80
- resp.body_parsed
81
- # => JSON body deserialized to a Hash
67
+ Format Discord specific objects to render in messages:
82
68
 
83
- resp.body_raw
84
- # => raw response body in String form
69
+ ```ruby
70
+ fmt = LibDiscord.formatter
71
+ fmt.user(12345678) # => "<@12345678>"
85
72
  ```
86
73
 
87
- [Discord's developer documentation]: https://discord.com/developers/docs
74
+ See [documentation](https://rubydoc.info/gems/lib_discord) for more details.
88
75
 
89
76
  ## Getting help
90
77
 
91
- Please use the [mailing lists] if you have questions or need help.
78
+ Please use the [mailing lists] if you have questions or need assistance.
92
79
 
93
80
  ## Contributing
94
81
 
95
82
  Bug reports and patch submissions are welcome on SourceHut via the [bug
96
83
  tracker] and [mailing lists], respectively. This project is intended to be a
97
- safe, welcoming space for collaboration, and contributors are expected to
98
- adhere to the [code of conduct].
99
-
100
- [code of conduct]: https://git.sr.ht/~komidore64/lib_discord/tree/main/item/CODE_OF_CONDUCT.md
101
-
102
- ### Code style
103
-
104
- This project adheres to [Standard Ruby] style rules.
84
+ safe and welcoming space for collaboration. All participants are expected to
85
+ adhere to the [code of
86
+ conduct](https://git.sr.ht/~komidore64/lib_discord/tree/main/item/CODE_OF_CONDUCT.md).
105
87
 
106
- Additionally, we strive for an 80 character line length, but it's not a
107
- hard-and-fast rule. There are occasions where breaking an expression across
108
- multiple lines decreases readability for no benefit other than to appease a
109
- linter. As such, there is no tool to enforce it.
110
-
111
- [Standard Ruby]: https://github.com/standardrb/standard
112
-
113
- ## Code of Conduct
114
-
115
- Everyone interacting in the `lib_discord` project's codebase, bug trackers,
116
- chat rooms, and mailing lists is expected to follow the [code of conduct].
88
+ See
89
+ [CONTRIBUTING.md](https://git.sr.ht/~komidore64/lib_discord/tree/main/item/CONTRIBUTING.md)
90
+ for more details.
117
91
 
118
92
  ## Licenses
119
93
 
120
- See files in the [LICENSES] directory.
121
-
122
- [LICENSES]: https://git.sr.ht/~komidore64/lib_discord/tree/main/item/LICENSES/
94
+ See files in the
95
+ [LICENSES/](https://git.sr.ht/~komidore64/lib_discord/tree/main/item/LICENSES)
96
+ directory.