commit
3da7203c43
@ -258,75 +258,78 @@ class PollControls:
|
|||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
async def cmd(self, ctx, *, cmd=None):
|
async def cmd(self, ctx, *, cmd=None):
|
||||||
'''The old, command style way paired with the wizard.'''
|
'''The old, command style way paired with the wizard.'''
|
||||||
server = await ask_for_server(self.bot, ctx.message)
|
await self.say_embed(ctx, say_text='This command is temporarily disabled.')
|
||||||
if not server:
|
# server = await ask_for_server(self.bot, ctx.message)
|
||||||
return
|
# if not server:
|
||||||
pre = await get_server_pre(self.bot, server)
|
# return
|
||||||
|
# pre = await get_server_pre(self.bot, server)
|
||||||
# generate the argparser and handle invalid stuff
|
#
|
||||||
descr = 'Accept poll settings via commandstring. \n\n' \
|
# # generate the argparser and handle invalid stuff
|
||||||
'**Wrap all arguments in quotes like this:** \n' \
|
# descr = 'Accept poll settings via commandstring. \n\n' \
|
||||||
f'{pre}cmd -question \"What tea do you like?\" -o \"green, black, chai\"\n\n' \
|
# '**Wrap all arguments in quotes like this:** \n' \
|
||||||
'The Order of arguments doesn\'t matter. If an argument is missing, it will use the default value. ' \
|
# f'{pre}cmd -question \"What tea do you like?\" -o \"green, black, chai\"\n\n' \
|
||||||
'If an argument is invalid, the wizard will step in. ' \
|
# 'The Order of arguments doesn\'t matter. If an argument is missing, it will use the default value. ' \
|
||||||
'If the command string is invalid, you will get this error :)'
|
# 'If an argument is invalid, the wizard will step in. ' \
|
||||||
parser = argparse.ArgumentParser(description=descr, formatter_class=CustomFormatter, add_help=False)
|
# 'If the command string is invalid, you will get this error :)'
|
||||||
parser.add_argument('-question', '-q')
|
# parser = argparse.ArgumentParser(description=descr, formatter_class=CustomFormatter, add_help=False)
|
||||||
parser.add_argument('-label', '-l', default=str(await generate_word(self.bot, server.id)))
|
# parser.add_argument('-question', '-q')
|
||||||
parser.add_argument('-options', '-o')
|
# parser.add_argument('-label', '-l', default=str(await generate_word(self.bot, server.id)))
|
||||||
parser.add_argument('-multiple_choice', '-mc', default='1')
|
# parser.add_argument('-options', '-o')
|
||||||
parser.add_argument('-roles', '-r', default='all')
|
# parser.add_argument('-multiple_choice', '-mc', default='1')
|
||||||
parser.add_argument('-weights', '-w', default='none')
|
# parser.add_argument('-roles', '-r', default='all')
|
||||||
parser.add_argument('-deadline', '-d', default='0')
|
# parser.add_argument('-weights', '-w', default='none')
|
||||||
parser.add_argument('-anonymous', '-a', action="store_true")
|
# parser.add_argument('-deadline', '-d', default='0')
|
||||||
|
# parser.add_argument('-anonymous', '-a', action="store_true")
|
||||||
helpstring = parser.format_help()
|
#
|
||||||
helpstring = helpstring.replace("pollmaster.py", f"{pre}cmd ")
|
# helpstring = parser.format_help()
|
||||||
|
# helpstring = helpstring.replace("pollmaster.py", f"{pre}cmd ")
|
||||||
if cmd and cmd == 'help':
|
#
|
||||||
await self.say_embed(ctx, say_text=helpstring)
|
# if cmd and cmd == 'help':
|
||||||
return
|
# await self.say_embed(ctx, say_text=helpstring)
|
||||||
|
# return
|
||||||
try:
|
#
|
||||||
cmds = shlex.split(cmd)
|
# try:
|
||||||
except ValueError:
|
# cmds = shlex.split(cmd)
|
||||||
await self.say_error(ctx, error_text=helpstring)
|
# except ValueError:
|
||||||
return
|
# await self.say_error(ctx, error_text=helpstring)
|
||||||
|
# return
|
||||||
try:
|
# except:
|
||||||
args, unknown_args = parser.parse_known_args(cmds)
|
# return
|
||||||
except SystemExit:
|
#
|
||||||
await self.say_error(ctx, error_text=helpstring)
|
# try:
|
||||||
return
|
# args, unknown_args = parser.parse_known_args(cmds)
|
||||||
except:
|
# except SystemExit:
|
||||||
return
|
# await self.say_error(ctx, error_text=helpstring)
|
||||||
|
# return
|
||||||
if unknown_args:
|
# except:
|
||||||
error_text = f'**There was an error reading the command line options!**.\n' \
|
# return
|
||||||
f'Most likely this is because you didn\'t surround the arguments with double quotes like this: ' \
|
#
|
||||||
f'`{pre}cmd -q "question of the poll" -o "yes, no, maybe"`' \
|
# if unknown_args:
|
||||||
f'\n\nHere are the arguments I could not understand:\n'
|
# error_text = f'**There was an error reading the command line options!**.\n' \
|
||||||
error_text += '`'+'\n'.join(unknown_args)+'`'
|
# f'Most likely this is because you didn\'t surround the arguments with double quotes like this: ' \
|
||||||
error_text += f'\n\nHere are the arguments which are ok:\n'
|
# f'`{pre}cmd -q "question of the poll" -o "yes, no, maybe"`' \
|
||||||
error_text += '`' + '\n'.join([f'{k}: {v}' for k, v in vars(args).items()]) + '`'
|
# f'\n\nHere are the arguments I could not understand:\n'
|
||||||
|
# error_text += '`'+'\n'.join(unknown_args)+'`'
|
||||||
await self.say_error(ctx, error_text=error_text, footer_text=f'type `{pre}cmd help` for details.')
|
# error_text += f'\n\nHere are the arguments which are ok:\n'
|
||||||
return
|
# error_text += '`' + '\n'.join([f'{k}: {v}' for k, v in vars(args).items()]) + '`'
|
||||||
|
#
|
||||||
# pass arguments to the wizard
|
# await self.say_error(ctx, error_text=error_text, footer_text=f'type `{pre}cmd help` for details.')
|
||||||
async def route(poll):
|
# return
|
||||||
await poll.set_name(force=args.question)
|
#
|
||||||
await poll.set_short(force=args.label)
|
# # pass arguments to the wizard
|
||||||
await poll.set_anonymous(force=f'{"yes" if args.anonymous else "no"}')
|
# async def route(poll):
|
||||||
await poll.set_options_reaction(force=args.options)
|
# await poll.set_name(force=args.question)
|
||||||
await poll.set_multiple_choice(force=args.multiple_choice)
|
# await poll.set_short(force=args.label)
|
||||||
await poll.set_roles(force=args.roles)
|
# await poll.set_anonymous(force=f'{"yes" if args.anonymous else "no"}')
|
||||||
await poll.set_weights(force=args.weights)
|
# await poll.set_options_reaction(force=args.options)
|
||||||
await poll.set_duration(force=args.deadline)
|
# await poll.set_multiple_choice(force=args.multiple_choice)
|
||||||
|
# await poll.set_roles(force=args.roles)
|
||||||
poll = await self.wizard(ctx, route, server)
|
# await poll.set_weights(force=args.weights)
|
||||||
if poll:
|
# await poll.set_duration(force=args.deadline)
|
||||||
await poll.post_embed(destination=poll.channel)
|
#
|
||||||
|
# poll = await self.wizard(ctx, route, server)
|
||||||
|
# if poll:
|
||||||
|
# await poll.post_embed(destination=poll.channel)
|
||||||
|
|
||||||
|
|
||||||
@commands.command(pass_context=True)
|
@commands.command(pass_context=True)
|
||||||
|
|||||||
@ -104,14 +104,15 @@ async def on_command_error(e, ctx):
|
|||||||
logger.error(f'{type(e).__name__}: {e}\n{"".join(traceback.format_tb(e.__traceback__))}')
|
logger.error(f'{type(e).__name__}: {e}\n{"".join(traceback.format_tb(e.__traceback__))}')
|
||||||
if SETTINGS.mode == 'development':
|
if SETTINGS.mode == 'development':
|
||||||
raise e
|
raise e
|
||||||
|
traceback.print_exception(type(e), e, e.__traceback__, file=sys.stderr)
|
||||||
|
|
||||||
if SETTINGS.msg_errors:
|
if SETTINGS.msg_errors:
|
||||||
# send discord message for unexpected errors
|
# send discord message for unexpected errors
|
||||||
e = discord.Embed(
|
e = discord.Embed(
|
||||||
title=f"Error With command: {ctx.command.name}",
|
title=f"Error With command: {ctx.command.name}",
|
||||||
description=f"```py\n{type(e).__name__}: {e}\n```\n\nContent:{ctx.message.content}"
|
description=f"```py\n{type(e).__name__}: {str(e)}\n```\n\nContent:{ctx.message.content}"
|
||||||
f"\n\tServer: {ctx.message.server}\n\tChannel: <#{ctx.message.channel.id}>"
|
f"\n\tServer: {ctx.message.server}\n\tChannel: <#{ctx.message.channel}>"
|
||||||
f"\n\tAuthor: <@{ctx.message.author.id}>",
|
f"\n\tAuthor: <@{ctx.message.author}>",
|
||||||
timestamp=ctx.message.timestamp
|
timestamp=ctx.message.timestamp
|
||||||
)
|
)
|
||||||
await bot.send_message(bot.owner, embed=e)
|
await bot.send_message(bot.owner, embed=e)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user