mirror of
https://github.com/Paillat-dev/Botator.git
synced 2026-01-02 09:16: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):
|
||||
super().__init__(title="Downvote")
|
||||
self.add_item(
|
||||
discord.ui.InputText(label="Reason", style=discord.InputTextStyle.long)
|
||||
discord.ui.InputText(
|
||||
label="Reason", style=discord.InputTextStyle.long)
|
||||
)
|
||||
self.message = message
|
||||
|
||||
@@ -30,26 +31,35 @@ class MyModal(discord.ui.Modal):
|
||||
description=f"Downvote recieved!",
|
||||
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(
|
||||
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(
|
||||
limit=5, before=self.message
|
||||
).flatten()
|
||||
history.reverse()
|
||||
|
||||
users = []
|
||||
fake_users = []
|
||||
|
||||
for user in history:
|
||||
if user.author not in users:
|
||||
# we anonimize the user, so user1, user2, user3, etc
|
||||
fake_users.append(f"user{len(fake_users)+1}")
|
||||
users.append(user.author)
|
||||
|
||||
if self.message.author not in users:
|
||||
fake_users.append(f"user{len(fake_users)+1}")
|
||||
users.append(self.message.author)
|
||||
|
||||
for msg in history:
|
||||
uname = fake_users[users.index(msg.author)]
|
||||
|
||||
@@ -61,18 +71,13 @@ class MyModal(discord.ui.Modal):
|
||||
embed.add_field(
|
||||
name=f"{uname} said", value=msg.content, inline=False
|
||||
)
|
||||
if len(self.message.content) > 1021:
|
||||
|
||||
uname = fake_users[users.index(self.message.author)]
|
||||
embed.add_field(
|
||||
name=f"{uname} said",
|
||||
value="*" + self.message.content[:1021] + "*",
|
||||
inline=False,
|
||||
)
|
||||
else:
|
||||
uname = fake_users[users.index(self.message.author)]
|
||||
embed.add_field(
|
||||
name=f"{uname} said",
|
||||
value="*" + self.message.content + "*",
|
||||
value="*" + self.message.content[:1021] + "*" if len(
|
||||
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
|
||||
inline=False,
|
||||
)
|
||||
await webhook.send(embed=embed)
|
||||
|
||||
Reference in New Issue
Block a user