foobara-discord-api 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 39c2e3b6247ea95acf1fd36deebca574371e5c76ae99eb696d41cb558bd1fa18
4
- data.tar.gz: ce0bf6aa85517da7945593c9b460ac815cb898198f055529c38362515efa8d43
3
+ metadata.gz: cbf7b7490f473ebbea634085c46b70fe2d4c6c2442dfd3fb4827fac69f2f67ad
4
+ data.tar.gz: 1381d836618ce3ab4764f6d655153c19dc98fed3733a1cedd3296a676aad28c4
5
5
  SHA512:
6
- metadata.gz: 122fbba60610364a00e48d6e3cb9b01b678f0391548d1379a0c94f688fda31b354c148e211bcec2e64e6a327e55a510981cc3f5c060651edba7db4bdd8cfefef
7
- data.tar.gz: b5739bd62f61bb8a536b157df436ebcd258daa29b49cfbf5b547a846251956e3ea1ae7b96d70e01c4317993333e878e09718cde5ca035a5e6373c165b74319f4
6
+ metadata.gz: ae333fa1196dedabf0dbaae3dff3c468234c6aa8bee62dc2da3b3184899116876cb770c50a6742f4b81bde8c4e8999633ad4c9409df6cbba05e13c11187f5b66
7
+ data.tar.gz: b6ce4e269a46a48a4459a5b499a319ba2261ed8a6546a0a2809d70ea17d9f539fedf6509523c28cb9360d1b39835c3e595eff73d3603cd32f3e40041587e96e7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.0.3] - 2026-10-09
2
+
3
+ - Make DiscordApi a Foobara domain
4
+
1
5
  ## [0.0.2] - 2026-09-09
2
6
 
3
7
  - Make use of ignore_unexpected_attributes to not error when unsupported attributes are added
data/README.md CHANGED
@@ -1,34 +1,83 @@
1
- #
2
-
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library
6
- into a gem. Put your Ruby code in the file `lib/foobara/empty_ruby_project_generator`. To experiment with that code,
7
- run `bin/console` for an interactive prompt.
1
+ # Foobara::DiscordApi
8
2
 
3
+ This Ruby gem provides an easy way to use the Discord API via Foobara commands.
9
4
 
10
5
  ## Installation
11
6
 
12
- Typical stuff: add `gem "foobara-discord-api"` to your Gemfile or .gemspec file. Or even just
13
- `gem install foobara-discord-api` if just playing with it directly in scripts.
7
+ Typical stuff: add `gem foobara-discord-api` to your Gemfile or .gemspec file. Or even just
8
+ `gem install foobara-discord-api` if just playing with it directly.
14
9
 
15
10
  ## Usage
16
11
 
17
- TODO: Write usage instructions here
12
+ ### Discord setup and credentials
13
+
14
+ To run `CreateMessage`, you'll need a Discord bot/Discord API token and a channel ID.
15
+
16
+ #### How to get Discord bot token
17
+ 1) Go to the[Discord developer portal](https://discord.com/developers).
18
+ 2) Discord will ask you to log in or create an account.
19
+ 3) You need to create a new application.
20
+ 4) Choose the option "build a bot for your sever...".
21
+ 5) Enter the app name and press **create**.
22
+ 6) in the **Token** section, you need to press **Reset token** to generate a new token.
23
+ 7) Your Discord bot is ready!.
24
+
25
+ #### How to add your bot to your Discord server
26
+ 1) In [Discord developer portal](https://discord.com/developers) go to your app.
27
+ 2) Go to **Installation**.
28
+ 3) Under **Guild install**, add **bot** to your scopes and select the permissions your bot needs.
29
+ 4) Save the changes.
30
+ 5) copy the **install link** and enter the URL in your browser. Then, select the server you want to add the bot to.
31
+ 6) Done! Your bot is now added to your server.
32
+
33
+ #### How get the channel ID
34
+ 1) First, go to the Discord server where your bot has the permissions.
35
+ 2) Right click on the channel.
36
+ 3) you will see the **Copy channel ID** option, check it.
37
+ 4) Done! You now have everything you need.
38
+
39
+ ### Send a message
40
+
41
+ Require the gem and run the command with the destination channel ID and the message content:
18
42
 
19
43
  ```ruby
20
- #!/usr/bin/env ruby
44
+ require "foobara/discord_api"
21
45
 
22
- require "foobara/load_dotenv"
23
- Foobara::LoadDotenv.run!(dir: __dir__)
46
+ outcome = Foobara::DiscordApi::CreateMessage.run(
47
+ channel_id: "some-channel-id",
48
+ api_token: "some-api-token",
49
+ content: "Hello, Discord!"
50
+ )
24
51
 
25
- TODO: some example code
52
+ if outcome.success?
53
+ message = outcome.result
54
+ puts "Created message #{message.id} in channel #{message.channel_id}"
55
+ else
56
+ puts outcome.errors_hash
57
+ end
26
58
  ```
59
+
60
+ The `api_token` input can be omitted and defaults to `ENV["DISCORD_API_TOKEN"]`.
61
+
27
62
  ## Contributing
28
63
 
29
- Bug reports and pull requests are welcome on GitHub
30
- at https://github.com/foobara/discord-api
64
+ Bug reports and pull requests are welcome on Github at https://github.com/foobara/discord-api
65
+
66
+ To work on an existing issue or submit a PR:
67
+
68
+ 1. Fork the `foobara/discord-api` repository and clone it to your local machine.
69
+ 2. Run `bundle install` to install any dependencies.
70
+ 3. Run `rake` to ensure that everything works as expected before making any changes.
71
+ 4. Implement your changes.
72
+ 5. Re-run `rake` to ensure that all tests and RuboCop still pass.
73
+ 6. Commit, push to GitHub and open a PR for review.
74
+
75
+ ## Help
76
+
77
+ If you need help using or contributing to this gem,
78
+ find us on Discord at [https://discord.gg/dDpdFAeCHB](https://discord.gg/dDpdFAeCHB)
79
+ and ask away!
31
80
 
32
81
  ## License
33
82
 
34
- This project is licensed under the MPL-2.0 license. Please see LICENSE.txt for more info.
83
+ This project is licensed under the MPL-2.0 license. Please see [LICENSE.txt](LICENSE.txt) for more info.
@@ -1,3 +1,10 @@
1
1
  require "foobara/all"
2
2
  require "foobara/http_api_command"
3
+
4
+ module Foobara
5
+ module DiscordApi
6
+ foobara_domain!
7
+ end
8
+ end
9
+
3
10
  Foobara::Util.require_directory "#{__dir__}/../../src"
@@ -4,7 +4,7 @@ module Foobara
4
4
  inputs do
5
5
  channel_id :string, :required
6
6
  content :string, :required
7
- api_token :string, :sensitive_exposed, default: -> { ENV["DISCORD_API_TOKEN"] }
7
+ api_token :string, :sensitive, default: -> { ENV["DISCORD_API_TOKEN"] }
8
8
  end
9
9
 
10
10
  result Message
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-discord-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 4.0.10
86
+ rubygems_version: 4.0.20
87
87
  specification_version: 4
88
88
  summary: An easy way to use the Discord API as Foobara commands
89
89
  test_files: []