xpyct_bot/cogs/head_or_tails.py

27 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import nextcord
from nextcord.ext import commands
import random
class head_or_tails(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f'Для использования команды повторно жди {round(error.retry_after, 2)} секунд')
@commands.command(aliases = ["орёл_или_решка", "монетка", "монета"])
@commands.cooldown(1, 10, commands.BucketType.user)
async def headortails(self, ctx, answer=None):
if answer == None:
await ctx.reply("Можно использовать только значения Орёл и Решка. Пример команды: $монета Орёл")
else:
if random.choice(["Орёл", "Решка"]) == answer:
await ctx.reply("Ты выиграл!")
else:
await ctx.reply("Ты проиграл :(")
def setup(bot):
bot.add_cog(head_or_tails(bot))