Skip to main content

A discord.py extension for automatic edit tracking

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 to None, 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discord_ext_track_edits-0.1.3.post1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

discord_ext_track_edits-0.1.3.post1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file discord_ext_track_edits-0.1.3.post1.tar.gz.

File metadata

  • Download URL: discord_ext_track_edits-0.1.3.post1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for discord_ext_track_edits-0.1.3.post1.tar.gz
Algorithm Hash digest
SHA256 78d4912c397cf3f9c7f1cd4de46082fac53d0365b0d7367b9989a1615a8dc192
MD5 ac265c1623b00e36d557b329841189c6
BLAKE2b-256 445f5060e04f501192801b13ccad454c3c9b1f55c5d97b7f4e6353fd5a025fbd

See more details on using hashes here.

File details

Details for the file discord_ext_track_edits-0.1.3.post1-py3-none-any.whl.

File metadata

  • Download URL: discord_ext_track_edits-0.1.3.post1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for discord_ext_track_edits-0.1.3.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 908179d7402b9a95cd90dedc7857d4651ff1258f00c192a5045e7504cac88eae
MD5 f5682711953571a1ec48ad4de4b73ec9
BLAKE2b-256 675a58dd854a9795e62c292385b7e007d3baba5db1c0730d3f718f60b58265a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page