Facebook
From Dominik Banach, 4 Years ago, written in Python.
This paste is a reply to Re: irytowanie Szpadzika - python discord bot from Dominik Banach - view diff
Embed
Download Paste or View Raw
Hits: 181
  1. import discord
  2. from discord.ext import commands
  3. from time import sleep
  4.  
  5. client = commands.Bot(command_prefix = '>')
  6.  
  7. @client.event
  8. async def on_ready():
  9.     print("BOT online")
  10.  
  11. @client.command()
  12. async def clear(ctx, *, ile = 1):
  13.  
  14.     try:
  15.         if ile > 0:
  16.              await ctx.channel.purge(limit = ile + 1)
  17.         else:
  18.              await ctx.send("Podaj wartość większą od zera!")
  19.  
  20.     except ValueError:
  21.         await ctx.send("Ilość wiadomości do usunięcia musi być podana liczbą!")
  22.    
  23.  
  24. @client.command()
  25. async def szpadzik(ctx, *, ile):
  26.     for i in range(int(ile)):
  27.  
  28.         await ctx.send(f"Szpadzik to jest ziomal! po raz {i+1}")  
  29.         sleep(1)
  30.  
  31. client.run("NzA0MDEyNDc0MTA1NTkzODk3.XqdFjQ.okaf4Hdbz705NmzDtXqMBl42a6Q")
  32.  
  33.  
  34.