Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added my_bot_folder/cogs/__init__.py
Empty file.
20 changes: 20 additions & 0 deletions my_bot_folder/cogs/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from discord.ext import commands


class Admin(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot

@commands.command(name="reload")
@commands.has_permissions(administrator=True)
async def reload_cog(self, ctx: commands.Context, cog_name: str) -> None:
ext = f"cogs.{cog_name.lower()}"
try:
await self.bot.reload_extension(ext)
await ctx.send(f"✅ Reloaded `{ext}`")
except commands.ExtensionError as exc:
await ctx.send(f"❌ Failed to reload `{ext}`: {exc}")


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Admin(bot))
88 changes: 76 additions & 12 deletions my_bot_folder/cogs/ai.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,88 @@
import discord
import aiohttp
from discord.ext import commands

POLLINATIONS_URL = "https://text.pollinations.ai/openai"
SYSTEM_PROMPT = (
"You are bot in discord server of Intent FreeDomain, we provide free subdomains "
"like .int.yt,.nc.to,.rh.to,.gw.to,.yn.to , intent is a nonprofit providing free "
"subdomains to everyone, your name is Intent AI Bot"
)


class AI(commands.Cog):
def __init__(self, bot):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot

@commands.command(name="intentai", aliases=["pollinate", "askai"])
async def intent_ai(self, ctx: commands.Context, *, prompt: str) -> None:
payload = {
"model": "openai",
"messages": [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": f"@{ctx.author.display_name} {prompt}"},
],
"temperature": 0.7,
"max_tokens": 500,
"stream": False,
"reasoning_effort": "medium",
}

async with ctx.typing():
try:
timeout = aiohttp.ClientTimeout(total=45)
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post(POLLINATIONS_URL, json=payload) as resp:
if resp.status != 200:
error_text = await resp.text()
await ctx.send(f"❌ Pollinations API error ({resp.status}): {error_text[:500]}")
return

data = await resp.json()
except aiohttp.ClientError:
await ctx.send("❌ Could not reach Pollinations API. Please try again.")
return

content = data.get("choices", [{}])[0].get("message", {}).get("content")
if not content:
await ctx.send("❌ No response from Pollinations API.")
return

for chunk_start in range(0, len(content), 1900):
await ctx.send(content[chunk_start : chunk_start + 1900])

@commands.command()
async def gemini(self, ctx, *, prompt):
key = self.bot.config["AI_KEYS"]["gemini"]
if not key: return await ctx.send("❌ Gemini API Key not set in config.")

async def gemini(self, ctx: commands.Context, *, prompt: str) -> None:
key = self.bot.config.get("AI_KEYS", {}).get("gemini", "")
if not key:
await ctx.send("❌ Gemini API key is not configured in config.py")
return

async with ctx.typing():
url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key={key}"
payload = {"contents": [{"parts": [{"text": prompt}]}]}
async with aiohttp.ClientSession() as session:
async with session.post(url, json=payload) as resp:
data = await resp.json()
response = data["candidates"][0]["content"]["parts"][0]["text"]
await ctx.send(response[:2000])

async def setup(bot):
try:
timeout = aiohttp.ClientTimeout(total=45)
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post(url, json=payload) as resp:
if resp.status != 200:
error_text = await resp.text()
await ctx.send(f"❌ Gemini API error ({resp.status}): {error_text[:500]}")
return
data = await resp.json()
except aiohttp.ClientError:
await ctx.send("❌ Could not reach Gemini API. Please try again.")
return

try:
response = data["candidates"][0]["content"]["parts"][0]["text"]
except (KeyError, IndexError, TypeError):
await ctx.send("❌ Gemini returned an unexpected response format.")
return

for chunk_start in range(0, len(response), 1900):
await ctx.send(response[chunk_start : chunk_start + 1900])


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(AI(bot))
40 changes: 24 additions & 16 deletions my_bot_folder/cogs/economy.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
import discord
import datetime
import random

import discord
from discord.ext import commands
from utils import CONFIG, get_user_data, update_user_data

from config import CONFIG
from database import get_user_data, update_user_data


class Economy(commands.Cog):
def __init__(self, bot):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot

