Reputation: 25
Okay, so I got code like this:
groups = ['Z208', 'D204']
def show_next_lesson(self, group):
workbook = load_workbook(filename=f'/home/xyz/Desktop/{group}.xls')
sheet = workbook.active
print(sheet)
class Wwsi(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def nl(self, ctx):
for role in ctx.author.roles:
x = str(role)
if x in groups:
sheet = x
show_next_lesson(sheet)
It returns error Missing positional argument "group" at function call
So basically sheet
variable is empty? However, if I do print(sheet)
it actually returns number of group. I don't really understand how does it work, would appreciate any advice ;)
Upvotes: 1
Views: 43
Reputation: 54
If you would move the show_next_lesson()
into your Class, it would work:
class Wwsi(commands.Cog):
def __init__(self, bot):
self.bot = bot
def show_next_lesson(self, group):
workbook = load_workbook(filename=f'/home/xyz/Desktop/{group}.xls')
sheet = workbook.active
print(sheet)
@commands.command()
async def nl(self, ctx):
for role in ctx.author.roles:
x = str(role)
if x in groups:
sheet = x
self.show_next_lesson(sheet)
Upvotes: 1