GithubHelp home page GithubHelp logo

jordishore / discordautodelete Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eta0/discordautodelete

0.0 0.0 0.0 37 KB

Discord Autodelete is a Discord bot to configure channels that automatically delete messages after a custom delay, written in Python using discord.py and aiosqlite.

License: zlib License

Python 92.18% Dockerfile 7.82%

discordautodelete's Introduction

Discord Autodelete ๐ŸŽ‡

Discord Autodelete is a Discord bot to configure channels that automatically delete messages after a custom delay, written in Python using discord.py and aiosqlite.

Features

This bot comes with three slash commands:

/autodelete enable <channel> <duration>   : Configure a channel for message autodeletion.
/autodelete disable <channnel>            : Turn off message autodeletion for a channel.
/autodelete list                          : List channels with autodeletion enabled.

Channel Setup: /autodelete enable <channel> <duration>

/autodelete enable can both initially set up a channel with autodeletion semantics, and modify previously configured channels. Once autodeletion is enabled in a channel, any new messages will be deleted on a rolling basis with a delay of duration after they were sent.

NOTE: Messages already in the channel will not be deleted.

Duration parsing is provided by the pytimeparse library and handles many intuitive time specifications written in natural language (in English). For instance:

/autodelete enable channel: #general duration: 1 day
/autodelete enable channel: #general duration: 20 minutes
/autodelete enable channel: #general duration: 1h, 20m
/autodelete enable channel: #general duration: 01:20:30
/autodelete enable channel: #general duration: 10s
/autodelete enable channel: #general duration: 2.5 weeks
/autodelete enable channel: #general duration: 52 weeks

Good-to-knows:

  • There is no (reasonable) limit to duration, though ambiguous units of time such as "months" or "years" cannot be specified directly. Try counting by days instead for very long periods of time.
  • The bot handles long durations effectively by storing new messages and their scheduled deletion time in a persistent SQLite database, and incrementally updating it during execution and at startup, based on the bot's last known state.
  • Disabling autodelete in a channel cancels all pending deletions.
  • Modifying the autodelete timer also cancels deletions, as anything prior to the modification is considered "before the channel was configured," and those messages are never touched.

Bot Setup

Discord Autodelete is built for Python 3.9 or later, and is tested on CPython 3.9, CPython 3.11, and PyPy 3.9.

As there is no public bot instance, to host your own instance of the bot:

  1. Install Python if you don't already have it.
  2. Run git clone https://github.com/Eta0/DiscordAutoDelete if you have git installed, or download and unzip the zipped repository through a web browser.
  3. Open that directory.
  4. Register an application through Discord's developer portal.
    1. Find your Application ID on the "General Information" page,
    2. Find your Token on the "Bot" page (you may need to press "Reset Token" to view it),
    3. Open the file named .env and paste the Token onto the end of the first line, after API_TOKEN=
    4. In the same file, paste the Application ID onto the end of the second line, after APPLICATION_ID=. No quotation marks are needed around either.
    5. Join the bot to your server(s) of choice by navigating to the "OAuth2 / URL Generator" page, checking bot, and in the "Bot Permissions" matrix checking Read Messages/View Channels, Read Message History, and Manage Messages, and then navigating to the generated URL.
    6. (Optional) Uncheck "Public Bot" on the "Bot" page if you want to be the only one who can use the link generated in step 5.
  5. In a terminal opened to the bot installation directory, run python -m pip install -e ..
  6. Launch the bot by running python -m discord_autodelete or simply discord-autodelete (note the dash on the second one).

Run python -m discord_autodelete --help for more information about launch options. Notably:

IMPORTANT: You need to launch the bot at least once with the --sync flag (python -m discord_autodelete --sync) for commands to appear in your server(s).

Bonus: Replace the installation command with python -m pip install -e .[speed] for more efficiency, with extra dependencies.

License

Discord Autodelete is free and open-source software provided under the zlib license.

  • This project is not affiliated with Discord Inc.

discordautodelete's People

Contributors

eta0 avatar stas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.