Advertisement
Guest User

for ginja

a guest
Jun 19th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.79 KB | None | 0 0
  1. import discord
  2. from discord.ext.commands import Bot
  3. from discord.ext import commands
  4. import asyncio
  5. import random
  6. from bs4 import BeautifulSoup
  7. import urllib.request
  8. import re
  9. import os
  10. from boto.s3.connection import S3Connection
  11.  
  12. client = commands.Bot(command_prefix='j!')
  13. client.remove_command('help')
  14.  
  15. @client.event
  16. async def on_ready():
  17.     await client.change_presence(status=discord.Status.online, activity=discord.Game('j!help | Created by Johnodon'))
  18.     print('Bot is ready.')
  19.  
  20. @client.event
  21. async def on_command_error(ctx, error):
  22.     if isinstance(error, commands.CommandNotFound):
  23.         print('Error: Invalid command run.')
  24.         await ctx.send('Invalid command used.')
  25.  
  26. @client.event
  27. async def on_member_join(member):
  28.     print(f'{member} has joined the server.')
  29.  
  30. @client.event
  31. async def on_member_remove(member):
  32.     print(f'{member} has left the server.')
  33.  
  34. @client.command()
  35. async def ping(ctx):
  36.     await ctx.send(f'Pong! ({round(client.latency * 1000)}ms)')
  37.  
  38. @client.command(aliases=['8ball'])
  39. async def _8ball(ctx, *, question):
  40.     responses = ['It is certain.',
  41.                  'It is decidedly so.',
  42.                  'Without a doubt.',
  43.                  'Yes - definitely.',
  44.                  'You may rely on it.',
  45.                  'As I see it, yes.',
  46.                  'Most likely.',
  47.                  'Outlook good.',
  48.                  'Yes.',
  49.                  'Signs point to yes.',
  50.                  'Reply hazy, try again.',
  51.                  'Ask again later.',
  52.                  'Better not tell you now.',
  53.                  'Cannot predict now.'
  54.                  'Concentrate and ask again.',
  55.                  "Don't count on it.",
  56.                  'My reply is no.',
  57.                  'My sources say no.',
  58.                  'Outlook not so good.',
  59.                  'Very doubtful.']
  60.     await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')
  61.  
  62. @client.command()
  63. async def add(ctx, left : int, right : int):
  64.     await ctx.send(left + right)
  65.  
  66. @client.command()
  67. async def subtract(ctx, left : int, right : int):
  68.     await ctx.send(left - right)
  69.  
  70. @client.command()
  71. async def multiply(ctx, left : int, right : int):
  72.     await ctx.send(left * right)
  73.  
  74. @client.command()
  75. async def divide(ctx, left : int, right : int):
  76.     await ctx.send(left / right)
  77.  
  78. @client.command()
  79. async def help(ctx):
  80.     embed = discord.Embed(title="The Hangout Discord Server", colour=discord.Colour(0xffec), url="http://thehangout.ga/")
  81.  
  82.     embed.set_author(name="Help", icon_url="https://static.wixstatic.com/media/04af07_8ed6ef39adca4c57a858b0cc991065dd~mv2.png/v1/fill/w_128,h_128,al_c,q_80/the-hangoutlogo%20copy.webp")
  83.     embed.set_footer(text="JohnodonBot")
  84.  
  85.     embed.add_field(name="j!help", value="Shows this menu", inline=False)
  86.     embed.add_field(name="j!ping", value="Displays the Bot's ping", inline=False)
  87.     embed.add_field(name="j!8ball [Question]", value="Ask it anything!", inline=False)
  88.     embed.add_field(name="j!add [number] [number]", value="Adds two numbers", inline=True)
  89.     embed.add_field(name="j!subtract [number] [number]", value="Subtracts two numbers", inline=True)
  90.     embed.add_field(name="j!multiply [number] [number]", value="Multiplies two numbers", inline=True)
  91.     embed.add_field(name="j!divide [number] [number]", value="Divides two numbers", inline=True)
  92.     embed.add_field(name="j!whoisbest", value="Who is best?", inline=False)
  93.     await ctx.send(embed=embed)
  94.  
  95. @client.command()
  96. async def userinfo(ctx, member: discord.Member = None):
  97.     member = ctx.author if not member else member
  98.     roles = [role for role in member.roles]
  99.  
  100.  
  101.     embed = discord.Embed(colour=member.color, timestamp=ctx.message.created_at)
  102.  
  103.     embed.set_author(name=f"User Info = {member}")
  104.     embed.set_thumbnail(url=member.avatar_url)
  105.     embed.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.avatar_url)
  106.  
  107.     embed.add_field(name="ID:", vaulue=member.id)
  108.     embed.add_field(name="Guild Name:", vaulue=member.display_name)
  109.  
  110.     embed.add_field(name="Created at:", vaulue=member.created_at.sfrftime("%a, %#d %B %Y, %I:%M %p UTC"))
  111.     embed.add_field(name="Joined on:", vaulue=member.joined_at.sfrftime("%a, %#d %B %Y, %I:%M %p UTC"))
  112.  
  113.     embed.add_field(name=f"Roles: ({len(roles)})", vaulue=" ".join([role.mention for role in roles]))
  114.     embed.add_field(name="Top Role:", vaulue=member.top_role.mention)
  115.  
  116.     embed.add_field(name="Bot:", vaulue=member.bot)
  117.  
  118.     await ctx.send(embed=embed)
  119.  
  120. @client.command()
  121. async def whoisbest(ctx):
  122.     await ctx.send('<@265913945900974080> is.... Obviously. He made this bot.')
  123.  
  124. @_8ball.error
  125. async def _ball_error(ctx):
  126.     if isinstance(error, commands.MissingRequiredArgument):
  127.         await ctx.send('Enter a question for the 8ball to answer.')
  128.  
  129.  
  130. client.run('REDACTED')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement