Facebook
From Sloppy Lizard, 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 90
  1. import random
  2. import discord
  3. from discord.ext import commands
  4.  
  5. client = commands.Bot(command_prefix='.')
  6.  
  7.  
  8. @client.event
  9. async def on_ready():
  10.     print('Bot is ready.')
  11.  
  12. @client.event
  13. async def on_member_join(ctx, member):
  14.     await ctx.send(f'{member} has joined the server.')
  15.  
  16. @client.event
  17. async def on_member_remove(ctx, member):
  18.     await ctx.send(f'{member} has left the server.')
  19.  
  20. @client.command()
  21. async def ping(ctx):
  22.     await ctx.send(f'Pong! {round(client.latency * 1000)}ms')
  23.  
  24. @client.command(aliases=['8ball'])
  25. async def _8ball(ctx, *, question):
  26.     responses=['It is certain.',
  27.                'It is decidedly so.',
  28.                'Without a doubt.',
  29.                'Yes - definitely.',
  30.                'You may rely on it.',
  31.                'As I see it, yes.',
  32.                'Most likely.',
  33.                'Outlook good.',
  34.                'Yes.',
  35.                'Signs point to good.',
  36.                'Reply hazy, try again.',
  37.                'Ask again later.',
  38.                'Better not tell you now.',
  39.                'Cannot predict now.',
  40.                'Concentrate and ask again.',
  41.                "Don't count on it",
  42.                'My reply is no.',
  43.                'My sources say no.',
  44.                'Outlook not so good.',
  45.                'Very doubtful.']
  46.     await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')
  47.  
  48. @client.command()
  49. async def clear(ctx, amount=5):
  50.     await ctx.channel.purge(limit=amount)
  51.  
  52. @client.command()
  53. async def kick(ctx, member : discord.Member, *, reason=None):
  54.     await member.kick(reason=reason)
  55.     await ctx.send(f'Reason: {reason}')
  56.  
  57. @client.command()
  58. async def ban(ctx, member : discord.Member, *, reason=None):
  59.     await member.ban(reason=reason)
  60.     await ctx.send(f'Reason: {reason}')
  61.  
  62. @client.command()
  63. async def unban(ctx, member):
  64.     banned_users = await ctx.guild.bans()
  65.     member_name, member_discriminator = member.split('#')
  66.  
  67.     for ban_entry in banned_users:
  68.         user = ban_entry.user
  69.  
  70.         if(user.name, user.discriminator) == (member_name, member_discriminator):
  71.             await ctx.guild.unban(user)
  72.             await ctx.send(f'Unbanned {user.name}#{user.discriminator}.')
  73.             return
  74.  
  75.  
  76. client.run('ENTER BOT TOKEN HERE')