@commands.command(aliases=["bal"])
async def balance(self, ctx, member: discord.Member = None):
async def balance(self, ctx: commands.Context, member: discord.Member | None = None) -> None:
member = member or ctx.author
data = await get_user_data(member.id, ctx.guild.id)
embed = discord.Embed(title=f"💰 {member.name}'s Balance", color=discord.Color.green())
embed = discord.Embed(title=f"💰 {member.display_name}'s Balance", color=discord.Color.green())
embed.add_field(name="Wallet", value=f"{CONFIG['CURRENCY_SYMBOL']} {data['balance']:,}")
embed.add_field(name="Bank", value=f"{CONFIG['CURRENCY_SYMBOL']} {data['bank']:,}")
await ctx.send(embed=embed)

@commands.command()
async def work(self, ctx):
async def work(self, ctx: commands.Context) -> None:
data = await get_user_data(ctx.author.id, ctx.guild.id)
now = datetime.datetime.utcnow()

# Check cooldown

if data.get("work_claimed"):
last = datetime.datetime.fromisoformat(data["work_claimed"])
if (now - last).total_seconds() < CONFIG["WORK_COOLDOWN"]:
return await ctx.send("⌛ You're tired! Take a break.")
last_claim = datetime.datetime.fromisoformat(data["work_claimed"])
if (now - last_claim).total_seconds() < CONFIG["WORK_COOLDOWN"]:
await ctx.send("⌛ Work cooldown active. Try again later.")
return

earned = random.randint(CONFIG["WORK_MIN"], CONFIG["WORK_MAX"])
await update_user_data(ctx.author.id, ctx.guild.id,
balance=data["balance"] + earned,
work_claimed=now.isoformat())
await ctx.send(f"💼 You worked and earned {CONFIG['CURRENCY_SYMBOL']} **{earned}**!")
await update_user_data(
ctx.author.id,
ctx.guild.id,
balance=data["balance"] + earned,
work_claimed=now.isoformat(),
)
await ctx.send(f"💼 You earned {CONFIG['CURRENCY_SYMBOL']} **{earned}**")


async def setup(bot):
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Economy(bot))
41 changes: 23 additions & 18 deletions my_bot_folder/cogs/events.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
import discord
import random
import time

from discord.ext import commands

from config import CONFIG
from database import get_user_data, update_user_data


class Events(commands.Cog):
def __init__(self, bot):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot

@commands.Cog.listener()
async def on_message(self, message):
if message.author.bot: return

# Leveling System
user_id, guild_id = message.author.id, message.guild.id
now = time.time()
if user_id not in self.bot.xp_cooldowns or now - self.bot.xp_cooldowns[user_id] > 60:
self.bot.xp_cooldowns[user_id] = now
data = await get_user_data(user_id, guild_id)
xp_gain = random.randint(15, 25)
await update_user_data(user_id, guild_id, xp=data['xp'] + xp_gain)
async def on_message(self, message) -> None:
if message.author.bot or not message.guild:
return

if CONFIG["LEVELING_ENABLED"]:
user_id = message.author.id
now = time.time()
cooldown = CONFIG["XP_COOLDOWN"]
if user_id not in self.bot.xp_cooldowns or now - self.bot.xp_cooldowns[user_id] > cooldown:
self.bot.xp_cooldowns[user_id] = now
data = await get_user_data(user_id, message.guild.id)
xp_min, xp_max = CONFIG["XP_PER_MESSAGE"]
xp_gain = random.randint(xp_min, xp_max)
await update_user_data(user_id, message.guild.id, xp=data["xp"] + xp_gain, messages=data["messages"] + 1)

await self.bot.process_commands(message)

@commands.Cog.listener()
async def on_member_join(self, member):
if self.bot.config["WELCOME_ENABLED"]:
print(f"👋 {member.name} joined {member.guild.name}")

async def setup(bot):
async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Events(bot))
17 changes: 17 additions & 0 deletions my_bot_folder/cogs/fun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import random

from discord.ext import commands


class Fun(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot

@commands.command()
async def eightball(self, ctx: commands.Context, *, question: str) -> None:
responses = ["Yes", "No", "Maybe", "Definitely", "Ask again later"]
await ctx.send(f"🎱 Q: {question}\nA: **{random.choice(responses)}**")


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Fun(bot))
21 changes: 21 additions & 0 deletions my_bot_folder/cogs/giveaway.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import random

from discord.ext import commands


class Giveaway(commands.Cog):
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot

@commands.command()
@commands.has_permissions(manage_guild=True)
async def groll(self, ctx: commands.Context, *members: str) -> None:
if not members:
await ctx.send("Provide participants for giveaway roll.")
return
winner = random.choice(members)
await ctx.send(f"🎉 Giveaway winner: **{winner}**")


async def setup(bot: commands.Bot) -> None:
await bot.add_cog(Giveaway(bot))
Loading