Rifat Azad commited on
Commit
cce1709
ยท
1 Parent(s): 3ff7d5a

update coinflip command

Browse files
Files changed (1) hide show
  1. pydvpl_bot.py +48 -87
pydvpl_bot.py CHANGED
@@ -36,7 +36,7 @@ load_dotenv()
36
  # DEFINES ------------------------------------------------------ START
37
 
38
 
39
- BOT_VERSION = '1.4.0'
40
 
41
  AUTHORIZED_USER_ID = os.getenv('AUTHORIZED_ID')
42
 
@@ -296,7 +296,7 @@ async def help(ctx):
296
  # Add fields for different categories of commands with their descriptions
297
  embed.add_field(name="PyDVPL Prefix:", value="`/` - Discord's slash command prefix.\n`>>` - PyDVPL default prefix.")
298
  embed.add_field(name="Dvpl Commands:", value="`compress` - Compresses files.\n`decompress` - Decompresses files.", inline=False)
299
- embed.add_field(name="User Utility Commands:", value="`ping` - Checks the bot's latency.\n`invite` - Get the bot's invite link.\n`uptime` - Displays the bot's uptime.\n`clock` - Shows the current date and time.\n`chat` - Chat with AI LLM models like 'phind', 'chatgpt' & 'blackboxai'.", inline=False)
300
  embed.add_field(name="Premium User Commands:", value="`chat` - Chat with AI LLM models like 'phind', 'chatgpt' & 'blackboxai'.\n`image` - Generate images with 'craiyon' AI.", inline=False)
301
  embed.add_field(name="Moderator Commands:", value="`kick` - Kick a member from the server.\n`ban` - Ban a member from the server.\n`timeout` - Timeout a member for a specified duration.\n`purge` - Bulk deletes set amount of messages in guilds.", inline=False)
302
  embed.add_field(name="Admin Utility Commands:", value="`stats` - Displays bot statistics.\n`list` - Lists server members.\n`say` - Make the bot say something.\n`announce` - Announces a message to a channel.\n`activity` - Sets bot activity status.\n`online` - Sets bot status to online.\n`dnd` - Sets bot status to Do Not Disturb.\n`offline` - Sets bot status to offline.\n`clean` - Cleans up bot's messages.\n`update` - Update a Python package using pip.\n`ip` - Shows the IP address of the current server.", inline=False)
@@ -839,92 +839,53 @@ async def image(ctx, *, prompt: str):
839
  # FUNCTION ------------------------------------------------------ SPLIT
840
 
841
 
842
- @bot.hybrid_command()
843
  async def coinflip(ctx):
844
- coin_frames = [
845
- "```\n"
846
- " ___________\n"
847
- " / \\\n"
848
- "| |\n"
849
- "| - |\n"
850
- "| |\n"
851
- " \\___________/\n"
852
- "```",
853
- "```\n"
854
- " ___________\n"
855
- " / \\\n"
856
- "| |\n"
857
- "| / |\n"
858
- "| |\n"
859
- " \\___________/\n"
860
- "```",
861
- "```\n"
862
- " ___________\n"
863
- " / \\\n"
864
- "| |\n"
865
- "| | |\n"
866
- "| |\n"
867
- " \\___________/\n"
868
- "```",
869
- "```\n"
870
- " ___________\n"
871
- " / \\\n"
872
- "| |\n"
873
- "| \\ |\n"
874
- "| |\n"
875
- " \\___________/\n"
876
- "```",
877
- "```\n"
878
- " ___________\n"
879
- " / \\\n"
880
- "| |\n"
881
- "| - |\n"
882
- "| |\n"
883
- " \\___________/\n"
884
- "```",
885
- "```\n"
886
- " ___________\n"
887
- " / \\\n"
888
- "| |\n"
889
- "| / |\n"
890
- "| |\n"
891
- " \\___________/\n"
892
- "```",
893
- "```\n"
894
- " ___________\n"
895
- " / \\\n"
896
- "| |\n"
897
- "| | |\n"
898
- "| |\n"
899
- " \\___________/\n"
900
- "```",
901
- "```\n"
902
- " ___________\n"
903
- " / \\\n"
904
- "| |\n"
905
- "| \\ |\n"
906
- "| |\n"
907
- " \\___________/\n"
908
- "```",
909
- "```\n"
910
- " ___________\n"
911
- " / \\\n"
912
- "| |\n"
913
- "| - |\n"
914
- "| |\n"
915
- " \\___________/\n"
916
- "```"
917
- ]
918
-
919
- flip_msg = await ctx.send("Flipping the coin...")
920
- for frame in coin_frames:
921
- await flip_msg.edit(content=frame)
922
-
923
- result = random.choice(["Heads", "Tails"])
924
- await flip_msg.edit(content=f"The result is.")
925
- await flip_msg.edit(content=f"The result is..")
926
- await flip_msg.edit(content=f"The result is...")
927
- await flip_msg.edit(content=f"The result is **{result}**!")
928
 
