-
Notifications
You must be signed in to change notification settings - Fork 0
/
rps.py
74 lines (69 loc) · 2.75 KB
/
rps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import discord
import random
from discord.ext import commands
async def rps(ctx, bot):
msg = await ctx.send("Choose rock, paper or scissors!")
await msg.add_reaction('🪨')
await msg.add_reaction('📜')
await msg.add_reaction('✂️')
items = ['🪨', '📜', '✂️']
computer = random.choice(items)
def checkNotBot(reaction, user):
return user != bot.user
reaction, user = await bot.wait_for("reaction_add", timeout=30.0, check=checkNotBot)
player = str(reaction.emoji)
if player == computer:
embed = discord.Embed(
title="Tie!",
description=f"We both chose {player}!"
)
await ctx.send(embed=embed)
elif player == '🪨':
if computer == '📜':
embed = discord.Embed(
title="You Lose!",
description=f"I picked: {computer}\n\nYou picked: {player}\n\n{computer} covers {player}!"
)
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title="You win!",
description=f"I picked: {computer}\n\nYou picked: {player}\n\n{player} crushes {computer}!"
)
await ctx.send(embed=embed)
elif player == '📜':
if computer == '✂️':
embed = discord.Embed(
title="You lose!",
description=f"I picked: {computer}\n\nYou picked: {player}\n\n{computer} cuts {player}!"
)
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title="You win!",
description=f"I picked: {computer}\n\nYou picked: {player}\n\n{player} covers {computer}!"
)
await ctx.send(embed=embed)
elif player == '✂️':
if computer == '🪨':
embed = discord.Embed(
title="You lose!",
description=f"I picked: {computer}\n\nYou picked: {player}\n\n{computer} smashes {player}!"
)
await ctx.send(embed=embed)
else:
embed = discord.Embed(
title="You win!",
description=f"I picked: {computer}\n\nYou picked: {player}\n\n{player} cuts {computer}!"
)
await ctx.send(embed=embed)
msg = await ctx.send("Do you want to play again?")
await msg.add_reaction('✅')
await msg.add_reaction('❌')
reaction, user = await bot.wait_for("reaction_add", timeout=30.0, check=checkNotBot)
if str(reaction.emoji) == '✅':
await ctx.channel.purge(limit=3)
await rps(ctx, bot)
else:
await ctx.channel.purge(limit=3)
await ctx.send("Thank you for playing Rock-Paper-Scissors!")