mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 10:03:40 +01:00
piss
This commit is contained in:
parent
53c87d5c27
commit
047eaa17c0
2 changed files with 24 additions and 16 deletions
|
@ -1,6 +1,7 @@
|
|||
import asyncio
|
||||
import io
|
||||
import os
|
||||
import time
|
||||
from typing import Tuple, Optional
|
||||
|
||||
import discord
|
||||
|
@ -154,7 +155,11 @@ class OtherCog(commands.Cog):
|
|||
"""Generates a "corrupted" file."""
|
||||
limit_mb = round(ctx.guild.filesize_limit / 1024 / 1024)
|
||||
if size_in_megabytes > limit_mb:
|
||||
return await ctx.respond(f"File size must be less than {limit_mb} MB.")
|
||||
return await ctx.respond(
|
||||
f"File size must be less than {limit_mb} MB.\n"
|
||||
"Want to corrupt larger files? see https://github.com/EEKIM10/cli-utils#installing-the-right-way"
|
||||
" (and then run `ruin <file>`)."
|
||||
)
|
||||
await ctx.defer()
|
||||
|
||||
size = max(min(int(size_in_megabytes * 1024 * 1024), ctx.guild.filesize_limit), 1)
|
||||
|
@ -174,17 +179,21 @@ class OtherCog(commands.Cog):
|
|||
|
||||
@corrupt_file.command(name="ruin")
|
||||
async def ruin_corrupt_file(
|
||||
self,
|
||||
ctx: discord.ApplicationContext,
|
||||
file: discord.Attachment,
|
||||
passes: int = 10,
|
||||
metadata_safety_boundary: float = 5
|
||||
self,
|
||||
ctx: discord.ApplicationContext,
|
||||
file: discord.Attachment,
|
||||
passes: int = 10,
|
||||
metadata_safety_boundary: float = 5,
|
||||
):
|
||||
"""Takes a file and corrupts parts of it"""
|
||||
await ctx.defer()
|
||||
attachment = file
|
||||
if attachment.size > 8388608:
|
||||
return await ctx.respond("File is too large. Max size 8mb.")
|
||||
return await ctx.respond(
|
||||
"File is too large. Max size 8mb.\n"
|
||||
"Want to corrupt larger files? see https://github.com/EEKIM10/cli-utils#installing-the-right-way"
|
||||
" (and then run `ruin <file>`)."
|
||||
)
|
||||
bound_pct = attachment.size * (0.01 * metadata_safety_boundary)
|
||||
bound_start = round(bound_pct)
|
||||
bound_end = round(attachment.size - bound_pct)
|
||||
|
@ -192,17 +201,17 @@ class OtherCog(commands.Cog):
|
|||
file = io.BytesIO(await file.read())
|
||||
file.seek(0)
|
||||
await ctx.edit(content="Corrupting file...")
|
||||
file = await asyncio.to_thread(
|
||||
self.do_file_corruption,
|
||||
file,
|
||||
passes,
|
||||
bound_start,
|
||||
bound_end
|
||||
)
|
||||
file = await asyncio.to_thread(self.do_file_corruption, file, passes, bound_start, bound_end)
|
||||
file.seek(0)
|
||||
await ctx.edit(content="Uploading file...")
|
||||
await ctx.edit(content="Here's your corrupted file!", file=discord.File(file, attachment.filename))
|
||||
|
||||
@commands.command(name="kys", aliases=['kill'])
|
||||
@commands.is_owner()
|
||||
async def end_your_life(self, ctx: commands.Context):
|
||||
await ctx.send(":( okay")
|
||||
await self.bot.close()
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(OtherCog(bot))
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
# py-cord==2.2.0
|
||||
git+https://github.com/pycord-development/pycord.git@master#egg=py-cord
|
||||
py-cord==2.3.2
|
||||
aiosmtplib==1.1.7
|
||||
orm[sqlite]==0.3.1
|
||||
httpx==0.23.0
|
||||
|
|
Loading…
Reference in a new issue