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

Enhanced Bot Presence: Dynamic Activities and Status Updates #345

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

Conversation

dehlirious
Copy link
Contributor

@dehlirious dehlirious commented Oct 14, 2023

Streamlining Discord Bot Presence with Dynamic Activity and Status Management

Quick Overview

This update enables the Discord bot to randomly display one of 81 pre-defined activities every ~35 seconds and adjust its online status (Online, Idle, DND, Invisible) accordingly.

Introduction

Building on that quick overview, the addition of this cog to the bot's architecture allows for a wider range of displayed activities—such as Playing, Watching, Competing, Listening—each accompanied by an appropriate status.

Core Features

  • Dynamic Activities: The bot can display a variety of distinct activities, characterized by inventive descriptors ranging from "exploring quantum mechanics" to "admiring celestial choreography."
  • Adaptive Status: Unlike a static condition, the bot's status adjusts in line with its ongoing activity.
  • Configurable Status: Status can be customized for particular activities or left unspecified to default to 'Online.'

Technical Overview

The core logic resides in a discord.Cog class, equipped with both activity and status services. It maintains an inventory of 81 different activities, each annotated with its type and an optional corresponding status. These activities are randomized and displayed in rotation.

Operational Mechanics

  1. An array of tuples encapsulates the ActivityType, descriptor, and an optional status.
  2. This array is randomized.
  3. The bot cycles through the randomized array, updating its presence based on the current tuple.
  4. Mindful of Discord's rate limits, presence updates occur every 36 seconds.
  5. If the status remains unchanged, it will not be updated to avoid unnecessary rate limit consumption.

Exemplary Code Snippet

self.activity_phrases = [
  (discord.ActivityType.watching, "deep-sea bioluminescence", discord.Status.dnd),
  # Manifests as "Watching deep-sea bioluminescence" in Do Not Disturb mode.
  {'type': 'streaming', 'url': 'https://twitch.tv/yourchannel', 'platform': 'Twitch'}
  # Activates a "watch stream" button when streaming.
]

Testing

I tested it for 5+ minutes on a Windows 10 Machine, and for 5+ minutes on a Ubuntu 22 Machine.

Animation23dasd

One last thing I just realized, ultimately some mention of it in README will have to take place in due time if it's implemented.

Introducing a refined mechanism to govern the bot's activity and status on Discord.
Now, not only does the bot display various activities from a diverse pool, but its status—Online, Idle, Do Not Disturb—can also be contextually aligned with the activity.
This new feature adds a layer of engagement and subtlety, enriching the user experience.

Key Highlights:
Dynamic activities and statuses shuffled at random intervals.
Ability to set specific statuses like 'Do Not Disturb' for particular activities.
@Kav-K
Copy link
Owner

Kav-K commented Oct 14, 2023

Nice work! However this feature seems a bit detached from the idea of this being a GPT discord bot, is there any way you could incorporate GPT3/4 into this somehow?

@dehlirious
Copy link
Contributor Author

dehlirious commented Oct 14, 2023

Nice work! However this feature seems a bit detached from the idea of this being a GPT discord bot, is there any way you could incorporate GPT3/4 into this somehow?

Fair. I'd definitely consider this a general bot feature, rather than a specific gpt bot feature. I feel it's worth the while but I get your point.

Thinking about it, I could make it so the mood/status is determined by gpt, on a slower change interval.
Could be based off what the bot is talking about as well.
Could also make it able to be controlled by command.
But beyond that, I'm fairly empty on ways to include gpt.

The way I'm seeing it, I'd rather have the preset moods than use tokens every ~5 minutes to generate them.

What do you think? Slap it in as is, cut it off entirely, or make it so it uses gpt in some form?

@Kav-K
Copy link
Owner

Kav-K commented Oct 21, 2023

To be fully upfront with you this just seems like an unneccessary feature that doesnt really add much to the project, as much as I think it's cool

@dehlirious
Copy link
Contributor Author

To be fully upfront with you this just seems like an unneccessary feature that doesnt really add much to the project, as much as I think it's cool

All good lol, thanks for being direct.

@Kav-K
Copy link
Owner

Kav-K commented Oct 30, 2023

@dehlirious I had an idea, what if you periodically updated the status of the bot based on the most interesting recent conversation that's happened with the bot? For example, if someone was talking about creating some python code to create a web server, the bot status could update to "just created a python web server". This could be a longer period too to save tokens, and just the initial few messages of conversations can be sent to gpt to determine the most interesting one and to generate the activity snippet. What do you think?

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.

None yet

2 participants