rancour 0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 42e2f9a65f4402abdd0fa79fa006e76462727a8028c38bc5205feed56204dd55
4
+ data.tar.gz: 11e03d5d55df794755e9ab12178214aa989927506218ffde8e00d90bcd62cc39
5
+ SHA512:
6
+ metadata.gz: a4cc23578a18ecb841a43a45af2bb10967bcbd1c8bbdc93f071bb669cddf478e875c713964074698fef13ffe0574abfe94875c2844156edb48ae140d525aa6e7
7
+ data.tar.gz: 53f7379a2ef056cf4b4025b92996abc51f0bc83d1c98efa911384494beeb577dab80d138577e401cb04019b53c6376304c67f48e48b58e7b4f402ada469b4b75
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httpx'
4
+
5
+ module Rancour
6
+ class Client
7
+ DISCORD_API_VERSION = 10
8
+
9
+ def initialize(app_id:, bot_token: nil, bearer_token: nil)
10
+ raise 'You must supply either a bot or bearer token' if bot_token.nil? && bearer_token.nil?
11
+
12
+ @app_id = app_id
13
+
14
+ @bot_token = bot_token if bot_token.present?
15
+ @bearer_token = bearer_token if bearer_token.present?
16
+ end
17
+
18
+ def register_application_commands(payload:, guild_id: nil)
19
+ path = '/commands'
20
+ path = "/guilds/#{guild_id}" + path if guild_id.present?
21
+
22
+ response = connection.post(path, json: payload)
23
+ response.raise_for_status
24
+
25
+ response.json
26
+ end
27
+
28
+ private
29
+
30
+ def connection
31
+ @connection ||= HTTPX.with(
32
+ origin: 'https://discord.com',
33
+ base_path: "/api/v#{DISCORD_API_VERSION}/applications/#{@app_id}",
34
+ headers: {
35
+ authorization: authorization_header
36
+ }
37
+ )
38
+ end
39
+
40
+ def authorization_header
41
+ return "Bearer #{@bearer_token}" if @bearer_token.present?
42
+
43
+ "Bot #{@bot_token}"
44
+ end
45
+ end
46
+ end
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ module Rancour
2
+ VERSION = 0.1
3
+ end
data/lib/rancour.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift(__dir__)
4
+
5
+ require 'rancour/client'
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rancour
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Bogan
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-03-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: httpx
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.4'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.4'
26
+ description: A simple gem for working with Discord.
27
+ email:
28
+ - d+rancour@waferbaby.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/rancour.rb
34
+ - lib/rancour/client.rb
35
+ - lib/rancour/interaction.rb
36
+ - lib/rancour/interaction_response.rb
37
+ - lib/rancour/version.rb
38
+ homepage: http://github.com/waferbaby/rancour
39
+ licenses:
40
+ - MIT
41
+ metadata:
42
+ rubygems_mfa_required: 'true'
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">"
49
+ - !ruby/object:Gem::Version
50
+ version: '3.0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.6.2
58
+ specification_version: 4
59
+ summary: A simple Discord wrapper
60
+ test_files: []