Skip to content

feat: cache voice channel info from gateway#3210

Open
plun1331 wants to merge 14 commits intomasterfrom
feat/channel-status-gateway
Open

feat: cache voice channel info from gateway#3210
plun1331 wants to merge 14 commits intomasterfrom
feat/channel-status-gateway

Conversation

@plun1331
Copy link
Copy Markdown
Member

@plun1331 plun1331 commented Apr 20, 2026

Caution

Feature freeze is active, as described by our Release Schedule.

Summary

https://docs.discord.com/developers/change-log#voice-channel-status-and-start-time-documentation

  • Adds support for Request Channel Info
  • Adds a flag to Client to automatically request and cache channel info at startup (cache_channel_info, default False)
  • Adds voice_channel_start_time_update event
  • Adds voice_start_time to voice channels.
  • Reworks how status is stored on voice channels.

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.
  • AI Usage has been disclosed.
    • If AI has been used, I understand fully what the code does

@pycord-app
Copy link
Copy Markdown

pycord-app Bot commented Apr 20, 2026

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/3210/head:pr-3210
git checkout pr-3210

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3210/head

@plun1331 plun1331 marked this pull request as ready for review April 20, 2026 23:22
@plun1331 plun1331 requested review from a team, Lumabots and Paillat-dev April 20, 2026 23:22
@plun1331 plun1331 requested a review from a team as a code owner April 20, 2026 23:22
@plun1331 plun1331 requested review from Icebluewolf and Soheab April 20, 2026 23:22
@plun1331
Copy link
Copy Markdown
Member Author

Test code I've been using:

import asyncio

import discord
import logging

logging.basicConfig(level=logging.DEBUG)

client = discord.Client(cache_channel_info=True, intents=discord.Intents.all(), chunk_guilds_at_startup=False)


@client.event
async def on_ready():
    while True:
        for channel in client.get_all_channels():
            if hasattr(channel, "voice_start_time") and channel.voice_start_time:
                print("rec", getattr(channel, "status", ...), channel.voice_start_time)


@client.event
async def on_voice_channel_status_update(channel, old, new):
    print("status", channel.status, channel.voice_start_time, old, new)


@client.event
async def on_voice_channel_start_time_update(channel, old, new):
    print("start", channel.status, channel.voice_start_time, old, new)


client.run("token")

@plun1331
Copy link
Copy Markdown
Member Author

Needs input: API for ChannelInfo and Guild.channel_info()

@plun1331 plun1331 added the feature Implements a feature label Apr 20, 2026
@Paillat-dev Paillat-dev self-assigned this Apr 22, 2026
Comment thread discord/client.py

.. versionadded:: 2.8
cache_channel_info: :class:`bool`
Whether to automatically request and cache channel statuses on startup. Defaults to ``False``.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Whether to automatically request and cache channel statuses on startup. Defaults to ``False``.
Whether to automatically request and cache voice channel statuses on startup. Defaults to ``False``.

Comment thread discord/guild.py
if not self._state.is_guild_evicted(self):
return await self._state.chunk_guild(self, cache=cache)

async def channel_info(self, *, cache: bool = True) -> None | list[ChannelInfo]:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't really like async methods that have attribute-like names. We have many in the lib already but I don't think we should create new ones when we have the opportunity to. I think you mentioned something about this naming as well (?)
Some ideas:

  • request_channel_info
  • fetch_channel_info

Comment thread discord/guild.py
Raises
------
ClientException
The members intent is not enabled.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe have a "this requires the members intent" notice in the main docstring body similar to how it's done in other places

Comment thread discord/raw_models.py
The guild ID where the voice channel start time update originated from.
voice_start_time: Optional[:class:`datetime.datetime`]
The new new voice channel start time.
data: :class:`dict`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to document this ?

Comment thread discord/state.py
self._get_guild,
cache=cache,
)
ws = self._get_websocket(guild.id) # This is ignored upstream
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

wdym

@Paillat-dev Paillat-dev requested review from a team and JustaSqu1d April 22, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants