diff --git a/cogs/Minigames.py b/cogs/Minigames.py index 6881803..f2292ba 100644 --- a/cogs/Minigames.py +++ b/cogs/Minigames.py @@ -41,6 +41,61 @@ async def _2048(self, ctx): await message.add_reaction('⬅') await message.add_reaction('❌') + @commands.command(aliases=['rps']) + async def rockpaperscissors(self, ctx): + ch1 = ["Rock","Scissors","Paper"] + comp = choice(ch1) + + yet = discord.Embed(title = f"{ctx.author.display_name}'s Rock Paper Scissors Game!", description = f"Status: You haven't clicked on any button yet!", color = ctx.author.color) + + win = discord.Embed(title = f"{ctx.author.display_name}, You Won!", description = f"Status: **You have won!** Bot chose {comp}", color = 0x00FF00) + + out = discord.Embed(title = f"{ctx.author.display_name}, You did not click on time!", description = f"Status: **Timed Out!**", color = discord.Colour.red()) + + lost = discord.Embed(title = f"{ctx.author.display_name}, You Lost!!", description = f"Status: **You have Lost!** Bot had chosen {comp}", color = discord.Color.red()) + + tie = discord.Embed(title = f"{ctx.author.display_name}, It was a Tie!", description = f"Status: **Tie!**, Bot had chosen {comp}", color = ctx.author.color) + m = await ctx.send( + embed=yet, + components=[[Button(style=1, label="Rock"),Button(style=3, label="Paper"),Button(style=ButtonStyle.red, label="Scissors")] + ], + ) + def check(res): + return ctx.author == res.user and res.channel == ctx.channel + + try: + res = await client.wait_for("button_click", check=check, timeout=15) + player = res.component.label + + if player==comp: + await m.edit(embed=tie,components=[]) + + if player=="Rock" and comp=="Paper": + await m.edit(embed=lost,components=[]) + + if player=="Rock" and comp=="Scissors": + await m.edit(embed=win,components=[]) + + + if player=="Paper" and comp=="Rock": + await m.edit(embed=win,components=[]) + + if player=="Paper" and comp=="Scissors": + await m.edit(embed=lost,components=[]) + + + if player=="Scissors" and comp=="Rock": + await m.edit(embed=lost,components=[]) + + if player=="Scissors" and comp=="Paper": + await m.edit(embed=win,components=[]) + + + except TimeoutError: + await m.edit( + embed=out, + components=[], + ) def setup(bot): bot.add_cog(Minigames(bot)) diff --git a/main.py b/main.py index 69eb7ff..56c5fb5 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import discord from discord.ext import commands, tasks from dotenv import load_dotenv +from discord_components import * from main_resources.events import Events from main_resources.functions import * @@ -45,6 +46,7 @@ def get_prefix(bot, message: discord.Message): async def on_ready(): change_status.start() clear_game.start() + DiscordComponents(client) print("Updating databases...") update_guilds_data(bot, guilds_data, DEFAULT_PREFIX) print(f'Logged in as {bot.user.name}#{bot.user.discriminator} ID = {bot.user.id}') diff --git a/requirements.txt b/requirements.txt index ca0c887..eef2334 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ asyncio~=3.4.3 python-dotenv~=0.17.1 requests~=2.25.1 discord~=1.0.1 +discord-components==1.1.4 numpy~=1.19.5 keras~=2.4.3 nltk~=3.6.2