Spaces:
Sleeping
Sleeping
Rifat Azad commited on
Commit ยท
cce1709
1
Parent(s): 3ff7d5a
update coinflip command
Browse files- 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.
|
| 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.
|
| 843 |
async def coinflip(ctx):
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
"
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
"
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
"
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 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
|