Switch to Discord Embeds

This commit is contained in:
augustin64 2022-02-17 12:12:29 +01:00
parent e75ffac089
commit 3bba63ba03

26
V4.py
View File

@ -8,7 +8,7 @@ import discord
import asyncio import asyncio
from sys import platform from sys import platform
from csv import reader from csv import reader
from discord import Webhook, RequestsWebhookAdapter # Importing discord.Webhook and discord.RequestsWebhookAdapter from discord import Webhook, RequestsWebhookAdapter, Embed, Colour # Importing discord.Webhook and discord.RequestsWebhookAdapter
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.firefox.options import Options from selenium.webdriver.firefox.options import Options
@ -141,13 +141,17 @@ def LogError(message,log = Log, Mobdriver = None):
gdriver.save_screenshot("screenshot.png") gdriver.save_screenshot("screenshot.png")
webhookFailure.send(content="------------------------------------\n" + _mail) embed = discord.Embed(
webhookFailure.send(ListTabs(Mdriver=Mobdriver)) title="An Error has occured",
webhookFailure.send(str(message)) description=str(message),
CustomSleep(1) url = ListTabs(Mdriver=Mobdriver)[0],
webhookFailure.send(file=discord.File('screenshot.png')) colour = Colour.red()
)
file = discord.File("screenshot.png")
embed.set_image(url="attachment://screenshot.png")
embed.set_footer(text=_mail)
webhookFailure.send(embed=embed, file=file)
webhookFailure.send(file=discord.File('page.html')) webhookFailure.send(file=discord.File('page.html'))
webhookFailure.send("------------------------------------")
def progressBar(current, total=30, barLength = 20, name ="Progress"): def progressBar(current, total=30, barLength = 20, name ="Progress"):
@ -656,8 +660,12 @@ def LogPoint(account="unknown"): #log des points sur discord
account = account.split('@')[0] account = account.split('@')[0]
embed = discord.Embed(
webhookSuccess.send(f'{account} actuellement à {str(point)} points') title=f"{account} actuellement à {str(point)} points",
colour = Colour.green()
)
embed.set_footer(text=_mail)
webhookSuccess.send(embed=embed)