Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: V4.0 endpoints #284

Open
wants to merge 4 commits into
base: 4.0-staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions discordrb-webhooks.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'faraday', '~> 1.8'
spec.add_dependency 'faraday_middleware', '~> 1.1.0'
spec.add_dependency 'faraday', '~> 2.12.0'
spec.add_dependency 'faraday-multipart', '~> 1.0.4'

spec.required_ruby_version = '>= 2.6'
spec.required_ruby_version = '>= 3.1'
spec.metadata = {
'rubygems_mfa_required' => 'true'
}
end
33 changes: 20 additions & 13 deletions discordrb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
spec.authors = %w[meew0 swarley]
spec.email = ['']

spec.summary = 'Discord API for Ruby'
spec.summary = 'Discord API for Ruby.'
spec.description = 'A Ruby implementation of the Discord (https://discord.com) API.'
spec.homepage = 'https://github.com/shardlab/discordrb'
spec.license = 'MIT'
Expand All @@ -19,28 +19,35 @@ Gem::Specification.new do |spec|
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.metadata = {
'changelog_uri' => 'https://github.com/shardlab/discordrb/blob/master/CHANGELOG.md'
'bug_tracker_uri' => 'https://github.com/shardlab/discordrb/issues',
'changelog_uri' => 'https://github.com/shardlab/discordrb/blob/main/CHANGELOG.md',
'documentation_uri' => 'https://github.com/shardlab/discordrb/wiki',
'source_code_uri' => 'https://github.com/shardlab/discordrb',
'rubygems_mfa_required' => 'true'
}
spec.require_paths = ['lib']

spec.add_dependency 'base64', '~> 0.2.0'
spec.add_dependency 'faraday', '~> 2.12.0'
spec.add_dependency 'faraday-multipart', '~> 1.0.4'
spec.add_dependency 'ffi', '>= 1.9.24'
spec.add_dependency 'opus-ruby'
spec.add_dependency 'faraday', '~> 1.8'
spec.add_dependency 'faraday_middleware', '~> 1.1.0'
spec.add_dependency 'websocket-client-simple', '>= 0.3.0'

spec.add_dependency 'discordrb-webhooks', '~> 3.4.2'
spec.add_dependency 'discordrb-webhooks', '~> 4.0.0'

spec.required_ruby_version = '>= 2.6'
spec.required_ruby_version = '>= 3.1'

spec.add_development_dependency 'sord', '~> 6.0'
spec.add_development_dependency 'bundler', '>= 1.10', '< 3'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'redcarpet', '~> 3.5.0' # YARD markdown formatting
spec.add_development_dependency 'rspec', '~> 3.10.0'
spec.add_development_dependency 'rspec-prof', '~> 0.0.7'
spec.add_development_dependency 'rubocop', '~> 1.21.0'
spec.add_development_dependency 'redcarpet', '~> 3.5' # YARD markdown formatting
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.5'
spec.add_development_dependency 'rspec-prof', '~> 0.0'
spec.add_development_dependency 'rubocop', '~> 1.0'
spec.add_development_dependency 'rubocop-performance', '~> 1.0'
spec.add_development_dependency 'rubocop-rake', '~> 0.6.0'
spec.add_development_dependency 'simplecov', '~> 0.21.0'
spec.add_development_dependency 'yard', '~> 0.9.9'
spec.add_development_dependency 'rubocop-rake', '~> 0.6'
spec.add_development_dependency 'simplecov', '~> 0.21'
spec.add_development_dependency 'yard', '~> 0.9'
end
18 changes: 17 additions & 1 deletion lib/discordrb/api/client.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# frozen_string_literal: true

