Better method to get results
This commit is contained in:
parent
ad7c2d9cf6
commit
ca32b1f0e2
@ -168,7 +168,7 @@ class CCRole(commands.Cog):
|
|||||||
task.cancel()
|
task.cancel()
|
||||||
|
|
||||||
if len(done) == 0:
|
if len(done) == 0:
|
||||||
return None, "Timed out, canceling"
|
return {'success': False, 'message': "Timed out, canceling"}
|
||||||
|
|
||||||
payload_or_message = done.pop().result()
|
payload_or_message = done.pop().result()
|
||||||
|
|
||||||
@ -184,10 +184,10 @@ class CCRole(commands.Cog):
|
|||||||
):
|
):
|
||||||
role_list = await get_roles_from_content(ctx, payload_or_message.content)
|
role_list = await get_roles_from_content(ctx, payload_or_message.content)
|
||||||
if role_list is None:
|
if role_list is None:
|
||||||
return None, "Invalid answer, canceling"
|
return {'success': False, 'message': "Invalid answer, canceling"}
|
||||||
|
|
||||||
# Either it was a reaction or None
|
# Either it was a reaction or None
|
||||||
return role_list, None
|
return {'success': True, 'roles': role_list, 'message': "Success"}
|
||||||
|
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@commands.group()
|
@commands.group()
|
||||||
@ -232,40 +232,43 @@ class CCRole(commands.Cog):
|
|||||||
return m.author == ctx.author and m.channel == ctx.channel
|
return m.author == ctx.author and m.channel == ctx.channel
|
||||||
|
|
||||||
# Roles to add
|
# Roles to add
|
||||||
arole_list, error_message = await self._query_for_roles(
|
results = await self._query_for_roles(
|
||||||
ctx,
|
ctx,
|
||||||
"What roles should it add? (Must be **comma separated**)\n"
|
"What roles should it add? (Must be **comma separated**)\n"
|
||||||
"Say `None` or react with tick to skip adding roles",
|
"Say `None` or react with tick to skip adding roles",
|
||||||
120,
|
120,
|
||||||
check,
|
check,
|
||||||
)
|
)
|
||||||
if arole_list is None:
|
if not results['success']:
|
||||||
await ctx.send(error_message)
|
await ctx.send(results['message'])
|
||||||
return
|
return
|
||||||
|
arole_list = results['roles']
|
||||||
|
|
||||||
# Roles to remove
|
# Roles to remove
|
||||||
rrole_list, error_message = await self._query_for_roles(
|
results = await self._query_for_roles(
|
||||||
ctx,
|
ctx,
|
||||||
"What roles should it remove? (Must be comma separated)\n"
|
"What roles should it remove? (Must be comma separated)\n"
|
||||||
"Say `None` or react with tick to skip removing roles",
|
"Say `None` or react with tick to skip removing roles",
|
||||||
120,
|
120,
|
||||||
check,
|
check,
|
||||||
)
|
)
|
||||||
if rrole_list is None:
|
if not results['success']:
|
||||||
await ctx.send(error_message)
|
await ctx.send(results['message'])
|
||||||
return
|
return
|
||||||
|
rrole_list = results['roles']
|
||||||
|
|
||||||
# Roles to allow use
|
# Roles to allow use
|
||||||
prole_list, error_message = await self._query_for_roles(
|
results = await self._query_for_roles(
|
||||||
ctx,
|
ctx,
|
||||||
"What roles are allowed to use this command? (Must be comma separated)\n"
|
"What roles are allowed to use this command? (Must be comma separated)\n"
|
||||||
"Say `None` or react with tick to allow all roles",
|
"Say `None` or react with tick to allow all roles",
|
||||||
120,
|
120,
|
||||||
check,
|
check,
|
||||||
)
|
)
|
||||||
if prole_list is None:
|
if not results['success']:
|
||||||
await ctx.send(error_message)
|
await ctx.send(results['message'])
|
||||||
return
|
return
|
||||||
|
prole_list = results['roles']
|
||||||
|
|
||||||
# Selfrole
|
# Selfrole
|
||||||
await ctx.send(
|
await ctx.send(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user