diff --git a/lib/discordrb/bot.rb b/lib/discordrb/bot.rb index d3f42e107..43b55177e 100644 --- a/lib/discordrb/bot.rb +++ b/lib/discordrb/bot.rb @@ -505,7 +505,8 @@ def parse_mention(mention, server = nil) # @param url [String, nil] The Twitch URL to display as a stream. nil for no stream. # @param since [Integer] When this status was set. # @param afk [true, false] Whether the bot is AFK. - # @param activity_type [Integer] The type of activity status to display. Can be 0 (Playing), 1 (Streaming), 2 (Listening), 3 (Watching) + # @param activity_type [Integer] The type of activity status to display. + # Can be 0 (Playing), 1 (Streaming), 2 (Listening), 3 (Watching), or 5 (Competing). # @see Gateway#send_status_update def update_status(status, activity, url, since = 0, afk = false, activity_type = 0) gateway_check @@ -558,6 +559,14 @@ def stream(name, url) name end + # Sets the currently competing status to the specified name. + # @param name [String] The name of the game to be competing in. + # @return [String] The game that is being competed in now. + def competing=(name) + gateway_check + update_status(@status, name, nil, nil, nil, 5) + end + # Sets status to online. def online gateway_check diff --git a/lib/discordrb/data/activity.rb b/lib/discordrb/data/activity.rb index c665983e5..0de16a684 100644 --- a/lib/discordrb/data/activity.rb +++ b/lib/discordrb/data/activity.rb @@ -17,7 +17,7 @@ class Activity # @return [String] the activity's name attr_reader :name - # @return [Integer, nil] activity type. Can be {GAME}, {STREAMING}, {LISTENING}, {CUSTOM} + # @return [Integer, nil] activity type. Can be {GAME}, {STREAMING}, {LISTENING}, {CUSTOM}, or {COMPETING} attr_reader :type # @return [String, nil] stream URL, when the activity type is {STREAMING} @@ -67,6 +67,8 @@ class Activity WATCHING = 3 # Type indicating the activity is a custom status CUSTOM = 4 + # Type indicating the activity is for a competitive game + COMPETING = 5 # @!visibility private def initialize(data, bot) @@ -260,5 +262,10 @@ def watching def custom_status @activities.select { |act| act.type == Activity::CUSTOM } end + + # @return [Array] all activities of type {Activity::COMPETING} + def competing + @activities.select { |act| act.type == Activity::COMPETING } + end end end