A discord.py extension for automatic edit tracking
Reason this release was yanked:
caused memory leak due to improper cache purging
Project description
discord-ext-track-edits
A discord.py extension that implements edit tracking for prefix commands, inspired by poise:
- When user edits their message, automatically update bot response
- When user deletes their message, automatically delete corresponding bot response, if it exists.
Usage
The extension contains an EditTrackerCog and an EditTrackableContext. They must
be used together for edit tracking to work.
Responses will be tracked only when you explicitly .reply() to the invocation message.
from datetime import timedelta
from typing import Type, Union
from typing_extensions import override
import discord
from discord.ext import commands
from discord.ext.track_edits import EditTrackerCog, EditTrackableContext
class Bot(commands.Bot):
async def setup_hook(self) -> None:
await self.add_cog(
EditTrackerCog(
self,
max_duration=timedelta(minutes=5),
execute_untracked_edits=True,
ignore_edits_if_not_yet_responded=False,
),
)
@override
async def get_context(
self,
origin: Union[discord.Message, discord.Interaction],
*,
cls: Type[EditTrackableContext] = EditTrackableContext,
) -> EditTrackableContext:
return await super().get_context(origin, cls=cls)
# your usual bot setup code here
Cog options
max_duration: How long to track bot responses for. If set toNone, bot responses will be tracked indefinitely until the process is shut down. (default: 5 minutes)execute_untracked_edits: Whether to execute a command that was previously untracked, for example, when the user makes a typo and edits it into a valid invocation. (default:True)ignore_edits_if_not_yet_responded: Whether to ignore edits on messages that have not been responded to. This happens if the edits happens before the command has sent a response, or if the command does not respond at all. (default:False)
Command options
Command options are supplied through the extras dictionary:
@commands.command(extras={"invoke_on_edit": False})
async def cmd(ctx):
...
invoke_on_edit: Whether to rerun the command if an existing invocation message is edited (default:True)track_deletion: Whether to delete the bot response if an existing invocation message is deleted (default:True)reuse_response: Whether to post subsequent responses as edits to the original response (default:True)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file discord_ext_track_edits-0.1.1.tar.gz.
File metadata
- Download URL: discord_ext_track_edits-0.1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30886a3346625257f99c4acb9ef7e67ab6fb5062910e95b22bc3a94eccbe24ab
|
|
| MD5 |
2bacdfc80cd8396332c9c5e3141aec2c
|
|
| BLAKE2b-256 |
7b806821306520f6abbdc44f70cf17fce831a2d978f35b9b1f61b3741f481bb0
|
File details
Details for the file discord_ext_track_edits-0.1.1-py3-none-any.whl.
File metadata
- Download URL: discord_ext_track_edits-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72de7daf36e00afeb0ca93b48f79ab5ac00ed5182d58e56bdb8272c739d85a50
|
|
| MD5 |
090efe107f73354d9bf8f728bbdca539
|
|
| BLAKE2b-256 |
64cd21cd1d406545793716bf6481f47f7b281c4a0bb5c8272fd8f18406e96b57
|