loader image

Reply To: Discord Message Purger [Python App]

What makes us different from other similar websites? Forums Tech Discord Message Purger [Python App] Reply To: Discord Message Purger [Python App]

#8463
thumbtak
Moderator

Bug fix:

import tkinter as tk
from tkinter import scrolledtext, messagebox
import requests
import threading
import time

class DiscordPurgeGUI:
def __init__(self, root):
self.root = root
self.root.title("Discord Vault - Pink Verbosity Purge")
self.root.geometry("800x850")
self.root.configure(bg="#0d0d0d")

# --- Styling (Neon Pink) ---
self.pink = "#ff69b4"
self.gray = "#1a1a1a"
self.text_color = "#ff69b4"

# --- Header ---
tk.Label(root, text="DISCORD MESSAGE PURGER (VERIFIED)", bg="#0d0d0d", fg=self.pink, font=("Courier", 16, "bold")).pack(pady=10)

# --- Help Button ---
self.help_btn = tk.Button(root, text="[ HOW TO GET IDS ]", bg="#333", fg=self.pink,
command=self.show_help, font=("Courier", 10), bd=0)
self.help_btn.pack(pady=5)

# --- Inputs ---
input_frame = tk.Frame(root, bg="#0d0d0d")
input_frame.pack(pady=10)

tk.Label(input_frame, text="AUTH TOKEN:", bg="#0d0d0d", fg=self.pink).grid(row=0, column=0, sticky="e", padx=5)
self.token_entry = tk.Entry(input_frame, width=60, bg=self.gray, fg="white", show="*")
self.token_entry.grid(row=0, column=1, pady=5)

tk.Label(input_frame, text="YOUR USER ID:", bg="#0d0d0d", fg=self.pink).grid(row=1, column=0, sticky="e", padx=5)
self.user_entry = tk.Entry(input_frame, width=60, bg=self.gray, fg="white")
self.user_entry.grid(row=1, column=1, pady=5)

tk.Label(input_frame, text="CHANNEL ID:", bg="#0d0d0d", fg=self.pink).grid(row=2, column=0, sticky="e", padx=5)
self.channel_entry = tk.Entry(input_frame, width=60, bg=self.gray, fg="white")
self.channel_entry.grid(row=2, column=1, pady=5)

# --- Button ---
self.start_btn = tk.Button(root, text="[ EXECUTE PURGE ]", bg=self.pink, fg="black",
command=self.start_thread, font=("Courier", 12, "bold"), width=30)
self.start_btn.pack(pady=15)

# --- Console Output ---
self.log_area = scrolledtext.ScrolledText(root, width=95, height=30, bg="black", fg=self.text_color, font=("Consolas", 9))
self.log_area.pack(pady=10, padx=10)

def show_help(self):
help_text = (
"1. AUTH TOKEN: Open Discord in a browser > F12 > Network Tab > "
"Refresh > Look at any request for the 'Authorization' header.\n\n"
"2. USER ID: Enable 'Developer Mode' in Settings > Advanced. "
"Right-click your profile avatar > Copy User ID.\n\n"
"3. CHANNEL ID: Right-click the channel name or DM > Copy Channel ID."
)
messagebox.showinfo("Credential Guide", help_text)

def log(self, msg, type="INFO"):
prefix = ">>"
if type == "DEL": prefix = "[DELETED]"
if type == "SKIP": prefix = "[SKIPPED]"
if type == "ERR": prefix = "[!! ERROR !!]"

self.log_area.insert(tk.END, f"{prefix} {msg}\n")
self.log_area.see(tk.END)

def start_thread(self):
self.start_btn.config(state="disabled", text="RUNNING...")
# Note: Added confirmation for clarity as per script design
threading.Thread(target=self.run_purge, daemon=True).start()

def run_purge(self):
token = self.token_entry.get().strip()
user_id = self.user_entry.get().strip()
chan_id = self.channel_entry.get().strip()

if not all([token, user_id, chan_id]):
messagebox.showerror("Security Alert", "All ID and Token fields must be populated.")
self.start_btn.config(state="normal", text="[ EXECUTE PURGE ]")
return

headers = {'Authorization': token, 'Content-Type': 'application/json'}
url = f"https://discord.com/api/v9/channels/{chan_id}/messages?limit=100"

self.log(f"Initializing connection to Channel: {chan_id}...")

while True:
try:
res = requests.get(url, headers=headers)

if res.status_code == 401:
self.log("Invalid Token. Check your Authorization header.", "ERR")
break
if res.status_code != 200:
self.log(f"API Error: {res.status_code} | {res.text}", "ERR")
break

messages = res.json()
if not messages:
self.log("No more messages detected in this sector. Operation complete.", "INFO")
break

for msg in messages:
if msg['author']['id'] == user_id:
msg_id = msg['id']
preview = msg['content'][:30].replace('\n', ' ')

del_url = f"https://discord.com/api/v9/channels/{chan_id}/messages/{msg_id}"
del_res = requests.delete(del_url, headers=headers)

if del_res.status_code == 204:
self.log(f"ID: {msg_id} | Content: '{preview}...'", "DEL")
elif del_res.status_code == 429:
self.log("Rate limited by Discord. Cooling down for 5s...", "ERR")
time.sleep(5)

time.sleep(1.6)
else:
self.log(f"ID: {msg['id']} | Author: {msg['author']['username']} (Non-Target)", "SKIP")

if messages:
last_id = messages[-1]['id']
url = f"https://discord.com/api/v9/channels/{chan_id}/messages?limit=100&before={last_id}"
self.log(f"Fetching next batch before ID: {last_id}...")

except Exception as e:
self.log(f"Internal Exception: {e}", "ERR")
break

self.start_btn.config(state="normal", text="[ EXECUTE PURGE ]")

if __name__ == "__main__":
root = tk.Tk()
app = DiscordPurgeGUI(root)
root.mainloop()
TAKs Shack