Всем привет, как сделать проверку на указание участника и числа в сообщении. Хочу сделать очистку чата. Пробовал через none, не работает.
import disnake
import os
from disnake.ext import commands
class Moderator(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@commands.command()
async def clear_num(self, ctx, amount: int):
await ctx.channel.purge(limit = amount + 1)
await ctx.send(f'Deleted `{amount} message` ', delete_after = 3)
@commands.command()
@commands.has_permissions(manage_messages=True)
async def clear_user(self, ctx, member: disnake.Member, amount: int):
if member is None:
await ctx.channel.purge(limit=amount, check=lambda message: message.author == member)
await ctx.send('Please specify the participant', delete_after = 3)
if amount is None:
await ctx.channel.purge(limit=amount, check=lambda message: message.author == member)
await ctx.send('Please specify the number of messages', delete_after = 3)
await ctx.channel.purge(limit=amount, check=lambda message: message.author == member)
await ctx.send(f'Deleted `{amount} message` of {member.mention} ', delete_after = 3)
def setup(bot: commands.Bot):
bot.add_cog(Moderator(bot))