jeudi 1 mars 2018

Python: How to respond with message if option is true

So, I am fairly new to this (30 minutes of experience as of right now) and an trying to get my Discord bot to display a message when one option of a command is used. But it just isn't working.

    async def cmd_warn(self, message, user_mentions, option):
    """
    Usage:
        {command_prefix}warn [ spam | racism | discrimination | inappropriate | inpersonating | arguing | rudeness | harassment ] @UserName [@UserName2 ...]

    Warn users for spam / racism / discrimination / inappropriate / inpersonating / arguing / rudeness / harassment
    """

    if not user_mentions:
        raise exceptions.CommandError("**Error:** No users listed.", expire_in=20)

    if option not in ['spam', 'racism', 'discrimination', 'inappropriate', 'inpersonating', 'arguing', 'rudeness', 'harassment']:
        raise exceptions.CommandError(
            '**Invalid reason:** Use !help warn for more info!' % option, expire_in=20
        )

    for user in user_mentions.copy():
        if user.id == self.config.owner_id:
            print("[Commands:Warn] The owner cannot be warned (Tyler rigged).")
            user_mentions.remove(user)

    old_len = len(self.blacklist)

    if option in ['spam']:
        return Response('( %s ) You were warned for spam!')
        )

Aucun commentaire:

Enregistrer un commentaire