commit 7e845ace539ee01f26618ff16d14361a641cc869 Author: William P Date: Sat Feb 14 19:11:17 2026 -0500 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d3f24e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +venv/ +out/ +build/ +dist/ +*.spec diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b35fa77 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +discord.py-self==2.1.0 +pyinstaller==6.19.0 \ No newline at end of file diff --git a/scrapist.py b/scrapist.py new file mode 100644 index 0000000..ecccb08 --- /dev/null +++ b/scrapist.py @@ -0,0 +1,54 @@ +import discord +import os +import argparse +from pathlib import Path + +parser = argparse.ArgumentParser( + prog="Scrapist", + description="Simple emoji extractor for Discord." +) +parser.add_argument('-t', '--discord_token', help="user or bot token that has access to the Discord server you'll be exporting emoji from. can also be provided via the `$DISCORD_TOKEN` env variable") +parser.add_argument('-g', '--guild_id', help="ID of the Discord server you wish to extract emoji from", required=True) +parser.add_argument('-o', '--out_dir', help="path where emojis will be downloaded to", required=True) +args = parser.parse_args() + +discord_token = os.getenv("DISCORD_TOKEN") +if args.discord_token is not None: + discord_token = args.discord_token +if discord_token is None: + exit("No Discord token provided") + +guild_id = args.guild_id +out_dir = args.out_dir + +class Scrapist(discord.Client): + async def on_ready(self): + print('Logged in as', self.user) + + guild = self.get_guild(int(guild_id)) + guild_name = guild.name + + # Create output directories if they don't exist + Path(f'{out_dir}/{guild_name}/emoji').mkdir(parents=True, exist_ok=True) + Path(f'{out_dir}/{guild_name}/animated').mkdir(parents=True, exist_ok=True) + Path(f'{out_dir}/{guild_name}/sticker').mkdir(parents=True, exist_ok=True) + + emotes = await guild.fetch_emojis() + for emote in emotes: + if emote.animated: + filename = f"{emote.name}.webp" + await emote.save(f'{out_dir}/{guild_name}/animated/{filename}') + else: + filename = f"{emote.name}.png" + await emote.save(f'{out_dir}/{guild_name}/emoji/{filename}') + print(f"downloaded {filename}") + stickers = await guild.fetch_stickers() + for sticker in stickers: + filename = f"{sticker.name}.png" + await sticker.save(f'{out_dir}/{guild_name}/sticker/{filename}') + print(f"downloaded {sticker.name}") + + await self.close() + +client = Scrapist() +client.run(discord_token) \ No newline at end of file