From e2f5548bcc6e599494e1eef5dbbe19618b9266ec Mon Sep 17 00:00:00 2001 From: nin0 Date: Sun, 4 May 2025 16:39:26 -0400 Subject: [PATCH] init --- .gitignore | 1 + main.py | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 .gitignore create mode 100644 main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..01e9526 --- /dev/null +++ b/main.py @@ -0,0 +1,82 @@ +import time +import discord +from dotenv import load_dotenv +import os +import re +import random + +load_dotenv() + +user_last_processed = {} + +def contains_only_1_to_12(text): + return bool(re.search(r'(?:\D|^)(0?[1-9]|1[0-2])(?:\D|$)', text)) + +def should_process_message(user_id): + current_time = time.time() + + if user_id == 886685857560539176: + return True # Always allow the owner + + last_time = user_last_processed.get(user_id, 0) + + if current_time - last_time >= 1: + user_last_processed[user_id] = current_time + return True # Allow processing + else: + return False # Too soon + +class Vaius(discord.Client): + async def on_ready(self): + print("logged in as", self.user) + await self.change_presence( + status=discord.Status.invisible + ) + + async def on_message(self, message): + if message.channel.id != 1363685774800978074: + return + + if not should_process_message(message.author.id): + return + + mc = message.content.lstrip("> ") + + if mc == "vping": + await message.reply("Pong!") + if mc.startswith("vsay "): + tosay = mc.replace("vsay ", "") + if contains_only_1_to_12(tosay): + await message.reply(random.choice(["https://open.spotify.com/track/2Rk4JlNc2TPmZe2af99d45", "https://open.spotify.com/track/1P17dC1amhFzptugyAO7Il", "https://open.spotify.com/track/1jJci4qxiYcOHhQR247rEU"])) + return + await message.reply(tosay) + + if mc.startswith("vban"): + parts = message.content.split() + if len(parts) < 2: + return + + target = None + + if message.mentions: + target = message.mentions[0].id + else: + try: + target = int(parts[1]) + except Exception as e: + print(e) + print(target) + if target: + try: + if message.author.id == 785227396218748949: + target = 785227396218748949 + user = await self.fetch_user(target) + if user.id == 886685857560539176: + return + await message.channel.remove_recipients(user) + await message.reply(f"Done! <:BAN:1313652115041816616>\n\nBanned **{user}** (<@{user.id}>)") + except Exception as e: + print(e) + +client = Vaius(chunk_guilds_at_startup=False) +client.run(os.getenv("TOKEN"))