fix: Protect all acmpl lengths.
This commit is contained in:
@@ -241,7 +241,7 @@ class BabelCog(LionCog):
|
||||
matching = {item for item in formatted if partial in item[1] or partial in item[0]}
|
||||
if matching:
|
||||
choices = [
|
||||
appcmds.Choice(name=localestr, value=locale)
|
||||
appcmds.Choice(name=localestr[:100], value=locale)
|
||||
for locale, localestr in matching
|
||||
]
|
||||
else:
|
||||
@@ -250,7 +250,7 @@ class BabelCog(LionCog):
|
||||
name=t(_p(
|
||||
'acmpl:language|no_match',
|
||||
"No supported languages matching {partial}"
|
||||
)).format(partial=partial),
|
||||
)).format(partial=partial)[:100],
|
||||
value=partial
|
||||
)
|
||||
]
|
||||
|
||||
@@ -447,7 +447,7 @@ class Reminders(LionCog):
|
||||
))
|
||||
value = 'None'
|
||||
choices = [
|
||||
appcmds.Choice(name=name, value=value)
|
||||
appcmds.Choice(name=name[:100], value=value)
|
||||
]
|
||||
else:
|
||||
# Build list of reminder strings
|
||||
@@ -463,7 +463,7 @@ class Reminders(LionCog):
|
||||
# Build list of valid choices
|
||||
choices = [
|
||||
appcmds.Choice(
|
||||
name=string[0],
|
||||
name=string[0][:100],
|
||||
value=f"rid:{string[1].reminderid}"
|
||||
)
|
||||
for string in matches
|
||||
@@ -474,7 +474,7 @@ class Reminders(LionCog):
|
||||
name=t(_p(
|
||||
'cmd:reminders_cancel|acmpl:reminder|error:no_matches',
|
||||
"You do not have any reminders matching \"{partial}\""
|
||||
)).format(partial=partial),
|
||||
)).format(partial=partial)[:100],
|
||||
value=partial
|
||||
)
|
||||
]
|
||||
@@ -562,7 +562,7 @@ class Reminders(LionCog):
|
||||
name=t(_p(
|
||||
'cmd:remindme_at|acmpl:time|error:parse',
|
||||
"Cannot parse \"{partial}\" as a time. Try the format HH:MM or YYYY-MM-DD HH:MM"
|
||||
)).format(partial=partial),
|
||||
)).format(partial=partial)[:100],
|
||||
value=partial
|
||||
)
|
||||
return [choice]
|
||||
|
||||
@@ -534,7 +534,7 @@ class RoleMenuCog(LionCog):
|
||||
choice_name = menu.data.name
|
||||
choice_value = f"menuid:{menu.data.menuid}"
|
||||
choices.append(
|
||||
appcmds.Choice(name=choice_name, value=choice_value)
|
||||
appcmds.Choice(name=choice_name[:100], value=choice_value)
|
||||
)
|
||||
|
||||
if not choices:
|
||||
@@ -545,7 +545,7 @@ class RoleMenuCog(LionCog):
|
||||
)).format(partial=partial)
|
||||
choice_value = partial
|
||||
choice = appcmds.Choice(
|
||||
name=choice_name, value=choice_value
|
||||
name=choice_name[:100], value=choice_value
|
||||
)
|
||||
choices.append(choice)
|
||||
|
||||
@@ -569,7 +569,7 @@ class RoleMenuCog(LionCog):
|
||||
"Please select a menu first"
|
||||
))
|
||||
choice_value = partial
|
||||
choices = [appcmds.Choice(name=choice_name, value=choice_value)]
|
||||
choices = [appcmds.Choice(name=choice_name[:100], value=choice_value)]
|
||||
else:
|
||||
# Resolve the menu name
|
||||
menu: RoleMenu
|
||||
@@ -591,7 +591,7 @@ class RoleMenuCog(LionCog):
|
||||
name=t(_p(
|
||||
'acmpl:menuroles|choice:invalid_menu|name',
|
||||
"Menu '{name}' does not exist!"
|
||||
)).format(name=menu_name),
|
||||
)).format(name=menu_name)[:100],
|
||||
value=partial
|
||||
)
|
||||
choices = [choice]
|
||||
@@ -611,7 +611,7 @@ class RoleMenuCog(LionCog):
|
||||
else:
|
||||
name = mrole.data.label
|
||||
choice = appcmds.Choice(
|
||||
name=name,
|
||||
name=name[:100],
|
||||
value=f"<@&{mrole.data.roleid}>"
|
||||
)
|
||||
choices.append(choice)
|
||||
@@ -620,7 +620,7 @@ class RoleMenuCog(LionCog):
|
||||
name=t(_p(
|
||||
'acmpl:menuroles|choice:no_matching|name',
|
||||
"No roles in this menu matching '{partial}'"
|
||||
)).format(partial=partial),
|
||||
)).format(partial=partial)[:100],
|
||||
value=partial
|
||||
)
|
||||
return choices[:25]
|
||||
|
||||
@@ -904,10 +904,10 @@ class ScheduleCog(LionCog):
|
||||
|
||||
if not interaction.guild or not isinstance(interaction.user, discord.Member):
|
||||
choice = appcmds.Choice(
|
||||
name=_p(
|
||||
name=t(_p(
|
||||
'cmd:schedule|acmpl:book|error:not_in_guild',
|
||||
"You need to be in a server to book sessions!"
|
||||
),
|
||||
))[:100],
|
||||
value='None'
|
||||
)
|
||||
choices = [choice]
|
||||
@@ -917,10 +917,10 @@ class ScheduleCog(LionCog):
|
||||
blacklist_role = (await self.settings.BlacklistRole.get(interaction.guild.id)).value
|
||||
if blacklist_role and blacklist_role in member.roles:
|
||||
choice = appcmds.Choice(
|
||||
name=_p(
|
||||
name=t(_p(
|
||||
'cmd:schedule|acmpl:book|error:blacklisted',
|
||||
"Cannot Book -- Blacklisted"
|
||||
),
|
||||
))[:100],
|
||||
value='None'
|
||||
)
|
||||
choices = [choice]
|
||||
@@ -947,7 +947,7 @@ class ScheduleCog(LionCog):
|
||||
)
|
||||
choices.append(
|
||||
appcmds.Choice(
|
||||
name=tzstring, value='None',
|
||||
name=tzstring[:100], value='None',
|
||||
)
|
||||
)
|
||||
|
||||
@@ -968,7 +968,7 @@ class ScheduleCog(LionCog):
|
||||
if partial.lower() in name.lower():
|
||||
choices.append(
|
||||
appcmds.Choice(
|
||||
name=name,
|
||||
name=name[:100],
|
||||
value=str(slotid)
|
||||
)
|
||||
)
|
||||
@@ -978,7 +978,7 @@ class ScheduleCog(LionCog):
|
||||
name=t(_p(
|
||||
"cmd:schedule|acmpl:book|no_matching",
|
||||
"No bookable sessions matching '{partial}'"
|
||||
)).format(partial=partial[:25]),
|
||||
)).format(partial=partial[:25])[:100],
|
||||
value=partial
|
||||
)
|
||||
)
|
||||
@@ -998,10 +998,10 @@ class ScheduleCog(LionCog):
|
||||
can_cancel = list(slotid for slotid in schedule if slotid > minid)
|
||||
if not can_cancel:
|
||||
choice = appcmds.Choice(
|
||||
name=_p(
|
||||
name=t(_p(
|
||||
'cmd:schedule|acmpl:cancel|error:empty_schedule',
|
||||
"You do not have any upcoming sessions to cancel!"
|
||||
),
|
||||
))[:100],
|
||||
value='None'
|
||||
)
|
||||
choices.append(choice)
|
||||
@@ -1025,7 +1025,7 @@ class ScheduleCog(LionCog):
|
||||
if partial.lower() in name.lower():
|
||||
choices.append(
|
||||
appcmds.Choice(
|
||||
name=name,
|
||||
name=name[:100],
|
||||
value=str(slotid)
|
||||
)
|
||||
)
|
||||
@@ -1034,7 +1034,7 @@ class ScheduleCog(LionCog):
|
||||
name=t(_p(
|
||||
'cmd:schedule|acmpl:cancel|error:no_matching',
|
||||
"No cancellable sessions matching '{partial}'"
|
||||
)).format(partial=partial[:25]),
|
||||
)).format(partial=partial[:25])[:100],
|
||||
value='None'
|
||||
)
|
||||
choices.append(choice)
|
||||
|
||||
@@ -1095,7 +1095,7 @@ class ColourShopping(ShopCog):
|
||||
for i, item in enumerate(items, start=1)
|
||||
]
|
||||
options = [option for option in options if partial.lower() in option[1].lower()]
|
||||
return [appcmds.Choice(name=option[1], value=option[0]) for option in options]
|
||||
return [appcmds.Choice(name=option[1][:100], value=option[0]) for option in options]
|
||||
|
||||
|
||||
class ColourStore(Store):
|
||||
|
||||
@@ -291,7 +291,7 @@ class TasklistCog(LionCog):
|
||||
name=t(_p(
|
||||
'argtype:taskid|error:no_tasks',
|
||||
"Tasklist empty! No matching tasks."
|
||||
)),
|
||||
))[:100],
|
||||
value=partial
|
||||
)
|
||||
]
|
||||
@@ -319,7 +319,7 @@ class TasklistCog(LionCog):
|
||||
if matching:
|
||||
# If matches were found, assume user wants one of the matches
|
||||
options = [
|
||||
appcmds.Choice(name=task_string, value=label)
|
||||
appcmds.Choice(name=task_string[:100], value=label)
|
||||
for label, task_string in matching
|
||||
]
|
||||
elif multi and partial.lower().strip() in ('-', 'all'):
|
||||
@@ -328,7 +328,7 @@ class TasklistCog(LionCog):
|
||||
name=t(_p(
|
||||
'argtype:taskid|match:all',
|
||||
"All tasks"
|
||||
)),
|
||||
))[:100],
|
||||
value='-'
|
||||
)
|
||||
]
|
||||
@@ -353,7 +353,7 @@ class TasklistCog(LionCog):
|
||||
multi_name = f"{partial[:remaining-1]} {error}"
|
||||
|
||||
multi_option = appcmds.Choice(
|
||||
name=multi_name,
|
||||
name=multi_name[:100],
|
||||
value=partial
|
||||
)
|
||||
options = [multi_option]
|
||||
@@ -371,7 +371,7 @@ class TasklistCog(LionCog):
|
||||
if not matching:
|
||||
matching = [(label, task) for label, task in labels if last_split.lower() in task.lower()]
|
||||
options.extend(
|
||||
appcmds.Choice(name=task_string, value=label)
|
||||
appcmds.Choice(name=task_string[:100], value=label)
|
||||
for label, task_string in matching
|
||||
)
|
||||
else:
|
||||
@@ -380,7 +380,7 @@ class TasklistCog(LionCog):
|
||||
name=t(_p(
|
||||
'argtype:taskid|error:no_matching',
|
||||
"No tasks matching '{partial}'!",
|
||||
)).format(partial=partial[:100]),
|
||||
)).format(partial=partial[:100])[:100],
|
||||
value=partial
|
||||
)
|
||||
]
|
||||
|
||||
@@ -915,7 +915,7 @@ class TimezoneSetting(InteractiveSetting[ParentID, str, TZT]):
|
||||
name=t(_p(
|
||||
'set_type:timezone|acmpl|no_matching',
|
||||
"No timezones matching '{input}'!"
|
||||
)).format(input=partial),
|
||||
)).format(input=partial)[:100],
|
||||
value=partial
|
||||
)
|
||||
]
|
||||
@@ -930,7 +930,7 @@ class TimezoneSetting(InteractiveSetting[ParentID, str, TZT]):
|
||||
"{tz} (Currently {now})"
|
||||
)).format(tz=tz, now=nowstr)
|
||||
choice = appcmds.Choice(
|
||||
name=name,
|
||||
name=name[:100],
|
||||
value=tz
|
||||
)
|
||||
choices.append(choice)
|
||||
|
||||
@@ -69,12 +69,12 @@ class DurationTransformer(Transformer):
|
||||
name=t(_p(
|
||||
'util:Duration|acmpl|error',
|
||||
"Cannot extract duration from \"{partial}\""
|
||||
)).format(partial=partial),
|
||||
)).format(partial=partial)[:100],
|
||||
value=partial
|
||||
)
|
||||
else:
|
||||
choice = appcmds.Choice(
|
||||
name=strfdur(duration, short=False, show_days=True),
|
||||
name=strfdur(duration, short=False, show_days=True)[:100],
|
||||
value=partial
|
||||
)
|
||||
return [choice]
|
||||
|
||||
@@ -307,17 +307,17 @@ class Pager(BasePager):
|
||||
"Current: Page {page}/{total}"
|
||||
)).format(page=num+1, total=total)
|
||||
choices = [
|
||||
appcmds.Choice(name=string, value=str(num+1))
|
||||
appcmds.Choice(name=string[:100], value=str(num+1))
|
||||
for num, string in sorted(page_choices.items(), key=lambda t: t[0])
|
||||
]
|
||||
else:
|
||||
# Particularly support page names here
|
||||
choices = [
|
||||
appcmds.Choice(
|
||||
name='> ' * (i == num) + t(_p(
|
||||
name=('> ' * (i == num) + t(_p(
|
||||
'cmd:page|acmpl|pager:Pager|choice:general',
|
||||
"Page {page}"
|
||||
)).format(page=i+1),
|
||||
)).format(page=i+1))[:100],
|
||||
value=str(i+1)
|
||||
)
|
||||
for i in range(0, total)
|
||||
@@ -351,7 +351,7 @@ class Pager(BasePager):
|
||||
name=t(_p(
|
||||
'cmd:page|acmpl|pager:Page|choice:select',
|
||||
"Selected: Page {page}/{total}"
|
||||
)).format(page=page_num+1, total=total),
|
||||
)).format(page=page_num+1, total=total)[:100],
|
||||
value=str(page_num + 1)
|
||||
)
|
||||
return [choice, *choices]
|
||||
@@ -361,7 +361,7 @@ class Pager(BasePager):
|
||||
name=t(_p(
|
||||
'cmd:page|acmpl|pager:Page|error:parse',
|
||||
"No matching pages!"
|
||||
)).format(page=page_num, total=total),
|
||||
)).format(page=page_num, total=total)[:100],
|
||||
value=partial
|
||||
)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user