0

Trying to go through the list and display the callables assigned in cmds

This is in __init__.py:

class Cmd(object):
    def __init__(self, callables, func, cooldown=0):
        self.func = func
        self.cooldown = cooldown
        self.next_use = time()
        self.callables = callables

cmds = [
    Cmd(["hello", "hi", "hey"], misc.hello, cooldown=30),
    Cmd(["roll"], misc.roll, cooldown=15),
    Cmd(["potato", "potatoes", "p"], economy.potato, cooldown=15),
    Cmd(["heist"], bet.start_heist, cooldown=15),
    Cmd(["about", "credits"], misc.about, cooldown=15),
    Cmd(["uptime"], misc.uptime, cooldown=15),
    """Cmd(["loyalty"], misc.loyalty, cooldown=15),"""
]

This is in misc.py

def help(bot, prefix, cmds):
    bot.send_message(f"Registered commands (incl. aliases): "
                     + ", ".join([f"{prefix}{'/'.join(cmd.callables[0])}" for cmd in cmds]))

The issue is on the line

bot.send_message(f"Registered commands (incl. aliases): "
                     + ", ".join([f"{prefix}{'/'.join(cmd.callables[0])}"
Brian61354270
  • 8,690
  • 4
  • 21
  • 43
Bodhiston
  • 3
  • 2
  • It looks like you attempted to comment out the last entry in `cmds` by putting it in a string. Since this string doesn't have a `callables` attribute, an `AttributeError` is being raised. Commenting out the line `"""Cmd(["loyalty"], . . . """` will likely fix your problem. – Brian61354270 Jun 23 '20 at 01:20
  • Yes! That helped it! It doesn't seem to go through the aliases though. – Bodhiston Jun 23 '20 at 01:23

1 Answers1

0

As noted in the comments, it looks like you attempted to comment-out one of the entries in cmds by placing it in a string. Since this string does not have a callables attribute, an AttributeError is raised when cmds is presumably processed by your help function.

Either deleting or commenting out (using a # sign) the last entry of cmds should fix your problem. E.g.,

cmds = [
    Cmd(["hello", "hi", "hey"], misc.hello, cooldown=30),
    ...
    Cmd(["uptime"], misc.uptime, cooldown=15),
    # """Cmd(["loyalty"], misc.loyalty, cooldown=15),"""
]
Brian61354270
  • 8,690
  • 4
  • 21
  • 43
  • Yes, thank you. This did help my issue. I now have an issue with the aliases, but that can be for another day. Thanks a ton! – Bodhiston Jun 23 '20 at 01:33