fix: Protect all acmpl lengths.

This commit is contained in:
2023-10-08 12:00:32 +03:00
parent 91a3f595b5
commit 1b4cfd0453
9 changed files with 39 additions and 39 deletions

View File

@@ -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]

View File

@@ -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]

View File

@@ -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)

View File

@@ -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):

View File

@@ -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
)
]