Limit titles in JokeCog to 256, pushes anything past that into description, closes #35
This commit is contained in:
parent
ae1d32b485
commit
7ffbc3eba5
1 changed files with 17 additions and 2 deletions
|
@ -84,6 +84,21 @@ class JokeCog(commands.Cog):
|
||||||
else:
|
else:
|
||||||
body += " " + word
|
body += " " + word
|
||||||
|
|
||||||
|
desc = ""
|
||||||
|
title = result["title"]
|
||||||
|
if len(title) > 256:
|
||||||
|
new_title = ""
|
||||||
|
limit = False
|
||||||
|
for word in title.split(" "):
|
||||||
|
if len(new_title) + len(word) + 1 > 253 and not limit:
|
||||||
|
new_title += "..."
|
||||||
|
desc = "..."
|
||||||
|
limit = True
|
||||||
|
if not limit:
|
||||||
|
new_title += word + " "
|
||||||
|
else:
|
||||||
|
desc += word + " "
|
||||||
|
|
||||||
body_chunks.append(Field("", body, False))
|
body_chunks.append(Field("", body, False))
|
||||||
|
|
||||||
fields = body_chunks
|
fields = body_chunks
|
||||||
|
@ -94,8 +109,8 @@ class JokeCog(commands.Cog):
|
||||||
# ),
|
# ),
|
||||||
fields.append(Field("ID", result["id"]))
|
fields.append(Field("ID", result["id"]))
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title=result["title"],
|
title=title,
|
||||||
description="",
|
description=desc,
|
||||||
fields=fields,
|
fields=fields,
|
||||||
url=f"https://reddit.com/r/jokes/comments/{result['id']}",
|
url=f"https://reddit.com/r/jokes/comments/{result['id']}",
|
||||||
timestamp=datetime.fromtimestamp(result["created_utc"]),
|
timestamp=datetime.fromtimestamp(result["created_utc"]),
|
||||||
|
|
Loading…
Add table
Reference in a new issue