Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Added shortenlink function and used when necessary #64

Merged
merged 10 commits into from
Oct 10, 2023
36 changes: 26 additions & 10 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,25 @@ async def SaveSetting(guildid: int, module: str, value: str):
return


def ShortenLink(link: str):
"""

:param link: str:

"""
headers = {
"Authorization": f"Bearer {FEMTOLINK}",
"Content-Type": "application/json",
}

data = '{ "long_url": "' + uurl + '" }'

response = requests.post("https://femtolink.jaumelopez.dev/api/link",
headers=headers,
data=data)
return response.json()["link"]


def GenerateChart(datasets):
"""

Expand Down Expand Up @@ -527,7 +546,8 @@ def numToEmoji(num):

def filterMember(member: discord.Member):
"""


:param member: discord.Member:
:param member: discord.Member:

"""
Expand Down Expand Up @@ -991,7 +1011,8 @@ async def seewarns(ctx, member: discord.Member):
MEMBER=filterMember(member)),
description=message,
)
embed.set_image(url=uurl)
final_url = uurl if len(uurl) < 2048 else ShortenLink(uurl)
embed.set_image(url=final_url)
embed.set_footer(
text=await GetTranslatedText(ctx.guild.id,
"footer_executed_by",
Expand Down Expand Up @@ -1647,14 +1668,9 @@ async def metrics(ctx):
for cmd, times in commandDict.items()
]),
)
if len(uurl) < 2048:
embed.set_image(url=uurl)
else:
rest = uurl
i = 1020
while len(rest) > 0:
await ctx.respond(rest[:i])
rest = rest[i:]
final_url = uurl if len(uurl) < 2048 else ShortenLink(uurl)
embed.set_image(url=final_url)

embed.set_footer(
text=await GetTranslatedText(ctx.guild.id,
"footer_executed_by",
Expand Down