Skip to content

Commit

Permalink
removed channel scrape
Browse files Browse the repository at this point in the history
  • Loading branch information
Mole1424 committed Mar 31, 2024
1 parent 1fca1cc commit 2e78787
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions cogs/commands/misc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import random
import tempfile

from discord import File
from discord.ext import commands
from discord.ext.commands import Bot, Context, check

from utils import is_compsoc_exec_in_guild
from discord.ext.commands import Bot, Context


class Misc(commands.Cog):
Expand Down Expand Up @@ -128,30 +124,6 @@ async def babbage(self, ctx: Context):
"Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?"
)

@commands.hybrid_command()
@check(is_compsoc_exec_in_guild)
async def scrapegeneral(self, ctx: Context):
# get general channel by id
general = ctx.guild.get_channel(189453139584221185)
# get all messages and send as txt file
messages = []
numfiles = 0
async for message in general.history(limit=None):
messages.append(message.content)
if len(messages) % 10000 == 0:
await ctx.send(f"Scraped {len(messages)}/~288,993s messages")
with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
f.write("\n".join(messages))
file = File(f.name, filename=f"general{numfiles}.txt")
numfiles += 1
await ctx.send(file=file)
messages = []
with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
f.write("\n".join(messages))
file = File(f.name, filename=f"general{numfiles}.txt")
await ctx.send(file=file)
return await ctx.send("Scraped all messages :)")


async def setup(bot: Bot):
await bot.add_cog(Misc(bot))

0 comments on commit 2e78787

Please sign in to comment.