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

Adds the ability to define a custom status for a bot #235

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Dakurei
Copy link
Contributor

@Dakurei Dakurei commented Sep 13, 2023

Summary

Possible for some time apparently (https://discord.com/developers/docs/change-log#aug-8-2023)
However, a bot can only define customizable text, no emoji can be defined (With the exception of putting a unicode emoji directly into the status text, only server emojis cannot be used in this way, of course 😎)

image

  • Adds a test/example file for custom status display

Added

  • Method Bot#custom_status= to set custom status
  • Add a test/example file examples/custom_status.rb

Changed

  • Method Bot::update_status‎ to add custom status

@@ -548,7 +548,11 @@ def update_status(status, activity, url, since = 0, afk = false, activity_type =
@streamurl = url
type = url ? 1 : activity_type

activity_obj = activity || url ? { 'name' => activity, 'url' => url, 'type' => type } : nil
activity_obj = if activity_type == 4
{ 'name' => activity, 'type' => type, 'state' => activity }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type here will (or should) always be 4. If something is changed in the logic above and type ends up not 4 then this might cause unwanted behaviour.

Setting 'type' => 4 or 'type' => activity_type might be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only problem I can see is that I used activity_type == 4 instead of type == 4 by mistake, which could have caused inconsistency in some cases.

But there's no reason to hard-code the value instead of using that of the variable, as long as it's the right one that's used and verified by the condition

I force push the change

@tarragon
Copy link

Tested this locally and it worked as expected, looks good to me!

  Possible for some time apparently (https://discord.com/developers/docs/change-log#aug-8-2023)
  However, a bot can only define customizable text, no emoji can be defined
  + Adds a test/example file for custom status display
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants