import random import discord from discord.ext import commands client = commands.Bot(command_prefix='.') @client.event async def on_ready(): print('Bot is ready.') @client.event async def on_member_join(ctx, member): await ctx.send(f'{member} has joined the server.') @client.event async def on_member_remove(ctx, member): await ctx.send(f'{member} has left the server.') @client.command() async def ping(ctx): await ctx.send(f'Pong! {round(client.latency * 1000)}ms') @client.command(aliases=['8ball']) async def _8ball(ctx, *, question): responses=['It is certain.', 'It is decidedly so.', 'Without a doubt.', 'Yes - definitely.', 'You may rely on it.', 'As I see it, yes.', 'Most likely.', 'Outlook good.', 'Yes.', 'Signs point to good.', 'Reply hazy, try again.', 'Ask again later.', 'Better not tell you now.', 'Cannot predict now.', 'Concentrate and ask again.', "Don't count on it", 'My reply is no.', 'My sources say no.', 'Outlook not so good.', 'Very doubtful.'] await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}') @client.command() async def clear(ctx, amount=5): await ctx.channel.purge(limit=amount) @client.command() async def kick(ctx, member : discord.Member, *, reason=None): await member.kick(reason=reason) await ctx.send(f'Reason: {reason}') @client.command() async def ban(ctx, member : discord.Member, *, reason=None): await member.ban(reason=reason) await ctx.send(f'Reason: {reason}') @client.command() async def unban(ctx, member): banned_users = await ctx.guild.bans() member_name, member_discriminator = member.split('#') for ban_entry in banned_users: user = ban_entry.user if(user.name, user.discriminator) == (member_name, member_discriminator): await ctx.guild.unban(user) await ctx.send(f'Unbanned {user.name}#{user.discriminator}.') return client.run('ENTER BOT TOKEN HERE')