commit 82313a23aaca0249845305685cffddc4d0bfaa71 Author: Jared Vititoe Date: Tue Jan 13 15:30:10 2026 -0500 Initial commit of Discord bot 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/bot.py b/bot.py new file mode 100644 index 0000000..c724e50 --- /dev/null +++ b/bot.py @@ -0,0 +1,903 @@ +import discord, os, random, asyncio, fnmatch, time, requests, json, logging, aiohttp +from datetime import datetime, time, timedelta +from dotenv import load_dotenv +from discord import app_commands +from discord.ext import commands, tasks +from discord.utils import get +from itertools import cycle +from mcrcon import MCRcon + +logging.basicConfig( + level=logging.INFO, + format='%(asctime)s - %(levelname)s - %(message)s', + handlers=[ + logging.FileHandler(f'logs/discord_{datetime.now().strftime("%Y-%m-%d")}.log'), + logging.StreamHandler() + ] +) +logger = logging.getLogger('discord_bot') + +load_dotenv() + +class CustomBot(commands.Bot): + def __init__(self): + intents = discord.Intents.all() + intents.message_content = True + super().__init__( + command_prefix=".", + intents=intents + ) + self.status_cycle = cycle([ + "The Lotus Guild is boomin", + "lotusguild.org", + "Ranked Minesweeper" + ]) + self.remove_command("help") + + with open('adjectives.json', 'r') as f: + self.adjectives_data = json.load(f) + self.current_adjective_index = 0 + + async def setup_hook(self): + print("Syncing commands...") + await self.tree.sync() + print("Commands synced!") + self.daily_adjective.start() + + @tasks.loop(time=time(hour=14)) # Posts at 9 AM every day + async def daily_adjective(self): + channel = self.get_channel(605864889940050088) + if not channel: + print(f"Failed to get announcement channel") + return + # Get and remove today's adjective + adjective = self.adjectives_data["adjectives"].pop(0) + + # Create and send embed + embed = discord.Embed( + title="📚 Adjective of the Day", + color=discord.Color.from_rgb(152,0,0), + timestamp=datetime.now() + ) + embed.add_field(name=adjective["word"].capitalize(), + value=adjective["definition"].capitalize(), + inline=False) + embed.set_footer(text="Expand your vocabulary!") + + await channel.send(embed=embed) + + # Save updated adjectives list back to file + with open('adjectives.json', 'w') as f: + json.dump(self.adjectives_data, f, indent=4) + + # Optional: Reload list if empty + if not self.adjectives_data["adjectives"]: + with open('adjectives.json', 'r') as f: + self.adjectives_data = json.load(f) + + @daily_adjective.before_loop + async def before_daily_adjective(self): + await self.wait_until_ready() + + @tasks.loop(hours=24) + async def daily_stats(): + guild = client.get_guild(605864889927467181) + stats = f"📊 Daily Server Stats\n" + stats += f"Members: {guild.member_count}\n" + stats += f"Channels: {len(guild.channels)}\n" + stats += f"Roles: {len(guild.roles)}" + await send_audit_log(stats) + + @tasks.loop(seconds=15) + async def change_status(self): + await self.change_presence(activity=discord.Game(next(self.status_cycle))) + + @change_status.before_loop + async def before_change_status(self): + await self.wait_until_ready() + + async def on_ready(self): + logger.info(f"Bot logged in as: {client.user.name}") + logger.info(f"Registered commands: {[cmd.name for cmd in client.tree.get_commands()]}") + self.change_status.start() + +client = CustomBot() + +def is_owner(): + async def predicate(ctx): + return ctx.author.id == 238728085342519296 + return commands.check(predicate) + +#await ctx.send(f'Servers: {client.guilds}') + +async def send_audit_log(message: str, color: int = 0x980000): + audit_channel = client.get_channel(1340861451392520233) + if audit_channel: + embed = discord.Embed( + description=message, + color=color, + timestamp=datetime.now() + ) + await audit_channel.send(embed=embed) + +@client.event +async def on_message(message): + logger.info(f"Channel: [{str(message.channel)}] User: {str(message.author)} Content: {message.content}") + await client.process_commands(message) + +@client.event +async def on_member_join(member): + logger.info(f"New member joined: {member.name} (ID: {member.id})") + await send_audit_log(f"✨ Member Joined\nUser: {member.mention}\nAccount Created: {member.created_at}") + +@client.event +async def on_member_remove(member): + logger.info(f"Member left: {member.name} (ID: {member.id})") + await send_audit_log(f"👋 Member Left\nUser: {member.name}#{member.discriminator}") + +@client.event +async def on_message_delete(message): + logger.warning(f"Message deleted in {message.channel}: {message.author}: {message.content}") + await send_audit_log(f"🗑️ Message Deleted\nChannel: {message.channel}\nUser: {message.author}\nContent: {message.content}") + +@client.event +async def on_voice_state_update(member, before, after): + if before.channel != after.channel: + if after.channel: + await send_audit_log(f"🎤 Voice Join\nUser: {member.mention}\nChannel: {after.channel.name}") + else: + await send_audit_log(f"🎤 Voice Leave\nUser: {member.mention}\nChannel: {before.channel.name}") + +@client.event +async def on_integration_create(integration): + await send_audit_log(f"🔌 New Integration Added\nName: {integration.name}\nType: {integration.type}") + +@client.event +async def on_scheduled_event_create(event): + await send_audit_log(f"📅 Event Created\nName: {event.name}\nStart Time: {event.start_time}") + +@client.event +async def on_scheduled_event_update(before, after): + await send_audit_log(f"📝 Event Updated\nName: {after.name}\nChanges Made") + +@client.event +async def on_member_update(before, after): + if before.timed_out_until != after.timed_out_until: + await send_audit_log(f"⏰ Member Timeout\nUser: {after.mention}\nUntil: {after.timed_out_until}") + +@client.event +async def on_member_ban(guild, user): + await send_audit_log(f"🔨 Member Banned\nUser: {user.name}") + +@client.event +async def on_guild_role_update(before, after): + if before.permissions != after.permissions: + await send_audit_log(f"🔑 Role Permissions Updated\nRole: {after.name}") + +@client.event +async def on_guild_emoji_create(emoji): + await send_audit_log(f"😄 New Emoji Added\nName: {emoji.name}") + +@client.event +async def on_guild_sticker_create(sticker): + await send_audit_log(f"🎯 New Sticker Added\nName: {sticker.name}") + +@client.event +async def on_guild_role_create(role): + await send_audit_log(f"👑 Role Created\nName: {role.name}\nColor: {role.color}") + +@client.event +async def on_guild_role_delete(role): + await send_audit_log(f"🗑️ Role Deleted\nName: {role.name}") + +@client.event +async def on_member_update(before, after): + if before.premium_since != after.premium_since: + await send_audit_log(f"⭐ Server Boost\nUser: {after.mention} boosted the server!") + +@client.event +async def on_member_update(before, after): + if before.nick != after.nick: + await send_audit_log(f"📛 Nickname Change\nUser: {before.mention}\nBefore: {before.nick}\nAfter: {after.nick}") + +@client.event +async def on_message_edit(before, after): + # Skip if content didn't change (e.g. embed or pin updates) + if before.content == after.content: + return + + logger.info(f"Message edited in {before.channel}\nBefore: {before.content}\nAfter: {after.content}") + + await send_audit_log( + f"✏️ Message Edited\n" + f"Channel: {before.channel.mention}\n" + f"User: {before.author.mention}\n" + f"Before: {before.content}\n" + f"After: {after.content}" + ) + +@client.event +async def on_member_update(before, after): + if before.roles != after.roles: + logger.info(f"Role change for {before.name}: {before.roles} -> {after.roles}") + await send_audit_log(f"👥 Role Update\nUser: {before.mention}\nBefore: {', '.join([r.name for r in before.roles])}\nAfter: {', '.join([r.name for r in after.roles])}") + +@client.event +async def on_guild_channel_create(channel): + logger.info(f"Channel created: {channel.name}") + +@client.event +async def on_guild_channel_delete(channel): + logger.info(f"Channel deleted: {channel.name}") + +@client.tree.command(name="help", description="Shows all available commands") +async def help(interaction: discord.Interaction): + embed = discord.Embed( + color=discord.Color.from_rgb(152,0,0), + title="Command List", + description="Describes what commands do and how to use them." + ) + + embed.set_author(name="Help Page (Lotus Bot)", icon_url="https://lotusguild.org/Lotus.png") + embed.set_image(url="https://lotusguild.org/favicon.ico") + embed.set_thumbnail(url="https://lotusguild.org/favicon.ico") + + # Basic Commands + embed.add_field(name="/help", value="Shows this help message with all available commands", inline=False) + embed.add_field(name="/ping", value="Shows the bot's response time in milliseconds", inline=False) + + # Fun Commands + embed.add_field(name="/8ball", value="Ask the magic 8-ball a question and receive an answer", inline=False) + embed.add_field(name="/fortune", value="Get your fortune cookie message", inline=False) + embed.add_field(name="/flip", value="Flip a coin and get heads or tails", inline=False) + embed.add_field(name="/roll", value="Roll dice (format: NdS, example: 2d6)", inline=False) + embed.add_field(name="/random", value="Generate a random number between specified range", inline=False) + embed.add_field(name="/rps", value="Play Rock Paper Scissors against the bot", inline=False) + embed.add_field(name="/poll", value="Create a simple yes/no poll", inline=False) + + # Game Commands + embed.add_field(name="/agent", value="Get a random Valorant agent with their role", inline=False) + embed.add_field(name="/champion", value="Get a random League of Legends champion with their lane", inline=False) + embed.add_field(name="/minecraft", value="Whitelists a player on the Minecraft server and shows server info", inline=False) + embed.add_field(name="/hytale", value="Whitelists a player on the Hytale server and shows server info", inline=False) + + # Interaction Commands + embed.add_field(name="/kill", value="Kill another user with a random animation", inline=False) + embed.add_field(name="/punch", value="Punch another user with a random animation", inline=False) + embed.add_field(name="/hug", value="Hug another user with a random animation", inline=False) + embed.add_field(name="/revive", value="Revive another user with a random animation", inline=False) + + # Admin Commands (Only visible to admins) + if discord.utils.get(interaction.user.roles, id=605867042104541194): + embed.add_field(name="🛡️ Admin Commands", value="---------------", inline=False) + embed.add_field(name="/clear", value="Clears specified number of messages from the channel", inline=False) + embed.add_field(name="/lockdown", value="Lock a channel to prevent messages", inline=False) + embed.add_field(name="/unlock", value="Unlock a previously locked channel", inline=False) + + embed.set_footer(text="Made by https://lotusguild.org") + await interaction.response.send_message(embed=embed) +#REACTION ROLES +@client.event +async def on_raw_reaction_add(payload): + if payload.message_id == 744047519696420914: + guild = client.get_guild(payload.guild_id) + member = await guild.fetch_member(payload.user_id) + if payload.emoji.name == "Overwatch": + role = discord.utils.get(guild.roles, name='(Overwatch)') + elif payload.emoji.name == "Minecraft": + role = discord.utils.get(guild.roles, name='(Minecraft)') + elif payload.emoji.name == "LeagueOfLegends": + role = discord.utils.get(guild.roles, name='(League Of Legends)') + elif payload.emoji.name == "ClashRoyale": + role = discord.utils.get(guild.roles, name='(Clash Royale)') + elif payload.emoji.name == "CSGO": + role = discord.utils.get(guild.roles, name='(CSGO)') + elif payload.emoji.name == "CivilizationVI": + role = discord.utils.get(guild.roles, name='(Civilization VI)') + elif payload.emoji.name == "Python": + role = discord.utils.get(guild.roles, name='Computer Nerd') + elif payload.emoji.name == "Valorant": + role = discord.utils.get(guild.roles, name='(Valorant)') + elif payload.emoji.name == "Ark": + role = discord.utils.get(guild.roles, name='(Ark Survival Evolved)') + elif payload.emoji.name == "AmongUs": + role = discord.utils.get(guild.roles, name='(Among Us)') + elif payload.emoji.name == "RainbowSixSiege": + role = discord.utils.get(guild.roles, name='(Rainbow Six Siege)') + elif payload.emoji.name == "Phasmophobia": + role = discord.utils.get(guild.roles, name='(Phasmophobia)') + elif payload.emoji.name == "StardewValley": + role = discord.utils.get(guild.roles, name='(Stardew Valley)') + elif payload.emoji.name == "Tarkov": + role = discord.utils.get(guild.roles, name='(Tarkov)') + elif payload.emoji.name == "LethalCompany": + role = discord.utils.get(guild.roles, name='(Lethal Company)') + elif payload.emoji.name == "BTD": + role = discord.utils.get(guild.roles, name='(Balloons Tower Defense)') + elif payload.emoji.name == "HellDivers": + role = discord.utils.get(guild.roles, name='(Hell Divers)') + elif payload.emoji.name == "ABI": + role = discord.utils.get(guild.roles, name='(Arena Breakout Infinite)') + elif payload.emoji.name == "UnoReverse": + role = discord.utils.get(guild.roles, name='(Uno)') + elif payload.emoji.name == "Hytale": + role = discord.utils.get(guild.roles, name='(Hytale)') + else: + role = discord.utils.get(guild.roles, name=payload.emoji.name) + if member is not None: + await member.add_roles(role) + try: + await member.add_roles(discord.utils.get(guild.roles, name='Member')) + except Exception as e: + print(e) + print("Role has been Added!") + else: + print("Member not found: " + str(member)) + '''if payload.message_id == 930647192648171540: + guild = client.get_guild(payload.guild_id) + member = await guild.fetch_member(payload.user_id) + if payload.emoji.name == "ClashRoyale": + role = discord.utils.get(guild.roles, name='(Clash Royale)') + elif payload.emoji.name == "Valorant": + role = discord.utils.get(guild.roles, name='(Valorant)') + else: + role = discord.utils.get(guild.roles, name=payload.emoji.name) + if member is not None: + await member.add_roles(role) + try: + await member.add_roles(discord.utils.get(guild.roles, name='Member')) + except Exception as e: + print(e) + print("Role has been Added!") + else: + print("Member not found: " + str(member))''' +#REMOVAL OF REACTION ROLES +@client.event +async def on_raw_reaction_remove(payload): + if payload.message_id == 744047519696420914: + guild = client.get_guild(payload.guild_id) + member = await guild.fetch_member(payload.user_id) + if payload.emoji.name == "Overwatch": + role = discord.utils.get(guild.roles, name='(Overwatch)') + elif payload.emoji.name == "Minecraft": + role = discord.utils.get(guild.roles, name='(Minecraft)') + elif payload.emoji.name == "LeagueOfLegends": + role = discord.utils.get(guild.roles, name='(League Of Legends)') + elif payload.emoji.name == "ClashRoyale": + role = discord.utils.get(guild.roles, name='(Clash Royale)') + elif payload.emoji.name == "CSGO": + role = discord.utils.get(guild.roles, name='(CSGO)') + elif payload.emoji.name == "CivilizationVI": + role = discord.utils.get(guild.roles, name='(Civilization VI)') + elif payload.emoji.name == "computer": + role = discord.utils.get(guild.roles, name='Computer Nerd') + elif payload.emoji.name == "Valorant": + role = discord.utils.get(guild.roles, name='(Valorant)') + elif payload.emoji.name == "Ark": + role = discord.utils.get(guild.roles, name='(Ark Survival Evolved)') + elif payload.emoji.name == "AmongUs": + role = discord.utils.get(guild.roles, name='(Among Us)') + elif payload.emoji.name == "RainbowSixSiege": + role = discord.utils.get(guild.roles, name='(Rainbow Six Siege)') + elif payload.emoji.name == "Phasmophobia": + role = discord.utils.get(guild.roles, name='(Phasmophobia)') + elif payload.emoji.name == "Tarkov": + role = discord.utils.get(guild.roles, name='(Tarkov)') + elif payload.emoji.name == "LethalCompany": + role = discord.utils.get(guild.roles, name='(Lethal Company)') + elif payload.emoji.name == "HellDivers": + role = discord.utils.get(guild.roles, name='(Hell Divers)') + elif payload.emoji.name == "ABI": + role = discord.utils.get(guild.roles, name='(Arena Breakout Infinite)') + elif payload.emoji.name == "UnoReverse": + role = discord.utils.get(guild.roles, name='(Uno)') + elif payload.emoji.name == "Hytale": + role = discord.utils.get(guild.roles, name='(Hytale)') + else: + role = discord.utils.get(guild.roles, name=payload.emoji.name) + if role is not None: + if member is not None: + await member.remove_roles(role) + print("Role has been removed!") + else: + print("Member not found: " + str(member)) + else: + print("Role not found: " + str(role)) + '''if payload.message_id == 930647192648171540: + guild = client.get_guild(payload.guild_id) + member = await guild.fetch_member(payload.user_id) + if payload.emoji.name == "ClashRoyale": + role = discord.utils.get(guild.roles, name='(Clash Royale)') + elif payload.emoji.name == "Valorant": + role = discord.utils.get(guild.roles, name='(Valorant)') + else: + role = discord.utils.get(guild.roles, name=payload.emoji.name) + if role is not None: + if member is not None: + await member.remove_roles(role) + print("Role has been removed!") + else: + print("Member not found: " + str(member)) + else: + print("Role not found: " + str(role))''' + +@client.tree.command(name="ping", description="Check the bot's latency") +async def ping(interaction: discord.Interaction): + await interaction.response.send_message(f"Pong! {round(client.latency * 1000)}ms") + +@client.tree.command(name="problem") +async def problem(ctx): + await ctx.send("If you got a problem with canada gooses then you got a problem with me and I suggest you let that one marinate.") + await ctx.send(file=discord.File("media/canadagoose.gif")) + +@commands.has_role(605867042104541194) +@client.tree.command(name="clear", description="Clear messages from the channel") +@app_commands.describe(amount="Number of messages to delete") +async def clear(interaction: discord.Interaction, amount: int = 5): + # Defer the response since message deletion might take a moment + await interaction.response.defer(ephemeral=True) + # Delete the messages + deleted = await interaction.channel.purge(limit=amount) + # Follow up with confirmation that only the command user can see + await interaction.followup.send(f"Successfully cleared {len(deleted)} messages!", ephemeral=True) + +@commands.has_role(605867042104541194) +@client.tree.command(name="lockdown", description="Lock a channel") +async def lockdown(interaction: discord.Interaction, channel: discord.TextChannel = None): + channel = channel or interaction.channel + await channel.set_permissions(interaction.guild.default_role, send_messages=False) + await send_audit_log(f"🔒 Channel Locked\nChannel: {channel.name}") + await interaction.response.send_message(f"Locked {channel.mention}") + +@commands.has_role(605867042104541194) +@client.tree.command(name="unlock", description="Unlock a channel") +async def unlock(interaction: discord.Interaction, channel: discord.TextChannel = None): + channel = channel or interaction.channel + await channel.set_permissions(interaction.guild.default_role, send_messages=True) + await send_audit_log(f"🔓 Channel Unlocked\nChannel: {channel.name}") + await interaction.response.send_message(f"Unlocked {channel.mention}") + +def is_valid_minecraft_username(username): + url = f'https://api.mojang.com/users/profiles/minecraft/{username}' + response = requests.get(url) + return response.status_code == 200 + +@client.tree.command(name="minecraft") +@commands.has_role(821163520942145556) +async def minecraft(interaction: discord.Interaction, minecraft_username: str): + if not is_valid_minecraft_username(minecraft_username): + await interaction.response.send_message("Invalid MC Username") + return + try: + with MCRcon("10.10.10.67", "Pythonisbetterthankotlin") as mcr: + response = mcr.command(f"whitelist add {minecraft_username}") + print(response) + except Exception as e: + print(e) + await interaction.response.send_message("An error occurred while whitelisting the player (jared will fix just let him know).") + return + minecraft_embed = discord.Embed( + color=discord.Color.from_rgb(152, 0, 0), + title="Minecraft" + ) + minecraft_embed.set_author(name="(Lotus Bot)", icon_url="https://photos.lotusguild.org/api/assets/3c4eb2da-0d06-407f-bdb7-c9e4cf795f0a/thumbnail?key=4aoZxX5-FHE3m_Ywwz1uGo3iNW53kmFztxfUw91PdOgphPNxayLFicNuxPvit1OYTpY&size=preview&c=jUqDBQAWF9iId3J%2FyAeIcIAICEd4d3BzSA%3D%3D") + minecraft_embed.set_image(url="https://photos.lotusguild.org/api/assets/3c4eb2da-0d06-407f-bdb7-c9e4cf795f0a/thumbnail?key=4aoZxX5-FHE3m_Ywwz1uGo3iNW53kmFztxfUw91PdOgphPNxayLFicNuxPvit1OYTpY&size=preview&c=jUqDBQAWF9iId3J%2FyAeIcIAICEd4d3BzSA%3D%3D") + minecraft_embed.set_thumbnail(url="https://photos.lotusguild.org/api/assets/3c4eb2da-0d06-407f-bdb7-c9e4cf795f0a/thumbnail?key=4aoZxX5-FHE3m_Ywwz1uGo3iNW53kmFztxfUw91PdOgphPNxayLFicNuxPvit1OYTpY&size=preview&c=jUqDBQAWF9iId3J%2FyAeIcIAICEd4d3BzSA%3D%3D") + minecraft_embed.add_field(name="You", value="have been whitelisted on the SMP", inline=False) + minecraft_embed.add_field(name="Server Address", value="minecraft.lotusguild.org", inline=False) + minecraft_embed.add_field(name="Version", value="1.21.11", inline=False) + minecraft_embed.set_footer(text="Thanks for using Lotus Minecraft Server!") + await interaction.response.send_message(embed=minecraft_embed) + +''' +@client.tree.command(name="hytale") +@commands.has_role(821163520942145556) +async def hytale(interaction: discord.Interaction, hytale_username: str): + if not is_valid_hytale_username(hytale_username): + await interaction.response.send_message("Invalid MC Username") + return + try: + with MCRcon("IP", "PASS") as mcr: + response = mcr.command(f"whitelist add {hytale_username}") + print(response) + except Exception as e: + print(e) + await interaction.response.send_message("An error occurred while whitelisting the player (jared will fix just let him know).") + return + hytale_embed = discord.Embed( + color=discord.Color.from_rgb(152, 0, 0), + title="Hytale" + ) + hytale_embed.set_author(name="(Lotus Bot)", icon_url="https://photos.lotusguild.org/api/assets/3c4eb2da-0d06-407f-bdb7-c9e4cf795f0a/thumbnail?key=4aoZxX5-FHE3m_Ywwz1uGo3iNW53kmFztxfUw91PdOgphPNxayLFicNuxPvit1OYTpY&size=preview&c=jUqDBQAWF9iId3J%2FyAeIcIAICEd4d3BzSA%3D%3D") + hytale_embed.set_image(url="https://photos.lotusguild.org/api/assets/3c4eb2da-0d06-407f-bdb7-c9e4cf795f0a/thumbnail?key=4aoZxX5-FHE3m_Ywwz1uGo3iNW53kmFztxfUw91PdOgphPNxayLFicNuxPvit1OYTpY&size=preview&c=jUqDBQAWF9iId3J%2FyAeIcIAICEd4d3BzSA%3D%3D") + hytale_embed.set_thumbnail(url="https://photos.lotusguild.org/api/assets/3c4eb2da-0d06-407f-bdb7-c9e4cf795f0a/thumbnail?key=4aoZxX5-FHE3m_Ywwz1uGo3iNW53kmFztxfUw91PdOgphPNxayLFicNuxPvit1OYTpY&size=preview&c=jUqDBQAWF9iId3J%2FyAeIcIAICEd4d3BzSA%3D%3D") + hytale_embed.add_field(name="You", value="have been whitelisted on the SMP", inline=False) + hytale_embed.add_field(name="Server Address", value="hytale.lotusguild.org", inline=False) + hytale_embed.add_field(name="Version:", value="2026.01.13-dcad8778f", inline=False) + hytale_embed.set_footer(text="Thanks for using Lotus Hytale Server!") + await interaction.response.send_message(embed=hytale_embed) +''' +# Track last usage per user +ask_cooldowns = {} +COOLDOWN_MINUTES = 2 + +@client.tree.command(name="ask", description="Ask a question to Lotus LLM") +@app_commands.describe(question="Your question for the AI") +@commands.has_role(788968178117902347) # Cool Kids role check +async def ask(interaction: discord.Interaction, question: str): + # Check cooldown + user_id = interaction.user.id + current_time = datetime.now() + if user_id in ask_cooldowns: + time_diff = current_time - ask_cooldowns[user_id] + if time_diff < timedelta(minutes=COOLDOWN_MINUTES): + remaining = COOLDOWN_MINUTES - (time_diff.seconds / 60) + await interaction.response.send_message( + f"Please wait {remaining:.1f} minutes before asking another question!", + ephemeral=True + ) + return + await interaction.response.defer() + # Select model based on user ID + model = "lotusllmben" if user_id == 460640040096104459 else "lotusllm" + logger.info(f"Sending question to Ollama: {question}") + async with aiohttp.ClientSession() as session: + async with session.post( + "http://10.10.10.157:11434/api/generate", + json={ + "model": model, + "prompt": question, + "stream": True + } + ) as response: + full_response = "" + async for line in response.content: + try: + chunk = json.loads(line) + logger.info(f"Received chunk: {chunk}") + if "response" in chunk: + full_response += chunk["response"] + except json.JSONDecodeError as e: + logger.error(f"Failed to parse JSON: {e}") + logger.error(f"Raw line: {line}") + + # Update cooldown timestamp + ask_cooldowns[user_id] = current_time + embed = discord.Embed( + title="Lotus LLM", + description=full_response if full_response else "No response received from server", + color=discord.Color.from_rgb(152,0,0) + ) + embed.add_field(name="Question", value=question, inline=False) + embed.set_footer(text=f"Asked by {interaction.user.display_name}") + await interaction.followup.send(embed=embed) + +@client.tree.command(name="8ball", description="Ask the magic 8-ball a question") +@app_commands.describe(question="What would you like to ask the 8ball?") +async def eight_ball(interaction: discord.Interaction, question: str): + possible_responses = [ + # Positive answers + "It is certain", "Without a doubt", "You may rely on it", + "Yes definitely", "It is decidedly so", "As I see it, yes", + "Most likely", "Yes sir!", "Hell yeah my dude", "100% easily", + # Neutral answers + "Reply hazy try again", "Ask again later", "Better not tell you now", + "Cannot predict now", "Concentrate and ask again", "Idk bro", + # Negative answers + "Don't count on it", "My reply is no", "My sources say no", + "Outlook not so good", "Very doubtful", "Hell no", "Prolly not" + ] + + embed = discord.Embed( + color=discord.Color.from_rgb(152,0,0), + title="🎱 Magic 8-Ball" + ) + embed.add_field(name="Question", value=question, inline=False) + embed.add_field(name="Answer", value=random.choice(possible_responses), inline=False) + embed.set_footer(text=f"Asked by {interaction.user.display_name}") + + await interaction.response.send_message(embed=embed) + +@client.tree.command(name="fortune", description="Get your fortune cookie message") +async def fortune(interaction: discord.Interaction): + possible_responses = [ + # Humorous fortunes + "If you eat something & nobody sees you eat it, it has no calories", + "Your pet is plotting world domination", + "Error 404: Fortune not found. Try again after system reboot", + "The fortune you seek is in another cookie", + + # Classic fortunes with a twist + "A journey of a thousand miles begins with ordering delivery", + "You will find great fortune... in between your couch cushions", + "A true friend is someone who tells you when your stream is muted", + + # Gaming-themed fortunes + "Your next competitive match will be legendary", + "The cake is still a lie", + "Press Alt+F4 for instant success", + "You will not encounter any campers today", + "Your tank will have a healer", + "No one will steal your pentakill", + "Your random teammate will have a mic", + "You will find diamonds on your first dig", + "The boss will drop the rare loot", + "Your speedrun will be WR pace", + "No lag spikes in your next match", + "Your gaming chair will grant you powers", + "The RNG gods will bless you", + "You will not get third partied", + "Your squad will actually stick together", + "The enemy team will forfeit at 15", + "Your aim will be crispy today", + "You will escape the backrooms", + "The imposter will not sus you", + "Your Minecraft bed will remain unbroken", + "You will get Play of the Game", + + # Internet culture fortunes + "Your next meme will go viral", + "Someone is talking about you in their Discord server", + "Your FBI agent thinks you're hilarious", + "Your next TikTok will hit the FYP, if the government doesn't ban it first", + "Someone will actually read your Twitter thread", + "Your DMs will be blessed with quality memes today", + "Touch grass (respectfully)", + "The algorithm will be in your favor today", + "Your next Spotify shuffle will hit different", + "Someone saved your Instagram post", + "Your Reddit comment will get gold", + "POV: You're about to go viral", + "Main character energy detected", + "No cap, you're gonna have a great day fr fr", + "Your rizz levels are increasing", + "You will not get ratio'd today", + "Someone will actually use your custom emoji", + "Your next selfie will be iconic", + + # Original favorites + "Buy a dolphin - your life will have a porpoise", + "Stop procrastinating - starting tomorrow", + "Catch fire with enthusiasm - people will come for miles to watch you burn", + + # Tech & computer nerd fortunes + "Your code will compile on the first try today", + "A semicolon will save your day", + "The bug you've been hunting is just a typo", + "Your next Git commit will be perfect", + "You will find the solution on the first StackOverflow link", + "Your Docker container will build without errors", + "The cloud is just someone else's computer", + "Your backup strategy will soon prove its worth", + "A mechanical keyboard is in your future", + "You will finally understand regex... maybe", + "Your CSS will align perfectly on the first try", + "Someone will star your GitHub repo today", + "Your Linux installation will not break after updates", + "You will remember to push your changes before shutdown", + "Your code comments will actually make sense in 6 months", + "The missing curly brace is on line 247", + "Have you tried turning it off and on again?", + "Your next pull request will be merged without comments", + "Your keyboard RGB will sync perfectly today", + "You will find that memory leak", + "Your next algorithm will have O(1) complexity", + "The force quit was strong with this one", + "Ctrl+S will save you today", + "Your next Python script will need no debugging", + "Your next API call will return 200 OK" + ] + + embed = discord.Embed( + color=discord.Color.from_rgb(152,0,0), + title="🥠 Fortune Cookie" + ) + embed.add_field(name="Your Fortune", value=random.choice(possible_responses), inline=False) + embed.set_footer(text=f"Cracked open by {interaction.user.display_name}") + + await interaction.response.send_message(embed=embed) + +@client.tree.command(name="flip", description="Flip a coin") +async def flip(interaction: discord.Interaction): + result = random.choice(["Heads", "Tails"]) + embed = discord.Embed(title="🪙 Coin Flip", color=discord.Color.from_rgb(152,0,0)) + embed.add_field(name="Result", value=result) + await interaction.response.send_message(embed=embed) + +@client.tree.command(name="roll", description="Roll dice (e.g. 2d6)") +@app_commands.describe(dice="Format: NdS (N=number of dice, S=sides)") +async def roll(interaction: discord.Interaction, dice: str = "1d6"): + try: + num, sides = map(int, dice.lower().split('d')) + results = [random.randint(1, sides) for _ in range(num)] + embed = discord.Embed(title="🎲 Dice Roll", color=discord.Color.from_rgb(152,0,0)) + embed.add_field(name="Results", value=f"Rolls: {results}\nTotal: {sum(results)}") + await interaction.response.send_message(embed=embed) + except: + await interaction.response.send_message("Please use format: NdS (example: 2d6)", ephemeral=True) + +@client.tree.command(name="random", description="Generate a random number") +@app_commands.describe(min="Minimum number", max="Maximum number") +async def random_number(interaction: discord.Interaction, min: int = 1, max: int = 100): + result = random.randint(min, max) + embed = discord.Embed(title="🎯 Random Number", color=discord.Color.from_rgb(152,0,0)) + embed.add_field(name="Result", value=str(result)) + await interaction.response.send_message(embed=embed) + +@client.tree.command(name="rps", description="Play Rock Paper Scissors") +@app_commands.describe(choice="Your choice: rock, paper, or scissors") +async def rps(interaction: discord.Interaction, choice: str): + choices = ["rock", "paper", "scissors"] + bot_choice = random.choice(choices) + choice = choice.lower() + + if choice not in choices: + await interaction.response.send_message("Please choose rock, paper, or scissors!", ephemeral=True) + return + + embed = discord.Embed(title="✂️ Rock Paper Scissors", color=discord.Color.from_rgb(152,0,0)) + embed.add_field(name="Your Choice", value=choice.capitalize()) + embed.add_field(name="Bot's Choice", value=bot_choice.capitalize()) + + if choice == bot_choice: + result = "It's a tie!" + elif (choice == "rock" and bot_choice == "scissors") or \ + (choice == "paper" and bot_choice == "rock") or \ + (choice == "scissors" and bot_choice == "paper"): + result = "You win!" + else: + result = "Bot wins!" + + embed.add_field(name="Result", value=result, inline=False) + await interaction.response.send_message(embed=embed) + +@client.tree.command(name="poll", description="Create a simple yes/no poll") +@app_commands.describe(question="The poll question") +async def poll(interaction: discord.Interaction, question: str): + embed = discord.Embed(title="📊 Poll", description=question, color=discord.Color.from_rgb(152,0,0)) + embed.set_footer(text=f"Created by {interaction.user.display_name}") + message = await interaction.response.send_message(embed=embed) + message = await interaction.original_response() + await message.add_reaction("👍") + await message.add_reaction("👎") + +@client.tree.command(name="kill", description="Kill another user") +@app_commands.describe(member="The user to kill") +async def kill(interaction: discord.Interaction, member: discord.Member): + kills = ["media/kill.gif", "media/kill1.gif", "media/kill2.gif", "media/kill3.gif"] + await interaction.response.send_message(f"You killed {member}", file=discord.File(random.choice(kills))) + +@client.tree.command(name="punch", description="Punch another user") +@app_commands.describe(member="The user to punch") +async def punch(interaction: discord.Interaction, member: discord.Member): + punches = ["media/punch.gif", "media/punch1.gif", "media/punch2.gif", "media/punch3.gif"] + await interaction.response.send_message(f"You punched {member}", file=discord.File(random.choice(punches))) + +@client.tree.command(name="hug", description="Hug another user") +@app_commands.describe(member="The user to hug") +async def hug(interaction: discord.Interaction, member: discord.Member): + hugs = ["media/hug.gif", "media/hug1.gif", "media/hug2.gif", "media/hug3.gif"] + await interaction.response.send_message(f"{member} has been squeezed tightly!", file=discord.File(random.choice(hugs))) + +@client.tree.command(name="revive", description="Revive another user") +@app_commands.describe(member="The user to revive") +async def revive(interaction: discord.Interaction, member: discord.Member): + revives = ["media/revive.gif", "media/revive1.gif", "media/revive2.gif", "media/revive3.gif"] + await interaction.response.send_message(f"{member} has been brought back to life", file=discord.File(random.choice(revives))) + +@client.tree.command(name="agent", description="Get a random Valorant agent") +async def agent(interaction: discord.Interaction): + agents = { + "Duelists": ["Jett", "Phoenix", "Raze", "Reyna", "Yoru", "Neon", "Iso"], + "Controllers": ["Brimstone", "Viper", "Omen", "Astra", "Harbor"], + "Initiators": ["Sova", "Breach", "Skye", "KAY/O", "Fade", "Gekko"], + "Sentinels": ["Killjoy", "Cypher", "Sage", "Chamber", "Deadlock"] + } + + # Pick a random category and agent + category = random.choice(list(agents.keys())) + agent = random.choice(agents[category]) + + embed = discord.Embed( + title="🎯 Valorant Agent Picker", + color=discord.Color.from_rgb(152,0,0) + ) + embed.add_field(name="Selected Agent", value=agent, inline=False) + embed.add_field(name="Role", value=category, inline=False) + embed.set_footer(text=f"Selected for {interaction.user.display_name}") + + await interaction.response.send_message(embed=embed) + +@client.tree.command(name="champion", description="Get a random League of Legends champion") +async def champion(interaction: discord.Interaction): + champions = { + "Top": ["Aatrox", "Camille", "Darius", "Fiora", "Garen", "Irelia", "Jax", "K'Sante", "Malphite", "Mordekaiser", "Nasus", "Ornn", "Riven", "Sett", "Teemo"], + "Jungle": ["Bel'Veth", "Diana", "Elise", "Evelynn", "Graves", "Hecarim", "Kayn", "Kindred", "Lee Sin", "Master Yi", "Nidalee", "Rammus", "Viego", "Warwick"], + "Mid": ["Ahri", "Akali", "Annie", "Cassiopeia", "Fizz", "Katarina", "LeBlanc", "Lux", "Orianna", "Syndra", "Twisted Fate", "Veigar", "Yasuo", "Zed"], + "Bot": ["Aphelios", "Ashe", "Caitlyn", "Draven", "Ezreal", "Jhin", "Jinx", "Kai'Sa", "Lucian", "Miss Fortune", "Samira", "Tristana", "Vayne", "Xayah"], + "Support": ["Blitzcrank", "Brand", "Janna", "Leona", "Lulu", "Morgana", "Nautilus", "Pyke", "Rakan", "Senna", "Seraphine", "Soraka", "Thresh", "Yuumi"] + } + + # Pick a random lane and champion + lane = random.choice(list(champions.keys())) + champion = random.choice(champions[lane]) + + embed = discord.Embed( + title="⚔️ League Champion Picker", + color=discord.Color.from_rgb(152,0,0) + ) + embed.add_field(name="Selected Champion", value=champion, inline=False) + embed.add_field(name="Lane", value=lane, inline=False) + embed.set_footer(text=f"Selected for {interaction.user.display_name}") + + await interaction.response.send_message(embed=embed) + +@client.tree.command(name="trivia", description="Play a trivia game") +async def trivia(interaction: discord.Interaction): + class TriviaView(discord.ui.View): + def __init__(self, correct_answer): + super().__init__() + self.correct_answer = correct_answer + + @discord.ui.button(label="A", style=discord.ButtonStyle.primary) + async def answer_a(self, interaction: discord.Interaction, button: discord.ui.Button): + if "A" == self.correct_answer: + await interaction.response.send_message("Correct!", ephemeral=True) + else: + await interaction.response.send_message("Wrong!", ephemeral=True) + + # Example usage + embed = discord.Embed(title="Trivia Question", description="What is 2+2?") + embed.add_field(name="A", value="4") + embed.add_field(name="B", value="5") + await interaction.response.send_message(embed=embed, view=TriviaView("A")) + +@client.tree.command(name="userinfo") +async def userinfo(interaction: discord.Interaction, member: discord.Member): + embed = discord.Embed(title="User Information", color=discord.Color.from_rgb(152,0,0)) + embed.add_field(name="Joined Server", value=member.joined_at.strftime("%Y-%m-%d")) + embed.add_field(name="Account Created", value=member.created_at.strftime("%Y-%m-%d")) + embed.add_field(name="Roles", value=", ".join([role.name for role in member.roles[1:]])) + await interaction.response.send_message(embed=embed) + +#------------------------------------------------------------------------------------------------# +#CREATE ROLES & GET ROLE +'''@client.event +async def on_raw_reaction_add(payload): + message_id = payload.message_id + member = payload.member + if message_id == 936082409127022592: + guild = client.get_guild(759211704419614781) + #await guild.create_text_channel('fart-channel') + await guild.create_role(name="God", colour=discord.Colour(0x980000),permissions=discord.Permissions(permissions=0x00000008),mentionable=False,hoist=True,reason="Because Jared is just better than you.") + await asyncio.sleep(5) + #await role.delete(discord.utils.get(guild.roles, name='God')) + await member.add_roles(discord.utils.get(guild.roles, name='God'))''' + +#REMOVE ROLES FROM SERVER +'''@client.event +async def on_raw_reaction_add(payload): + message_id = payload.message_id + member = payload.member + if message_id == 936082409127022592: + guild = client.get_guild(759211704419614781) + await member.remove_roles(discord.utils.get(guild.roles, name='mod')) + await asyncio.sleep(5) + #await role.delete(discord.utils.get(guild.roles, name='God')) +#Random Error +@client.event +async def on_command_error(ctx, error): + if isinstance(error, commands.MissingRequiredArgument): + await ctx.send("Please pass in all required arguments.") +''' + +@client.event +async def on_command_error(ctx, error): + if isinstance(error, commands.CommandNotFound): + await ctx.send("Command not found!") + logger.error(f"Command error: {str(error)}") + elif isinstance(error, commands.MissingPermissions): + await ctx.send("You don't have permission to use this command!") + logger.error(f"Command error: {str(error)}") + +client.run(os.getenv('DISCORD_TOKEN')) \ No newline at end of file