Class: Posthubify::DiscordResource
- Inherits:
-
Object
- Object
- Posthubify::DiscordResource
- Defined in:
- lib/posthubify/resources/messaging.rb
Overview
Discord community-ops (D6) — role/member/event/pin/DM/settings. account_id scopes to the connected account.
Instance Method Summary collapse
- #assign_role(account_id, guild_id, user_id, role_id) ⇒ Object
- #create_event(account_id, guild_id, body) ⇒ Object
- #delete_event(account_id, guild_id, event_id) ⇒ Object
- #get_event(account_id, guild_id, event_id, with_user_count: nil) ⇒ Object
- #get_settings(account_id) ⇒ Object
-
#initialize(http) ⇒ DiscordResource
constructor
A new instance of DiscordResource.
- #list_channels(account_id) ⇒ Object
- #list_events(account_id, guild_id, with_user_count: nil) ⇒ Object
- #list_members(account_id, guild_id, limit: nil, after: nil) ⇒ Object
- #list_pins(account_id, channel_id) ⇒ Object
- #list_roles(account_id, guild_id) ⇒ Object
- #pin(account_id, channel_id, message_id) ⇒ Object
- #remove_role(account_id, guild_id, user_id, role_id) ⇒ Object
- #send_dm(body) ⇒ Object
- #unpin(account_id, channel_id, message_id) ⇒ Object
- #update_event(account_id, guild_id, event_id, body) ⇒ Object
- #update_settings(account_id, patch) ⇒ Object
Constructor Details
#initialize(http) ⇒ DiscordResource
Returns a new instance of DiscordResource.
788 789 790 |
# File 'lib/posthubify/resources/messaging.rb', line 788 def initialize(http) @http = http end |
Instance Method Details
#assign_role(account_id, guild_id, user_id, role_id) ⇒ Object
801 802 803 804 |
# File 'lib/posthubify/resources/messaging.rb', line 801 def assign_role(account_id, guild_id, user_id, role_id) @http.data('PUT', "/discord/guilds/#{guild_id}/members/#{user_id}/roles/#{role_id}", query: { 'accountId' => account_id }) end |
#create_event(account_id, guild_id, body) ⇒ Object
816 817 818 |
# File 'lib/posthubify/resources/messaging.rb', line 816 def create_event(account_id, guild_id, body) @http.data('POST', "/discord/guilds/#{guild_id}/events", query: { 'accountId' => account_id }, body: body) end |
#delete_event(account_id, guild_id, event_id) ⇒ Object
830 831 832 |
# File 'lib/posthubify/resources/messaging.rb', line 830 def delete_event(account_id, guild_id, event_id) @http.data('DELETE', "/discord/guilds/#{guild_id}/events/#{event_id}", query: { 'accountId' => account_id }) end |
#get_event(account_id, guild_id, event_id, with_user_count: nil) ⇒ Object
820 821 822 823 |
# File 'lib/posthubify/resources/messaging.rb', line 820 def get_event(account_id, guild_id, event_id, with_user_count: nil) @http.data('GET', "/discord/guilds/#{guild_id}/events/#{event_id}", query: { 'accountId' => account_id, 'withUserCount' => with_user_count }) end |
#get_settings(account_id) ⇒ Object
854 855 856 |
# File 'lib/posthubify/resources/messaging.rb', line 854 def get_settings(account_id) @http.data('GET', "/accounts/#{account_id}/discord-settings") end |
#list_channels(account_id) ⇒ Object
850 851 852 |
# File 'lib/posthubify/resources/messaging.rb', line 850 def list_channels(account_id) @http.data('GET', "/accounts/#{account_id}/discord-channels") end |
#list_events(account_id, guild_id, with_user_count: nil) ⇒ Object
811 812 813 814 |
# File 'lib/posthubify/resources/messaging.rb', line 811 def list_events(account_id, guild_id, with_user_count: nil) @http.data('GET', "/discord/guilds/#{guild_id}/events", query: { 'accountId' => account_id, 'withUserCount' => with_user_count }) end |
#list_members(account_id, guild_id, limit: nil, after: nil) ⇒ Object
796 797 798 799 |
# File 'lib/posthubify/resources/messaging.rb', line 796 def list_members(account_id, guild_id, limit: nil, after: nil) @http.data('GET', "/discord/guilds/#{guild_id}/members", query: { 'accountId' => account_id, 'limit' => limit, 'after' => after }) end |
#list_pins(account_id, channel_id) ⇒ Object
834 835 836 |
# File 'lib/posthubify/resources/messaging.rb', line 834 def list_pins(account_id, channel_id) @http.data('GET', "/discord/channels/#{channel_id}/pins", query: { 'accountId' => account_id }) end |
#list_roles(account_id, guild_id) ⇒ Object
792 793 794 |
# File 'lib/posthubify/resources/messaging.rb', line 792 def list_roles(account_id, guild_id) @http.data('GET', "/discord/guilds/#{guild_id}/roles", query: { 'accountId' => account_id }) end |
#pin(account_id, channel_id, message_id) ⇒ Object
838 839 840 |
# File 'lib/posthubify/resources/messaging.rb', line 838 def pin(account_id, channel_id, ) @http.data('PUT', "/discord/channels/#{channel_id}/pins/#{}", query: { 'accountId' => account_id }) end |
#remove_role(account_id, guild_id, user_id, role_id) ⇒ Object
806 807 808 809 |
# File 'lib/posthubify/resources/messaging.rb', line 806 def remove_role(account_id, guild_id, user_id, role_id) @http.data('DELETE', "/discord/guilds/#{guild_id}/members/#{user_id}/roles/#{role_id}", query: { 'accountId' => account_id }) end |
#send_dm(body) ⇒ Object
846 847 848 |
# File 'lib/posthubify/resources/messaging.rb', line 846 def send_dm(body) @http.data('POST', '/discord/dms', body: body) end |
#unpin(account_id, channel_id, message_id) ⇒ Object
842 843 844 |
# File 'lib/posthubify/resources/messaging.rb', line 842 def unpin(account_id, channel_id, ) @http.data('DELETE', "/discord/channels/#{channel_id}/pins/#{}", query: { 'accountId' => account_id }) end |
#update_event(account_id, guild_id, event_id, body) ⇒ Object
825 826 827 828 |
# File 'lib/posthubify/resources/messaging.rb', line 825 def update_event(account_id, guild_id, event_id, body) @http.data('PATCH', "/discord/guilds/#{guild_id}/events/#{event_id}", query: { 'accountId' => account_id }, body: body) end |
#update_settings(account_id, patch) ⇒ Object
858 859 860 |
# File 'lib/posthubify/resources/messaging.rb', line 858 def update_settings(account_id, patch) @http.data('PATCH', "/accounts/#{account_id}/discord-settings", body: patch) end |