From aaf17c5bd19f10942706957cf77564d0487aaddf Mon Sep 17 00:00:00 2001 From: nin0 Date: Sun, 4 May 2025 18:15:42 -0400 Subject: [PATCH] lets go we ball --- main.py | 81 +++++++----------------------------------------- requirements.txt | 1 + 2 files changed, 13 insertions(+), 69 deletions(-) diff --git a/main.py b/main.py index 01e9526..e8dff5b 100644 --- a/main.py +++ b/main.py @@ -1,82 +1,25 @@ -import time import discord +from discord.ext import commands 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): +class Vaius(commands.Bot): async def on_ready(self): - print("logged in as", self.user) - await self.change_presence( - status=discord.Status.invisible - ) + print(f"Logged in as {self.user.name}") - async def on_message(self, message): - if message.channel.id != 1363685774800978074: - return - - if not should_process_message(message.author.id): + async def on_message(self, message: discord.Message): + if (message.guild and message.guild.id != 1362175947612098892) and message.channel.id != 1363685774800978074: return + ctx = await self.get_context(message) + if ctx.valid: + await self.invoke(ctx) - mc = message.content.lstrip("> ") +@Vaius.command +async def ping(self, ctx): + await ctx.reply("Pong!") - 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) +client = Vaius(command_prefix="v", user_bot=True, chunk_guilds_at_startup=False) - 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")) diff --git a/requirements.txt b/requirements.txt index 0debc4a..2e3054e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ aiohappyeyeballs==2.6.1 aiohttp==3.11.18 aiosignal==1.3.2 attrs==25.3.0 +audioop-lts==0.2.1 discord-protos==0.0.2 discord.py-self==2.0.1 frozenlist==1.6.0