Skip to content

Commit

Permalink
Added webhook support to prepembed fixes cbrxyz#309
Browse files Browse the repository at this point in the history
  • Loading branch information
Nydauron committed Jan 11, 2021
1 parent 9c596e7 commit a94fc92
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
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
)
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

0 comments on commit a94fc92

Please sign in to comment.