Beispiel #1
0
                message.author)
    else:
        return '{} has inputted an invalid argument. Please input either Star or Wang.'.format(
            message.author)


def swear_command(message, client, args):
    # TODO: add this functionality
    return 'Swear command not implemented'


# adding commands that refer to the functions above
ch.add_command({
    'trigger': '!test',
    'function': test_command,
    'args_num': 0,
    'args_name': [''],
    'description': 'Prints number of messages.'
})

ch.add_command({
    'trigger':
    '!observe',
    'function':
    observe_command,
    'args_num':
    1,
    'args_name': ['Expected State'],
    'description':
    'Observes a qubit in equal quantum superposition.'
})
Beispiel #2
0
from commandhandler import CommandHandler, Command

load_dotenv()  # take environment variables from .env

# Setup client, command handler, and get auth token
client = discord.Client()
token = os.environ.get('TOKEN')
c_handler = CommandHandler(client)


def help_func():
    print('help_func')


help_command = Command('help', 0, 'Usage: ;sports help', help_func)
c_handler.add_command(help_command)


# Called when the bot first starts up
@client.event
async def on_ready():
    print(f'{client.user} has connected to Discord!')


# Called everytime there is a new message
@client.event
async def on_message(message):

    # If the message is from the bot then ignore this message
    if message.author == client.user:
        return