#[any class] object has no attribute [any ctx function]

1 messages · Page 1 of 1 (latest)

hazy rapids
#

So for context, I have file tree that looks more or less like this: Bot/ ├─ modules/ │ └─ git.py ├─ bot.py └─ decorators.py
bot loads git.py as Extension, and everywhere where I need the decorator I just use from decorators import SomeDecorator
And to the point - if I'll make something like (at some point probably I'll delete both functions/files as they don't have much sense but for now im just exploring how it works) ```py

decorators.py

def administration_only(func):
@functools.wraps(func)
async def wrapper(ctx: SlashContext, *args, **kwargs):
if role_id_administration in [role.id for role in ctx.author.roles]:
await func(ctx, *args, **kwargs)
else:
await ctx.send("You don't have access to that command")
return wrapper

and
```py
# git.py
class Git(Extension):
    @slash_command(description="Local git management commands")
    async def git(self, ctx: SlashContext):
        pass

    @subcommand("git", description="switch active branch")
    @slash_option(name="repo", description="", opt_type=OptionType.STRING, required=True, choices = [SlashCommandChoice(name=branch, value=branch) for branch in list_branches()])
    async def checkout(self, ctx: SlashContext, branch: str):
        branch_set = subprocess.check_output(["git", "checkout", branch]).decode()
        branch_current = subprocess.check_output(["git", "branch", "--show-current"]).decode()
        await ctx.send(f"{branch_set}\nCurrent branch: {branch_current}")```
I'm getting ``AttributeError: 'Git' object has no attribute 'author'``
tldr; *how do I pass the Context..?*  I bet I'm either missing something simple or doing something horrible, but anyway. I'm just playing with the lib for fun, at least for now.
jovial ingotBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

fallow yarrow