Skip to content

Commit

Permalink
delete properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Ast3risk-ops committed Jan 12, 2025
1 parent cd6264d commit b2f7fe7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
)

embed = None
numembeds = 0
numfiles = 0

webhookurl = str(os.getenv("WEBHOOK_URL"))
intents = discord.Intents.default()
Expand Down Expand Up @@ -76,6 +78,16 @@ async def button_callback(self, button, interaction):
await interaction.response.defer()
self.disable_all_items()
await interaction.message.delete()
global numembeds
global numfiles
if numembeds or numfiles != 0:
channel = interaction.channel
to_delete = int(numembeds + numfiles)
messages = await channel.history(
limit=to_delete, after=interaction.message.created_at
).flatten()
for i in messages:
await i.delete()

@discord.ui.button(
label="", custom_id="pin", style=discord.ButtonStyle.secondary, emoji="📌"
Expand Down Expand Up @@ -223,13 +235,15 @@ async def bookmark_tag(ctx, message: discord.Message):
name="<:mdichesscastle:1314056466516283413> Guild", value=f"DM", inline=True
)
if message.embeds:
global numembeds
numembeds = len(message.embeds) # Number of embeds
embed.add_field(
name="<:mdicardtext:1311825458480021596> Embeds",
value=f"{numembeds}",
inline=True,
)
if message.attachments:
global numfiles
numfiles = len(message.attachments)
embed.add_field(
name="<:mdifiledownload:1322695880637284514> Attachments",
Expand Down
15 changes: 15 additions & 0 deletions main_emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"https://caltrop.asterisk.lol" # Will save a lot of time if the domain changes
)

numembeds = 0
numfiles = 0

embed = None

webhookurl = str(os.getenv("WEBHOOK_URL"))
Expand Down Expand Up @@ -77,6 +80,16 @@ async def button_callback(self, button, interaction):
await interaction.response.defer()
self.disable_all_items()
await interaction.message.delete()
global numembeds
global numfiles
if numembeds or numfiles != 0:
channel = interaction.channel
to_delete = int(numembeds + numfiles)
messages = await channel.history(
limit=to_delete, after=interaction.message.created_at
).flatten()
for i in messages:
await i.delete()

@discord.ui.button(
label="", custom_id="pin", style=discord.ButtonStyle.secondary, emoji="📌"
Expand Down Expand Up @@ -211,9 +224,11 @@ async def bookmark_tag(ctx, message: discord.Message):
else:
embed.add_field(name="🏰 Guild", value=f"DM", inline=True)
if message.embeds:
global numembeds
numembeds = len(message.embeds) # Number of embeds
embed.add_field(name="🔲 Embeds", value=f"{numembeds}", inline=True)
if message.attachments:
global numfiles
numfiles = len(message.attachments)
embed.add_field(name="📸 Attachments", value=f"{numfiles}", inline=True)

Expand Down

0 comments on commit b2f7fe7

Please sign in to comment.