929
 
930
  # UTILITY USER_CMD ------------------------------------------------------ END
 
36
  # DEFINES ------------------------------------------------------ START
37
 
38
 
39
+ BOT_VERSION = '1.4.1'
40
 
41
  AUTHORIZED_USER_ID = os.getenv('AUTHORIZED_ID')
42
 
 
296
  # Add fields for different categories of commands with their descriptions
297
  embed.add_field(name="PyDVPL Prefix:", value="`/` - Discord's slash command prefix.\n`>>` - PyDVPL default prefix.")
298
  embed.add_field(name="Dvpl Commands:", value="`compress` - Compresses files.\n`decompress` - Decompresses files.", inline=False)
299
+ embed.add_field(name="User Utility Commands:", value="`ping` - Checks the bot's latency.\n`invite` - Get the bot's invite link.\n`uptime` - Displays the bot's uptime.\n`clock` - Shows the current date and time.\n`chat` - Chat with AI LLM models like 'phind', 'chatgpt' & 'blackboxai'.\n`coinflip - Plays a coinflip game with users or bot`", inline=False)
300
  embed.add_field(name="Premium User Commands:", value="`chat` - Chat with AI LLM models like 'phind', 'chatgpt' & 'blackboxai'.\n`image` - Generate images with 'craiyon' AI.", inline=False)
301
  embed.add_field(name="Moderator Commands:", value="`kick` - Kick a member from the server.\n`ban` - Ban a member from the server.\n`timeout` - Timeout a member for a specified duration.\n`purge` - Bulk deletes set amount of messages in guilds.", inline=False)
302
  embed.add_field(name="Admin Utility Commands:", value="`stats` - Displays bot statistics.\n`list` - Lists server members.\n`say` - Make the bot say something.\n`announce` - Announces a message to a channel.\n`activity` - Sets bot activity status.\n`online` - Sets bot status to online.\n`dnd` - Sets bot status to Do Not Disturb.\n`offline` - Sets bot status to offline.\n`clean` - Cleans up bot's messages.\n`update` - Update a Python package using pip.\n`ip` - Shows the IP address of the current server.", inline=False)
 
839
  # FUNCTION ------------------------------------------------------ SPLIT
840
 
841
 
842
+ @bot.command(help="Plays a coinflip game with users or bot")
843
  async def coinflip(ctx):
844
+ emojis = ["๐Ÿˆ", "๐Ÿ˜ธ"] # Add more emojis if needed
845
+
846
+ # Create an embedded message
847
+ embed = discord.Embed(title="Coin Flip", description="React with ๐Ÿˆ for tails or ๐Ÿ˜ธ for heads!", color=discord.Colour.yellow())
848
+ embed.set_footer(text=f"Requested by {ctx.author.display_name}", icon_url=ctx.author.display_avatar.url if ctx.author.display_avatar else discord.Embed.Empty)
849
+ embed.timestamp = ctx.message.created_at
850
+ flip_msg = await ctx.send(embed=embed)
851
+
852
+ # Add reactions for heads and tails
853
+ for emoji in emojis:
854
+ await flip_msg.add_reaction(emoji)
855
+
856
+ # Wait for reactions
857
+ def check(reaction, user):
858
+ return user == ctx.author and str(reaction.emoji) in emojis
859
+
860
+ try:
861
+ reaction, user = await bot.wait_for('reaction_add', timeout=30.0, check=check)
862
+ user_choice = reaction.emoji
863
+ except asyncio.TimeoutError:
864
+ await ctx.send("You didn't react in time. Aborting...")
865
+ return
866
+
867
+ if user == bot.user: # If the bot reacted, skip waiting
868
+ user_choice = random.choice(emojis)
869
+
870
+ await asyncio.sleep(1)
871
+
872
+ for i in range(3, 0, -1):
873
+ embed.description = f"Flipping the coin in {i}..."
874
+ await flip_msg.edit(embed=embed)
875
+ await asyncio.sleep(1)
876
+
877
+ result = random.choice(emojis)
878
+ embed.description = f"The result is **{result}**!"
879
+
880
+ if result == user_choice:
881
+ winner = ctx.author.display_name
882
+ else:
883
+ winner = "The bot"
884
+
885
+ embed.set_footer(text=f"Winner: {winner}", icon_url=ctx.author.display_avatar.url if ctx.author.display_avatar else discord.Embed.Empty)
886
+ await flip_msg.edit(embed=embed)
887
+
888
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
889
 
890
 
891
  # UTILITY USER_CMD ------------------------------------------------------ END