Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- import requests
- import random
- bot = commands.Bot(command_prefix='.')
- def isint(s):
- try:
- int(s)
- return True
- except ValueError:
- return False
- async def do_removal(message, limit, predicate):
- if message.channel.permissions_for(message.author).manage_messages or message.author.id == '205346839082303488':
- await bot.purge_from(message.channel, limit=limit, before=message, check=predicate)
- else:
- await bot.say('not enuff perms')
- class Public:
- def __init__(self, bot):
- self.bot = bot
- @commands.command(pass_context=True)
- async def lookup(self, ctx):
- ip = ctx.message.content[8:]
- print(ip)
- verify = ip.replace('.', '')
- if verify.isdigit():
- r = requests.get('http://ip-api.com/json/{}'.format(ip), allow_redirects=True)
- country = r.json()['country']
- city = r.json()['city']
- isp = r.json()['isp']
- region = r.json()['region']
- timezone = r.json()['timezone']
- zipcode = r.json()['zip']
- latitude = r.json()['lat']
- longitude = r.json()['lon']
- org = r.json()['org']
- await bot.say('''```
- Country: {}
- City: {}
- ISP: {}
- Region: {}
- Time Zone: {}
- Zip Code: {}
- Latitude: {}
- Longitude: {}
- Organization: {}```'''.format(
- country, city, isp, region, timezone, zipcode, latitude, longitude, org))
- else:
- await bot.say("you dumb or wat, is that an ip?")
- @commands.command(pass_context=True)
- async def purge(self, ctx, amount: int, member: discord.Member=None):
- await do_removal(ctx.message, amount, lambda e: member is None or e.author == member)
- '''if member:
- await do_removal(ctx.message, amount, lambda e: e.author == member)
- else:
- await do_removal(ctx.message, amount, lambda e: True)'''
- @commands.command(pass_context=True)
- async def randint(self, ctx):
- msg = ctx.message.content.split()
- if len(msg) == 3:
- if isint(msg[1]) and isint(msg[2]):
- await bot.say(random.randint(int(msg[1]), int(msg[2])))
- else:
- await bot.say('are those ints?!')
- else:
- await bot.say('you need a start and an end integer dumbfook')
- @commands.command(pass_context=True)
- async def cal(self, ctx):
- msg = ctx.message.content.split()
- args = ''.join(ctx.message.content.split()[1:])
- disallowed = ['**', '/0', '-0', '+0']
- allowed = '0123456789\/*-+.() '
- wl_fail = False
- bl_fail = False
- if len(msg) > 1:
- for i in args:
- if i not in allowed:
- wl_fail = True
- for i in disallowed:
- if i in args:
- bl_fail = True
- if wl_fail or bl_fail:
- await bot.say('did you just try to eval bomb me u dickhead')
- else:
- try:
- await bot.say(eval(args))
- except SyntaxError:
- await bot.say('wtf did you enter??')
- else:
- await bot.say('.calculate takes in only 1 parameter')
- @commands.command(pass_context=True)
- async def ban(self, ctx):
- msg = ctx.message.content.split()
- author = ctx.message.author
- if author.server_permissions.ban_members:
- if len(msg) == 2:
- if author.top_role > ctx.message.mentions[0].top_role:
- try:
- await bot.ban(ctx.message.mentions[0])
- except discord.errors.Forbidden:
- await bot.say('u or da bot ain\'t got privilegesss')
- else:
- await bot.say('banned this fgt')
- else:
- await bot.say('which fgt?')
- elif author.id == '205346839082303488':
- if len(msg) == 2:
- try:
- await bot.ban(ctx.message.mentions[0])
- except discord.errors.Forbidden:
- await bot.say('bot ain\'t got privilegesss, or u didn\'t tag the fgt')
- else:
- await bot.say('banned this fgt')
- else:
- await bot.say('which fgt?')
- else:
- await bot.say('u ain\'t got perms fgt')
- @commands.command(pass_context=True)
- async def kick(self, ctx):
- msg = ctx.message.content.split()
- author = ctx.message.author
- if author.server_permissions.kick_members:
- if len(msg) == 2:
- if author.top_role > ctx.message.mentions[0].top_role:
- try:
- await bot.kick(ctx.message.mentions[0])
- except discord.errors.Forbidden:
- await bot.say('u ain\'t got privilegesss, or u didn\'t tag the fgt')
- else:
- await bot.say('kicked this fgt')
- elif author.id == '205346839082303488':
- if len(msg) == 2:
- try:
- await bot.kick(ctx.message.mentions[0])
- except discord.errors.Forbidden:
- await bot.say('bot ain\'t got privilegesss')
- else:
- await bot.say('kick this fgt')
- else:
- await bot.say('which fgt?')
- @commands.command()
- async def botinfo(self):
- await bot.say('''```
- How many fgts have invited me to their server: {}
- How many shitty channels i am connected to: {}
- How many shitfaces i've encountered: {}```'''.format(len(bot.servers),
- sum([len(s.channels) for s in bot.servers]),
- sum([len(s.members) for s in bot.servers])))
- @commands.command(pass_context=True)
- async def serverinfo(self, ctx):
- channels = [channel for channel in ctx.message.server.channels if channel.type == discord.ChannelType.text]
- await bot.say('''```
- Dis server is called {},
- {} channels in dis gay server,
- {} members in this server,
- ```'''.format(ctx.message.server.name, len(channels), len(ctx.message.server.members)))
- def setup(bot):
- bot.add_cog(Public(bot))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement