mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 01:06:19 +00:00
[CHAT] Cleaned up code
This commit is contained in:
@@ -9,7 +9,8 @@ class MyModal(discord.ui.Modal):
|
|||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
super().__init__(title="Downvote")
|
super().__init__(title="Downvote")
|
||||||
self.add_item(
|
self.add_item(
|
||||||
discord.ui.InputText(label="Reason", style=discord.InputTextStyle.long)
|
discord.ui.InputText(
|
||||||
|
label="Reason", style=discord.InputTextStyle.long)
|
||||||
)
|
)
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
@@ -30,26 +31,35 @@ class MyModal(discord.ui.Modal):
|
|||||||
description=f"Downvote recieved!",
|
description=f"Downvote recieved!",
|
||||||
color=discord.Color.og_blurple(),
|
color=discord.Color.og_blurple(),
|
||||||
)
|
)
|
||||||
embed.add_field(name="Reason", value=self.children[0].value, inline=True)
|
|
||||||
embed.add_field(name="Author", value=interaction.user.mention, inline=True)
|
embed.add_field(
|
||||||
|
name="Reason", value=self.children[0].value, inline=True)
|
||||||
|
embed.add_field(
|
||||||
|
name="Author", value=interaction.user.mention, inline=True)
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="Channel", value=self.message.channel.name, inline=True
|
name="Channel", value=self.message.channel.name, inline=True
|
||||||
)
|
)
|
||||||
embed.add_field(name="Guild", value=self.message.guild.name, inline=True)
|
embed.add_field(
|
||||||
|
name="Guild", value=self.message.guild.name, inline=True)
|
||||||
|
|
||||||
history = await self.message.channel.history(
|
history = await self.message.channel.history(
|
||||||
limit=5, before=self.message
|
limit=5, before=self.message
|
||||||
).flatten()
|
).flatten()
|
||||||
history.reverse()
|
history.reverse()
|
||||||
|
|
||||||
users = []
|
users = []
|
||||||
fake_users = []
|
fake_users = []
|
||||||
|
|
||||||
for user in history:
|
for user in history:
|
||||||
if user.author not in users:
|
if user.author not in users:
|
||||||
# we anonimize the user, so user1, user2, user3, etc
|
# we anonimize the user, so user1, user2, user3, etc
|
||||||
fake_users.append(f"user{len(fake_users)+1}")
|
fake_users.append(f"user{len(fake_users)+1}")
|
||||||
users.append(user.author)
|
users.append(user.author)
|
||||||
|
|
||||||
if self.message.author not in users:
|
if self.message.author not in users:
|
||||||
fake_users.append(f"user{len(fake_users)+1}")
|
fake_users.append(f"user{len(fake_users)+1}")
|
||||||
users.append(self.message.author)
|
users.append(self.message.author)
|
||||||
|
|
||||||
for msg in history:
|
for msg in history:
|
||||||
uname = fake_users[users.index(msg.author)]
|
uname = fake_users[users.index(msg.author)]
|
||||||
|
|
||||||
@@ -61,20 +71,15 @@ class MyModal(discord.ui.Modal):
|
|||||||
embed.add_field(
|
embed.add_field(
|
||||||
name=f"{uname} said", value=msg.content, inline=False
|
name=f"{uname} said", value=msg.content, inline=False
|
||||||
)
|
)
|
||||||
if len(self.message.content) > 1021:
|
|
||||||
uname = fake_users[users.index(self.message.author)]
|
uname = fake_users[users.index(self.message.author)]
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name=f"{uname} said",
|
name=f"{uname} said",
|
||||||
value="*" + self.message.content[:1021] + "*",
|
value="*" + self.message.content[:1021] + "*" if len(
|
||||||
inline=False,
|
self.message.content) > 1021 else "*" + self.message.content + "*", # [:1021] if len(self.message.content) > 1021,
|
||||||
)
|
# means that if the message is longer than 1021 characters, it will be cut at 1021 characters
|
||||||
else:
|
inline=False,
|
||||||
uname = fake_users[users.index(self.message.author)]
|
)
|
||||||
embed.add_field(
|
|
||||||
name=f"{uname} said",
|
|
||||||
value="*" + self.message.content + "*",
|
|
||||||
inline=False,
|
|
||||||
)
|
|
||||||
await webhook.send(embed=embed)
|
await webhook.send(embed=embed)
|
||||||
else:
|
else:
|
||||||
debug(
|
debug(
|
||||||
|
|||||||
Reference in New Issue
Block a user