def make_embed(request, message="New Transaction"):
"""
create an embed for logging transactions
"""
fields = []
fields.append({"name": "ID", "value": request['_id']})
if request['type'] == "deposit":
fields.append({"name": "Amount", "value": f"+{request['amount']}"})
elif request['type'] == "withdrawl":
fields.append({"name": "Amount", "value": f"-{request['amount']}"})
fields.append({"name": "Reason", "value": request['reason']})
fields.append({"name": "Balance", "value": request['user']['balance']})
fields.append(
{"name": "User", "value": f"{request['user']['name']}#{request['user']['discrim']} ({request['user']['_id']})"})
fields.append(
{"name": "Bot", "value": f"{request['bot']['name']}#{request['bot']['discrim']} ({request['bot']['_id']})"})
embed = {"title": message, "fields": fields, "timestamp":datetime.now().isoformat()}
test = requests.post('https://canary.discordapp.com/api/webhooks/338371642277494786/vG8DJjpXC-NEXB4ZISo1r7QQ0Ras_RaqZbuhzjYOklKu70l73PmumdUCgBruypPv3fQp', json={"embeds": [embed]})
评论列表
文章目录