Corrected how to add member/server usage on command completion
This commit is contained in:
parent
ff2234640f
commit
900e8026ee
1 changed files with 7 additions and 3 deletions
8
bot.py
8
bot.py
|
@ -91,11 +91,13 @@ async def on_message(message):
|
||||||
return
|
return
|
||||||
await bot.process_commands(message)
|
await bot.process_commands(message)
|
||||||
|
|
||||||
|
|
||||||
@bot.event
|
@bot.event
|
||||||
async def on_command_completion(command, ctx):
|
async def on_command_completion(command, ctx):
|
||||||
# There's no reason to continue waiting for this to complete, so lets immediately lanch this in a new future
|
# There's no reason to continue waiting for this to complete, so lets immediately lanch this in a new future
|
||||||
bot.loop.create_task(process_command(command, ctx))
|
bot.loop.create_task(process_command(command, ctx))
|
||||||
|
|
||||||
|
|
||||||
async def process_command(command, ctx):
|
async def process_command(command, ctx):
|
||||||
# This try catch is only here while this is first being implemented
|
# This try catch is only here while this is first being implemented
|
||||||
# It will be removed once I ensure this is working correctly
|
# It will be removed once I ensure this is working correctly
|
||||||
|
@ -112,12 +114,14 @@ async def process_command(command, ctx):
|
||||||
# Add one to the author's usage for this command
|
# Add one to the author's usage for this command
|
||||||
total_member_usage = command_usage.get('member_usage', {})
|
total_member_usage = command_usage.get('member_usage', {})
|
||||||
member_usage = total_member_usage.get(author.id, 0) + 1
|
member_usage = total_member_usage.get(author.id, 0) + 1
|
||||||
command_usage['member_usage'] = member_usage
|
total_member_usage[author.id] = member_usage
|
||||||
|
command_usage['member_usage'] = total_member_usage
|
||||||
|
|
||||||
# Add one to the server's usage for this command
|
# Add one to the server's usage for this command
|
||||||
total_server_usage = command_usage.get('server_usage', {})
|
total_server_usage = command_usage.get('server_usage', {})
|
||||||
server_usage = total_server_usage.get(server.id, 0) + 1
|
server_usage = total_server_usage.get(server.id, 0) + 1
|
||||||
command_usage['server_usage'] = server_usage
|
total_server_usage[server.id] = server_usage
|
||||||
|
command_usage['server_usage'] = total_server_usage
|
||||||
|
|
||||||
# Save all the changes
|
# Save all the changes
|
||||||
total_command_usage[command.qualified_name] = command_usage
|
total_command_usage[command.qualified_name] = command_usage
|
||||||
|
|
Loading…
Reference in a new issue