Skip to content

Commit

Permalink
Reordering decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
probicheaux committed Feb 21, 2021
1 parent 4e1f160 commit a5c08f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions queue_bot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ def start(self, msg, author):
new_queue = Queue(queue_name, self.redis_connector)

if new_queue in self.queue_list.keys():
queue = self.queue_list[new_queue]
index = self.queue_list.index(queue)+1
show_str = queue.showq(index)
index = self.queue_list.index(new_queue)
queue = self.queue_list[index]
show_str = queue.showq(index+1)
user_str = "Queue **{}** already started!\n".format(queue) + show_str
raise SmusError("Attempted to add queue that already exists", user_str)

Expand Down Expand Up @@ -185,4 +185,4 @@ def nuke(self):

response = '**DELETED ALL QUEUES**\n'
response += '*are you happy with the untold devastation you have wrought?*'
return response
return response
18 changes: 9 additions & 9 deletions queue_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def trying(func):
@functools.wraps(func)
async def wrapper_function(ctx):
try:
response = func(ctx)
response = await func(ctx)
except SmusError as E:
response = E.user_message

Expand All @@ -30,53 +30,53 @@ async def wrapper_function(ctx):
async def on_ready():
print(f'{client.user} has connected to Discord!')

@trying
@client.command()
@trying
async def join(ctx):
msg = ctx.message.content
author = ctx.message.author
response = api.join(msg, author)
return response

@trying
@client.command()
@trying
async def start(ctx):
msg = ctx.message.content
author = ctx.message.author
response = api.start(msg, author)
return response

@trying
@client.command()
@trying
async def leave(ctx):
msg = ctx.message.content
author = ctx.message.author
response = api.leave(msg, author)
return response

@trying
@client.command()
@trying
async def clear(ctx):
msg = ctx.message.content
response = api.clear(msg)
return response

@trying
@client.command()
@trying
async def pop(ctx):
msg = ctx.message.content
response = api.pop(msg)
return response

@trying
@client.command()
@trying
async def kick(ctx):
msg = ctx.message.content
response = api.kick(msg)
return response

@trying
@client.command()
@trying
async def show(ctx):
response = api.show_all()
return response
Expand All @@ -89,8 +89,8 @@ async def meme(ctx):
async def remove(ctx):
clear(ctx)

@trying
@client.command()
@trying
async def nuke(ctx):
response = api.nuke()
return response
Expand Down
4 changes: 2 additions & 2 deletions queue_bot/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ def show_queue_names(self):

def show_all(self):
show_str = ''
for ind in range(len(self)):
for ind in range(len(self.games())):
q = self[ind]
show_str += q.showq(ind+1) +'\n'

if len(self) == 0:
if len(self.games()) == 0:
show_str = 'NO QUEUES FOOL\n'

return show_str

0 comments on commit a5c08f7

Please sign in to comment.