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

Issue #309: !prepembed webhook support #329

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 36 additions & 16 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1550,22 +1550,42 @@ async def prepembed(ctx, channel:discord.TextChannel, *, jsonInput):
footerText = jso['footerText'] if 'footerText' in jso else ""
footerUrl = jso['footerUrl'] if 'footerUrl' in jso else ""
imageUrl = jso['imageUrl'] if 'imageUrl' in jso else ""
embed = assembleEmbed(
title=title,
desc=desc,
titleUrl=titleUrl,
hexcolor=hexcolor,
webcolor=webcolor,
thumbnailUrl=thumbnailUrl,
authorName=authorName,
authorUrl=authorUrl,
authorIcon=authorIcon,
fields=fields,
footerText=footerText,
footerUrl=footerUrl,
imageUrl=imageUrl
)
await channel.send(embed=embed)

asWebhook = jso['asWebhook'] if 'asWebhook' in jso else False

if asWebhook:
embed = assembleEmbed(
title=title,
desc=desc,
titleUrl=titleUrl,
hexcolor=hexcolor,
webcolor=webcolor,
thumbnailUrl=thumbnailUrl,
fields=fields,
footerText=footerText,
footerUrl=footerUrl,
imageUrl=imageUrl
)
Comment on lines +1557 to +1568
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the authorName, authorUrl, and authorIcon parameters removed from this function call? Those parameters should still be able to be set because they belong to the embed itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems kinda redundant to display the username and pfp on the embed and then again on the webhook. The only other use case is if we want the webhook to display something different to the author of the embed. This probably can be implemented easily ...

wh = await channel.create_webhook(name=authorName, avatar= await authorIcon.read())
await wh.send(embed=embed)
await wh.delete()
else:
embed = assembleEmbed(
title=title,
desc=desc,
titleUrl=titleUrl,
hexcolor=hexcolor,
webcolor=webcolor,
thumbnailUrl=thumbnailUrl,
authorName=authorName,
authorUrl=authorUrl,
authorIcon=authorIcon,
fields=fields,
footerText=footerText,
footerUrl=footerUrl,
imageUrl=imageUrl
)
await channel.send(embed=embed)

@bot.command(aliases=["event"])
async def events(ctx, *args):
Expand Down
4 changes: 4 additions & 0 deletions commandinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@
"name": "footerText / footerUrl (in json)",
"description": "the footer text or url of the embed"
},
{
"name": "asWebhook (in json)",
"description": "Displays embed as a webhook"
}
],
"usage":[
{
Expand Down