Module: DSU3::API::Channel

Defined in:
lib/dsu3/api/channel.rb

Overview

Channel API calls

Class Method Summary collapse

Class Method Details

.react(token, channel, message, emoji) ⇒ Object

Note:

To use custom emoji, you must encode it in the format name:id with the emoji name and emoji id

Reacts to a message

Parameters:

  • token (String)

    Discord account token

  • channel (String, Integer)

    Channel ID

  • message (String, Integer)

    Message ID

  • emoji (String)


35
36
37
38
39
40
41
42
43
# File 'lib/dsu3/api/channel.rb', line 35

def react(token, channel, message, emoji)
  emoji = URI.encode_www_form_component(emoji)

  DSU3::API.request(
    token, :put,
    "channels/#{channel}/messages/#{message}/reactions/#{emoji}/@me",
    { params: { location: 'Message' } }
  )
end

.send(token, channel, message) ⇒ Object

Sends a message to a channel

Parameters:

  • token (String)

    Discord account token

  • channel (String, Integer)

    Channel ID

  • message (String, Integer)

    Message contents



22
23
24
25
26
27
# File 'lib/dsu3/api/channel.rb', line 22

def send(token, channel, message)
  DSU3::API.request(
    token, :post, "channels/#{channel}/messages",
    {}, { content: message }.to_json
  )
end

.type(token, channel) ⇒ Object

Types text into a channel

Parameters:

  • token (String)

    Discord account token

  • channel (String, Integer)

    Channel ID



12
13
14
15
16
# File 'lib/dsu3/api/channel.rb', line 12

def type(token, channel)
  DSU3::API.request(
    token, :post, "channels/#{channel}/typing"
  )
end