member specific command added

This commit is contained in:
esef committed 2026-06-30 15:54:42 +03:00
1 parent a8afeb40ac
commit a0dbe27884
3 files changed
+166 -140

No files matched your search

+1
View File
@@ -8,6 +8,7 @@ import asyncio
import discord import discord
from discord.ext import commands from discord.ext import commands
from collections import defaultdict, deque from collections import defaultdict, deque
# pyrefly: ignore [missing-import]
from openai import AsyncOpenAI from openai import AsyncOpenAI
#only last 12 messages on discord will be fed into the ai's memory #only last 12 messages on discord will be fed into the ai's memory
+160 -139
View File
@@ -1,139 +1,160 @@
import discord from datetime import timedelta
from aiohttp import client_exceptions from aiohttp import client_exceptions
from discord.ext import commands import discord
import os from aiohttp import client_exceptions
import aiohttp from discord.ext import commands
import feedparser import os
import urllib.parse import aiohttp
import feedparser
class General(commands.Cog): import urllib.parse
def __init__(self, bot):
self.bot = bot class General(commands.Cog):
def __init__(self, bot):
@commands.command() self.bot = bot
async def yuuka(self, ctx):
await ctx.send('kanpeki!') @commands.command()
async def yuuka(self, ctx):
@commands.command() await ctx.send('kanpeki!')
async def leaks(self, ctx):
rss_url = os.getenv('TWITTER_RSS_URL') @commands.command()
if not rss_url: async def leaks(self, ctx):
return await ctx.reply('rss url not configured.') rss_url = os.getenv('TWITTER_RSS_URL')
if not rss_url:
try: return await ctx.reply('rss url not configured.')
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'}
async with aiohttp.ClientSession(headers=headers) as session: try:
async with session.get(rss_url) as resp: headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'}
text = await resp.text() async with aiohttp.ClientSession(headers=headers) as session:
async with session.get(rss_url) as resp:
feed = feedparser.parse(text) text = await resp.text()
if not feed.entries:
return await ctx.reply('no tweets found.') feed = feedparser.parse(text)
if not feed.entries:
response = "**Latest 5 Leaks:**\n" return await ctx.reply('no tweets found.')
for entry in feed.entries[:5]:
title = entry.get('title', '') response = "**Latest 5 Leaks:**\n"
link = entry.get('link', '') for entry in feed.entries[:5]:
title = entry.get('title', '')
if 'nitter.net' in link: link = entry.get('link', '')
link = link.replace('nitter.net', 'twitter.com').replace('#m', '')
if 'nitter.net' in link:
response += f"\n{title}\n{link}\n" link = link.replace('nitter.net', 'twitter.com').replace('#m', '')
await ctx.reply(response[:2000]) response += f"\n{title}\n{link}\n"
except Exception as e:
await ctx.reply(f'failed to fetch leaks: {e}') await ctx.reply(response[:2000])
except Exception as e:
@commands.command() await ctx.reply(f'failed to fetch leaks: {e}')
async def weather(self, ctx, *, city: str = "kayseri"):
try: @commands.command()
city_encoded = urllib.parse.quote(city) async def weather(self, ctx, *, city: str = "kayseri"):
url = f'https://wttr.in/{city_encoded}?0T' try:
async with aiohttp.ClientSession() as session: city_encoded = urllib.parse.quote(city)
async with session.get(url) as resp: url = f'https://wttr.in/{city_encoded}?0T'
if resp.status == 200: async with aiohttp.ClientSession() as session:
weather_data = await resp.text() async with session.get(url) as resp:
await ctx.reply(f'```text\n{weather_data.strip()}\n```') if resp.status == 200:
else: weather_data = await resp.text()
await ctx.reply(f'could not fetch weather for {city}') await ctx.reply(f'```text\n{weather_data.strip()}\n```')
except Exception as e: else:
await ctx.reply(f'weather fetch failed: {e}') await ctx.reply(f'could not fetch weather for {city}')
except Exception as e:
await ctx.reply(f'weather fetch failed: {e}')
@commands.command()
async def purge(self, ctx, amount: int):
if ctx.author.id != int(os.getenv('OWNER_ID')): @commands.command()
return async def purge(self, ctx, amount: int):
await ctx.channel.purge(limit=amount + 1) if ctx.author.id != int(os.getenv('OWNER_ID')):
return
@commands.command() await ctx.channel.purge(limit=amount + 1)
async def ban(self, ctx, *, reason=None):
if ctx.author.id != int(os.getenv('OWNER_ID')): #member specific command, priviliged
return @commands.command()
async def ferox(self, ctx, duration: str):
if not ctx.guild: if ctx.author.id != int(os.getenv("MELLO")):
return return await ctx.reply("you are not her bro")
msg = ctx.message units = {
to_ban = set() "m": timedelta(minutes=1),
"h": timedelta(hours=1),
# Collect targets from mentions "d": timedelta(days=1),
if msg.mention_everyone: "w": timedelta(weeks=1),
for member in ctx.guild.members: }
to_ban.add(member)
amount = int(duration[:-1])
for role in msg.role_mentions: delta = amount * units[duration[-1].lower()]
for member in role.members: ferox = ctx.guild.get_member(int(os.getenv("FEROX")))
to_ban.add(member) await ferox.timeout(discord.utils.utcnow() + delta)
await ctx.reply(f"muted ferox for {duration}, she knows the best")
for user in msg.mentions:
if isinstance(user, discord.Member): @commands.command()
to_ban.add(user) async def ban(self, ctx, *, reason=None):
if ctx.author.id != int(os.getenv('OWNER_ID')):
# Safety checks: never ban the bot itself or the owner return
if ctx.me in to_ban:
to_ban.remove(ctx.me) if not ctx.guild:
if ctx.author in to_ban: return
to_ban.remove(ctx.author)
msg = ctx.message
if not to_ban: to_ban = set()
return await ctx.reply("i couldnt ban, im broken fix me esef :(")
# Collect targets from mentions
# Confirm before banning if msg.mention_everyone:
await ctx.reply(f"Are you sure you want to ban {len(to_ban)} members? Type `yes` or `y` to confirm. (You have 30 seconds to confirm or i wont ban anyone)") for member in ctx.guild.members:
to_ban.add(member)
def check(m):
return m.author == ctx.author and m.channel == ctx.channel for role in msg.role_mentions:
for member in role.members:
try: to_ban.add(member)
import asyncio
response_msg = await self.bot.wait_for('message', timeout=30.0, check=check) for user in msg.mentions:
except asyncio.TimeoutError: if isinstance(user, discord.Member):
return await ctx.reply("Ban wave cancelled (timed out).") to_ban.add(user)
if response_msg.content.lower() not in ('yes', 'y'): # Safety checks: never ban the bot itself or the owner
return await ctx.reply("You didnt say yes so... im not banning until im sure.") if ctx.me in to_ban:
to_ban.remove(ctx.me)
await ctx.reply(f"Okay... banning {len(to_ban)} members, hope you wont regret...") if ctx.author in to_ban:
to_ban.remove(ctx.author)
banned_count = 0
for member in to_ban: if not to_ban:
try: return await ctx.reply("i couldnt ban, im broken fix me esef :(")
await member.ban(reason=reason or f"Mass ban by {ctx.author}")
banned_count += 1 # Confirm before banning
except discord.Forbidden: await ctx.reply(f"Are you sure you want to ban {len(to_ban)} members? Type `yes` or `y` to confirm. (You have 30 seconds to confirm or i wont ban anyone)")
pass # Can't ban this user (higher role/admin)
except discord.HTTPException: def check(m):
pass # Random discord API error return m.author == ctx.author and m.channel == ctx.channel
await ctx.reply(f"i banned {banned_count} users.") try:
import asyncio
response_msg = await self.bot.wait_for('message', timeout=30.0, check=check)
@commands.Cog.listener() except asyncio.TimeoutError:
async def on_command_error(self, ctx, error): return await ctx.reply("Ban wave cancelled (timed out).")
if isinstance(error, commands.CommandNotFound):
return # ignore typos silently if response_msg.content.lower() not in ('yes', 'y'):
print(f'Error: {error}') return await ctx.reply("You didnt say yes so... im not banning until im sure.")
async def setup(bot): await ctx.reply(f"Okay... banning {len(to_ban)} members, hope you wont regret...")
await bot.add_cog(General(bot))␍
banned_count = 0
for member in to_ban:
try:
await member.ban(reason=reason or f"Mass ban by {ctx.author}")
banned_count += 1
except discord.Forbidden:
pass # Can't ban this user (higher role/admin)
except discord.HTTPException:
pass # Random discord API error
await ctx.reply(f"i banned {banned_count} users.")
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandNotFound):
return # ignore typos silently
print(f'Error: {error}')
async def setup(bot):
await bot.add_cog(General(bot))
+5 -1
View File
@@ -18,4 +18,8 @@ STRINOVA_STAT_CHANNEL_ID="yo strinova stat channel here"
#me (for purging and other owner only things) #me (for purging and other owner only things)
OWNER_ID="your discord servers owner id here" OWNER_ID="your discord servers owner id here"
DEEPSEEK_API=lol you thought DEEPSEEK_API=lol you thought
#mis ids member speicific stuff
MELLO=""
FEROX=""