selfbot-legacy/bot/cogs/fun_commands.py

72 lines
2.4 KiB
Python
Raw Normal View History

2025-05-09 21:43:55 +02:00
from bot.cogs.cog_manager import BaseCog
import discord
import random
import asyncio
class FunCog(BaseCog):
def __init__(self, bot):
super().__init__(bot)
async def cmd_horse(self, message):
"""
Toggle horse reactions in a channel
Usage: .horse
"""
if message.channel.id in self.bot.horsin:
self.bot.horsin.remove(message.channel.id)
await message.reply("no longer horsin around D:")
else:
self.bot.horsin.append(message.channel.id)
await message.reply(":D")
async def cmd_rps(self, message):
"""
Play Rock Paper Scissors
Usage: .rps <rock|paper|scissors>
"""
choices = ["rock", "paper", "scissors"]
content = message.content.strip().lower()
parts = content.split(maxsplit=1)
if len(parts) != 2 or parts[1] not in choices:
await message.edit(content="❌ Usage: `.rps <rock|paper|scissors>`")
return
user_choice = parts[1]
bot_choice = random.choice(choices)
# Determine winner
if user_choice == bot_choice:
result = "It's a tie! 🤝"
elif (user_choice == "rock" and bot_choice == "scissors") or \
(user_choice == "paper" and bot_choice == "rock") or \
(user_choice == "scissors" and bot_choice == "paper"):
result = "You win! 🎉"
else:
result = "I win! 🎮"
await message.edit(content=f"You chose {user_choice}, I chose {bot_choice}. {result}")
async def cmd_repeat(self, message):
"""
Repeat a message multiple times
Usage: .repeat29 <text>
"""
content = message.content.strip()
if " " not in content:
await message.edit(content="❌ Usage: `.repeat29 <text>`")
return
text = content.split(" ", 1)[1]
# Don't allow mentions in repeated text
if "@" in text:
text = text.replace("@", "@\u200b") # Insert zero-width space to break mentions
# Delete original command
await message.delete()
# Send 29 times
for _ in range(29):
await message.channel.send(text)
await asyncio.sleep(0.5) # Add small delay to avoid rate limiting