-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ScamReportModal.py
48 lines (42 loc) · 2.7 KB
/
ScamReportModal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from discord import ui, TextStyle, Interaction, Member, User
from Logger import Logger, LogLevel
class SubmitScamReport(ui.Modal):
ReportedUser:Member|User = None
TypeOfScam = ui.TextInput(label="Type of Scam", required=True, placeholder="Please state the type of scam", max_length=50, min_length=10)
Reasoning = ui.TextInput(label="Scam Ban Reasoning",
placeholder="The reason that this user should be reported",
max_length=300, required=False)
ScamEvidence = ui.TextInput(label="Evidence of Scam",
placeholder="Please insert links to images (space separated up to 9)",
style=TextStyle.paragraph,
max_length=4000,
required=True)
def __init__(self, InReportUser:Member|User):
self.ReportedUser = InReportUser
TruncatedName:str = InReportUser.name[:19]
ModalTitle:str=f"Report {TruncatedName}[{InReportUser.id}]"[:45]
super().__init__(title=ModalTitle)
async def on_submit(self, interaction: Interaction):
# Check to see if already banned.
if (interaction.client.Database.DoesBanExist(self.ReportedUser.id)):
await interaction.response.send_message(f"The reported user has been already banned.", ephemeral=True, delete_after=20.0)
return
# Split the evidence block into a string list
EvidenceList:list[str] = self.ScamEvidence.value.split()
ScamReportPayload = {
"ReportingUserName": interaction.user.name,
"ReportingUserId": interaction.user.id,
"ReportedServer": interaction.guild.name,
"ReportedServerId": interaction.guild_id,
"ReportedUserGlobalName": self.ReportedUser.display_name,
"ReportedUserName": self.ReportedUser.name,
"ReportedUserId": self.ReportedUser.id,
"TypeOfScam": self.TypeOfScam.value,
"Reasoning": self.Reasoning.value,
"Evidence": EvidenceList
}
interaction.client.AddAsyncTask(interaction.client.PostScamReport(ScamReportPayload))
await interaction.response.send_message(f"Sent report about user {self.ReportedUser.id} successfully!")
async def on_error(self, interaction: Interaction, exceptionError: Exception):
Logger.Log(LogLevel.Error, f"Encountered Exception with the scam report modal: {str(exceptionError)}")
await interaction.response.send_message(f"Unable to send report about user {self.ReportedUser.id}", ephemeral=True, delete_after=20.0)