65 lines
2.4 KiB
Python
65 lines
2.4 KiB
Python
![]() |
import random
|
||
|
import asyncio
|
||
|
|
||
|
class FunCommands:
|
||
|
def __init__(self, bot):
|
||
|
self.bot = bot
|
||
|
|
||
|
async def cmd_horse(self, message):
|
||
|
"""Toggle horse reactions in a channel"""
|
||
|
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"""
|
||
|
parts = message.content.split(" ", 1)
|
||
|
if len(parts) != 2:
|
||
|
await message.reply("Usage: `.rps <item>`", silent=True)
|
||
|
return
|
||
|
|
||
|
item = parts[1]
|
||
|
|
||
|
# Easter eggs
|
||
|
if item.lower() == "dick":
|
||
|
await message.reply("Scissors beats dick any day :3", silent=True)
|
||
|
return
|
||
|
if item == "<@696800726084747314>":
|
||
|
await message.reply("Head so thick that i would try rock but the rock would break")
|
||
|
return
|
||
|
|
||
|
# The main game
|
||
|
choice = random.choice([1, 2, 3]) # 1=rock, 2=paper, 3=scissors
|
||
|
rps_map = {1: 'r', 2: 'p', 3: 's'}
|
||
|
rps_map_reverse = {'r': 1, 'p': 2, 's': 3} # Fixed the reversed mapping
|
||
|
shortmaps = {'r': 'rock', 'p': 'paper', 's': 'scissors'}
|
||
|
|
||
|
beat_map = {1: 3, 2: 1, 3: 2} # What beats what: rock>scissors, paper>rock, scissors>paper
|
||
|
|
||
|
# Determine user choice
|
||
|
iid = 0
|
||
|
for k, v in rps_map_reverse.items():
|
||
|
if item.lower().startswith(k):
|
||
|
iid = v
|
||
|
break
|
||
|
|
||
|
if iid == 0:
|
||
|
await message.reply("Invalid choice!", silent=True)
|
||
|
return
|
||
|
|
||
|
if choice == iid:
|
||
|
await message.reply(f"Huh we chose the same thing. Try again!", silent=True)
|
||
|
elif beat_map[iid] == choice:
|
||
|
await message.reply(f"Welp, ggs, I won. I chose `{shortmaps[rps_map[choice]]}`", silent=True)
|
||
|
else:
|
||
|
await message.reply(f"Oop, you lost. Try again later! I chose `{shortmaps[rps_map[choice]]}`", silent=True)
|
||
|
|
||
|
async def cmd_repeat(self, message):
|
||
|
"""Repeat a message every 29 minutes"""
|
||
|
await message.reply("oop ok")
|
||
|
while True:
|
||
|
await message.channel.send("you asked dad")
|
||
|
await asyncio.sleep(29 * 60) # 29 minutes
|