Websites/app/logical/requests/discord_webhook.rb

23 lines
469 B
Ruby
Raw Normal View History

2024-05-03 03:04:43 +00:00
# frozen_string_literal: true
module Requests
class DiscordWebhook
attr_reader :id, :token
def initialize(id:, token:)
@id = id
@token = token
end
def client
Discordrb::Webhooks::Client.new(id: id, token: token)
2024-05-03 03:04:43 +00:00
end
delegate :execute, :edit_message, :delete, to: :client
2024-05-03 03:04:43 +00:00
def self.is_deleted(error)
error.instance_of?(RestClient::NotFound) && JSON.parse(error.response.body)["code"] == 10_015
2024-05-03 03:04:43 +00:00
end
end
end