require 'faraday'
require 'faraday_middleware'
require 'faraday/multipart'
require 'discordrb/api/endpoints/application_command'
require 'discordrb/api/endpoints/application'
require 'discordrb/api/endpoints/audit_log'
require 'discordrb/api/endpoints/auto_moderation'
require 'discordrb/api/endpoints/channel'
require 'discordrb/api/endpoints/emoji'
require 'discordrb/api/endpoints/entitlement'
require 'discordrb/api/endpoints/guild_scheduled_event'
require 'discordrb/api/endpoints/guild'
require 'discordrb/api/endpoints/guild_template'
require 'discordrb/api/endpoints/interaction'
require 'discordrb/api/endpoints/invite'
require 'discordrb/api/endpoints/message'
require 'discordrb/api/endpoints/poll'
require 'discordrb/api/endpoints/sku'
require 'discordrb/api/endpoints/soundboard'
require 'discordrb/api/endpoints/stage_instance'
require 'discordrb/api/endpoints/sticker'
require 'discordrb/api/endpoints/user'
Expand Down Expand Up @@ -99,13 +107,21 @@ def update(data)
# Client for making HTTP requests to the Discord API.
class Client
include ApplicationCommandEndpoints
include ApplicationEndpoints
include AuditLogEndpoints
include AutoModerationEndpoints
include ChannelEndpoints
include EmojiEndpoints
include EntitlementEndpoints
include GuildScheduledEventEndpoints
include GuildEndpoints
include GuildTemplateEndpoints
include InteractionEndpoints
include InviteEndpoints
include MessageEndpoints
include PollEndpoints
include SkuEndpoints
include SoundboardEndpoints
include StageInstanceEndpoints
include StickerEndpoints
include UserEndpoints
Expand Down
65 changes: 65 additions & 0 deletions lib/discordrb/api/endpoints/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# frozen_string_literal: true

module Discordrb
module API
# @!discord_api https://discord.com/developers/docs/resources/application
module ApplicationEndpoints
# @!discord_api https://discord.com/developers/docs/resources/application#get-current-application
# @return [Hash<Symbol, Object>]
def get_current_application(**params)
request Route[:GET, '/applications/@me'], params: params
end

# @!discord_api https://discord.com/developers/docs/resources/application#edit-current-application
# @param custom_install_url [String] Default custom authorization for the URL.
# @param description [String] Description of the app.
# @param role_connections_verification_url [String] Role connection verification URL for the app.
# @param install_params [Hash<Symbol, Object>] Settings for the app's default in-app authorization link.
# @param integration_types_config [Hash] Hash containing supported install types.
# @param flags [Integer] Public flags for the app.
# @param icon [String, #read] A base64 encoded string with the image data.
# @param cover_image [String, #read] A base64 encoded string with the image data.
# @param interactions_endpoint_url [String] An endpoint an app can use to reccive interactions via the REST API.
# @param tags [Array<String>] Tags that describe the functionality of the app.
# @return [Hash<Symbol, Object>]
def edit_current_application(custom_install_url: :undef, description: :undef,
role_connections_verification_url: :undef, install_params: :undef,
integration_types_config: :undef, flags: :undef, icon: :undef,
cover_image: :undef, interactions_endpoint_url: :undef, tags: :undef, **rest)
data = {
custom_install_url: custom_install_url,
description: description,
role_connections_verification_url: role_connections_verification_url,
install_params: install_params,
integration_types_config: integration_types_config,
flags: flags,
icon: icon,
cover_image: cover_image,
interactions_endpoint_url: interactions_endpoint_url,
tags: tags,
**rest
}

request Route[:PATCH, '/applications/@me'],
body: filter_undef(data)
end

# @!discord_api https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records
# @param application_id [Integer, String] An ID that uniquely identifies an application.
# @return [Hash<Symbol, Object>]
def get_application_role_connection_metadata_records(application_id, **params)
request Route[:GET, "/applications/#{application_id}/role-connections/metadata"],
params: params
end

# @!discord_api https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records
# @param application_id [Integer, String] An ID that uniquely identifies an application.
# @param application_role_connection_metadata [Hash<Symbol, Object>] An application role connection metadata object.
# @return [Hash<Symbol, Object>]
def update_application_role_connection_metadata_records(application_id, application_role_connection_metadata, **rest)
request Route[:PUT, "/applications/#{application_id}/role-connections/metadata"],
body: filter_undef({ application_role_connection_metadata: application_role_connection_metadata, **rest })
end
end
end
end
Loading