edison-moreland
8/15/2017 - 4:26 AM

bot.py

import discord

client = discord.Client()
commands = dict()
nerds = list()


def command(in_function):
    commands.update({in_function.__name__: in_function})
    return in_function


@command
async def gay(message, *args):
    for name in args:
        await client.send_message(message.channel, "{} is so gay! \n".format(name))


@command
async def register_nerd(message, *args):
    global nerds
    nerds += message.mentions


@client.event
async def on_ready():
    print("Logged in")
    print(client.user.id)


@client.event
async def on_message(message):
    if message.author.id == client.user.id:
        return
    message_content = message.content

    if message_content.startswith("!"):
        command_name, *args = message_content.split()
        command_name = command_name.strip("!")
        try:
            await commands[command_name](message, *args)

        except KeyError:
            await client.send_message(message.channel,
                                      "Command {} not found. Check your spelling and try again".format(command_name))

    if message.author in nerds:
        await client.send_message(message.channel, "{} is a fucking nerd!".format(message.author.mention))