Exemple #1
0
                        value=len(client.servers),
                        inline=True)
    a_details.add_field(name='Current Bot Owner:',
                        value=str(client.bot_info.owner),
                        inline=True)
    a_details.set_footer(
        text='Made in Python3.5+ with discord.py library!',
        icon_url='http://findicons.com/files/icons/2804/plex/512/python.png')
    a_details.set_image(url=message.server.me.avatar_url)
    a_details.set_author(name=message.server.me,
                         icon_url=message.server.me.avatar_url)
    await client.send_message(message.channel, embed=a_details)


commands.add_command(command_name='about',
                     command_function=about,
                     alias='info')
'''Gets a users info'''


async def user(message, client):
    if message.content.startswith(client.pfix + 'user'):
        r = lambda: random.randint(0, 255)
        rr = ('0x%02X%02X%02X' % (r(), r(), r()))
        try:
            username = message.content.replace(
                message.content.split()[0] + ' ', '')
            roles_member = message.server.get_member_named(username).roles
            user_details = discord.Embed(title='',
                                         description='',
                                         colour=int(rr, 16))
Exemple #2
0
            print(pokemon['hp'])
            print(pokemon['defense'])
            print(pokemon['attack'])
            print(pokemon['national_id'])
            print(BASE_URL + sprite['image'])
    except TypeError as e:
        print(e)
        if message.server.id not in ['242887866730938378']:
            await client.send_message(
                message.channel,
                'ERROR {} is not in the Pokedex! Try using all lowercase!'.
                format(parsedPokemon))


commands.add_command(command_name='pokemon',
                     command_function=randPokemon,
                     alias='pokémon')
'''Gets info on a pokemon name/id/pokedexentry'''


async def getPokemon(message, client):
    try:
        parsedPokemon = message.content.replace(
            message.content.split()[0] + ' ', '')

        pokemon = await getPokemonData2('/api/v1/pokemon/' + parsedPokemon,
                                        message, client)

        sprite_uri = pokemon['sprites'][0]['resource_uri']
        description_uri = pokemon['descriptions'][0]['resource_uri']
        type_uri = pokemon['types'][0]['resource_uri']
Exemple #3
0
            await asyncio.sleep(1)
            tbd = await client.send_message(
                message.channel, 'Deleted {} message(s)'.format(len(deleted)))
            await asyncio.sleep(8)
            await client.delete_message(tbd)
        except ValueError:
            await client.send_message(message.channel,
                                      'Error, Did you specify number?')
    else:
        await client.send_message(
            message.channel,
            'You need manage messages permission on this server, to use this commands'
        )


commands.add_command(command_name='clear', command_function=clear_logic)


async def warning_add(message, client):
    if message.author.permissions_in(message.channel).ban_members:
        if message.author.id in admin:
            person = re.sub('[!@<>]', '', message.content)
            r_person = person.split()[1]
            print(r_person)
            if r_person not in warnings.keys():
                warnings[r_person] = []
            warnings[r_person].append(' '.join(person.split()[1:]))
            with open("database/warn.json", "w+") as outfile:
                outfile.write(json.dumps(warnings))
            x = message.server.get_member(r_person)
            await asyncio.sleep(1)
Exemple #4
0

def bdel(s, r):
    return (s[len(r):] if s.startswith(r) else s)


'''A simple ping testing command.'''


async def ping_logic(message, client):
    start2 = time.time()
    await client.send_message(message.channel, 'Pong')


commands.add_command(command_name='ping',
                     command_function=ping_logic,
                     alias='test')
'''displays bots current uptime.'''


async def uptime_logic(message, client):
    await client.send_message(
        message.channel, "I have been awake for: " + str(time.time() - start))


commands.add_command(command_name='uptime', command_function=uptime_logic)
'''Gets sentiment analysis for a word in the AFINN-111 database'''


async def afinn_logic(message, client):
    winput = bdel(message.content, message.content.split()[0] + ' ')
Exemple #5
0
'''Random and Fun Commands!'''
import modules.commands as commands
import aiohttp
import re
import json
import asyncio

alphabet = list('abcdefghijklmnopqrstuvwxyz')
wingdings = '♋︎ ♌︎ ♍︎ ♎︎ ♏︎ ♐︎ ♑︎ ♒︎ ♓︎ &︎ &︎ ●︎ ❍︎ ■︎ □︎ ◻︎ ❑︎ ❒︎ ⬧︎ ⧫︎ ◆︎ ❖︎ ⬥︎ ⌧︎ ⍓︎ ⌘︎'.split()
'''Just F#cking Google it!'''
async def jfgi(message, client):
    await client.send_message(message.channel, 'http://www.justfuckinggoogleit.com/')
commands.add_command(command_name='jfgi', command_function=jfgi)


''';)'''
async def hotdog(message, client):
    await client.send_message(message.channel, ':hotdog: '*10)
commands.add_command(command_name='hotdog', command_function=hotdog)


'''Ceaser Cipher encoder/decoder.'''
async def ccipher(message, client):
    if message.content.split()[1] == 'e':
        encode = True
    elif message.content.split()[1] == 'd':
        encode = False
    else:
        await client.send_message(message.channel, 'You didn\'t specify a mode!')

    key = message.content.split()[2]
Exemple #6
0

async def restart_logic(message, client):
    if message.author.id == client.bot_info.owner.id:
        await client.send_message(
            message.channel,
            'Restarting... Please wait 5-10 seconds before trying to run any commands!'
        )
        os.execl(sys.executable, sys.executable, *sys.argv)
    else:
        await client.send_message(message.channel,
                                  'ERROR you need to be a bot owner!')


commands.add_command(command_name='restart',
                     command_function=restart_logic,
                     alias='reset, reload')
'''Update bot from github(only works if git cloned! working on a fix).'''


async def update_logic(message, client):
    if message.author.id in client.bot_info.owner.id:
        await client.send_message(message.channel, 'Updating...')
        g = git.cmd.Git()
        u = g.pull('-v')
        await client.send_message(message.channel, '```' + str(u) + '```')
        if str(u) == 'Already up-to-date.':
            await client.send_message(message.channel,
                                      'Already Up To Date! Not restarting')
        else:
            await client.send_message(message.channel,
import modules.commands as commands
import aiohttp
import asyncio

'''parsing and cleaning raw html for custom google search'''
async def g_search_custom(message, client, search):
    loop = asyncio.get_event_loop()
    headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
    search = search.replace(' ', '+')
    async with aiohttp.get('https://www.google.com/search?q={}&start=1&num=1'.format(search), headers=headers) as gr:
        try: 
            from BeautifulSoup import BeautifulSoup
        except ImportError:
            from bs4 import BeautifulSoup
        html = await gr.text()
        results = []
        parsed_html = BeautifulSoup(html, "html.parser")
        for item in parsed_html.find_all('h3', attrs={'class': 'r'}):
            results.append(str(item.a['href']).replace('/url?q=', '').split('&sa=U&ved=')[0])
    await client.send_message(message.channel, 'Top result for `{}`: '.format(search) + ''.join(results[0]))

'''searches google'''
async def search_google(message, client):
    search_google = message.content.replace(message.content.split()[0] + ' ', '')
    await g_search_custom(message, client, search_google)
commands.add_command(command_name='google', command_function=search_google, alias='search')