{"id":28076968,"url":"https://github.com/bjoerrrn/discord-cleaner-bot","last_synced_at":"2025-05-13T01:56:14.619Z","repository":{"id":291272145,"uuid":"977116527","full_name":"bjoerrrn/discord-cleaner-bot","owner":"bjoerrrn","description":"A Discord bot that automatically assigns the \"Cleaner\" role to members who have been inactive (no messages or voice activity) for over 90 days. It also removes all other roles except \"Soldier\", and kicks them after 180 days.","archived":false,"fork":false,"pushed_at":"2025-05-11T16:00:29.000Z","size":106,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-13T01:56:10.184Z","etag":null,"topics":["discord-bot","python"],"latest_commit_sha":null,"homepage":"https://discordapp.com/users/371404709262786561","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bjoerrrn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-03T13:11:59.000Z","updated_at":"2025-05-11T15:59:48.000Z","dependencies_parsed_at":"2025-05-03T15:20:38.990Z","dependency_job_id":"3d7c01d8-5474-4366-9455-964b360b89ad","html_url":"https://github.com/bjoerrrn/discord-cleaner-bot","commit_stats":null,"previous_names":["bjoerrrn/discord-cleaner-bot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoerrrn%2Fdiscord-cleaner-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoerrrn%2Fdiscord-cleaner-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoerrrn%2Fdiscord-cleaner-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoerrrn%2Fdiscord-cleaner-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjoerrrn","download_url":"https://codeload.github.com/bjoerrrn/discord-cleaner-bot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253856631,"owners_count":21974577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["discord-bot","python"],"created_at":"2025-05-13T01:56:14.228Z","updated_at":"2025-05-13T01:56:14.608Z","avatar_url":"https://github.com/bjoerrrn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Discord Cleaner Bot\n\nA Discord bot that automatically assigns the \"Cleaner\" role to members who have been inactive (no messages or voice activity) for over 90 days. It also removes all other roles except \"Soldier\", and kicks them after 180 days.\n\n## Features\n\n- Assigns the @Cleaner role to users inactive for ≥ 3 months\n- Posts a public warning message in #discussion-💬\n- Removes all roles except @Soldier\n- Kicks @Cleaner users after 6 months total inactivity\n- Exempts @Major and @General roles from being kicked\n- Posts original role list for admin reference\n- Activity cache for fast reports and exporting\n- Commands to export activity, report status, and debug unreadable channels\n\n## 📦 Installation \u0026 Setup\n\n### 1. Prerequisites\n\n- Python 3.9+\n- A registered Discord bot: https://discord.com/developers/applications\n- The bot must have the following permissions:\n  - Manage Roles\n  - Kick Members\n  - Read Message History\n  - View Channels\n  - Connect to Voice Channels\n\n### 2. Clone the Repository\n\n```bash\ngit clone https://github.com/bjoerrrn/discord-cleaner-bot.git\ncd discord-cleaner-bot\n```\n\n### 3. Create and Activate a Virtual Environment\n\n```bash\nsudo apt install python3-venv\npython3 -m venv venv\nsource venv/bin/activate\n```\n\n### 4. Install Python Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\nIf no `requirements.txt` is available, install manually:\n\n```bash\npip install discord.py python-dotenv\n```\n\n### 5. Configure Your Environment\n\nCreate a `.env` file in the root directory:\n\n```env\nDISCORD_TOKEN=your-bot-token-here\nDISCORD_GUILD_ID=123456789012345678\n```\n\n### 6. Registering Your Bot in Discord\n\n1. Go to the [Discord Developer Portal](https://discord.com/developers/applications)\n2. Click “New Application” and give it a name\n3. Under “Bot”, click “Add Bot”\n4. Click “Reset Token” → Copy this token and add it to your `.env`\n\n### 7. Invite the Bot to Your Server\n\n1. In the Developer Portal, go to `OAuth2 \u003e URL Generator`\n2. Under scopes, select:\n   - `bot`\n3. Under Bot Permissions, select:\n   - Read Messages/View Channels\n   - Send Messages\n   - Manage Roles\n   - Kick Members\n4. Copy the generated URL and open it in your browser to invite the bot\n\n### 8. Get Your Discord Guild (Server) ID\n\n1. In Discord: `User Settings \u003e Advanced \u003e Enable Developer Mode`\n2. Right-click your server icon → Click \"Copy Server ID\"\n3. Paste this ID into the `.env` file as `DISCORD_GUILD_ID`\n\n---\n\n## 🔁 Run the Bot Automatically with systemd\n\n### 1. Create a systemd Service File\n\n```bash\nsudo nano /etc/systemd/system/discord-cleaner.service\n```\n\nPaste the following, updating paths as needed:\n\n```ini\n[Unit]\nDescription=Discord Cleaner Bot\nAfter=network.target\n\n[Service]\nType=simple\nUser=pi\nWorkingDirectory=/home/pi/discord-cleaner-bot\nExecStart=/home/pi/discord-cleaner-bot/venv/bin/python bot.py\nRestart=always\n\n[Install]\nWantedBy=multi-user.target\n```\n\n### 2. Enable and Start the Service\n\n```bash\nsudo systemctl daemon-reexec\nsudo systemctl daemon-reload\nsudo systemctl enable discord-cleaner\nsudo systemctl start discord-cleaner\n```\n\n### 3. View Logs\n\n```bash\njournalctl -u discord-cleaner -f\n```\n\n---\n\n## 🛠️ Bot Commands\n\nOnly members with the @General role can run these:\n\n- `!commands` – Lists all commands\n- `!lastactive @member` – Shows last activity and join date\n- `!exportactivity` – Exports a full CSV of all members' activity and roles\n- `!unreadable_channels` – Lists channels the bot cannot read\n- `!inactivity_report` – Lists all tracked activity\n- `!inactivity_report clean` – Shows only members near thresholds\n\n---\n\n## 📝 Notes\n\n- Bot scans 5000 messages per channel to build the activity cache\n- All timestamps are stored and displayed in UTC\n- Voice channel activity counts as active\n- The original roles are posted in #discussion-💬 for restoration\n\n---\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjoerrrn%2Fdiscord-cleaner-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjoerrrn%2Fdiscord-cleaner-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjoerrrn%2Fdiscord-cleaner-bot/lists"}