Skip to content

Instantly share code, notes, and snippets.

@kubinka0505
Created January 18, 2021 11:51
Show Gist options
  • Save kubinka0505/3969a36ca46705e3f53f7f9624ee9403 to your computer and use it in GitHub Desktop.
Save kubinka0505/3969a36ca46705e3f53f7f9624ee9403 to your computer and use it in GitHub Desktop.
Discord Custom Emoji Ripper (rewrite)
import discord # >= 1.6
from os import *
from io import BytesIO
from discord.ext.commands import Bot
__description__ = "Discord Custom Emoji Ripper"
__author__ = "kubinka0505"
__date__ = "18.01.2021"
__version__ = "0.1"
__credits__ = __author__
__status__ = "Development"
__license__ = "Apache 2.0"
__changelog__ = {"0.1": "Initial release"}
Bot = Bot(
command_prefix = "/",
description = __description__
)
Bot.remove_command("help")
#---#
Guild_ID = "" # Target Server ID
Autocrop_Emojis = False # Possibly makes static emoji images optically larger (requires PIL)
Token = ""
#---#
@Bot.event
async def on_ready():
Guild = Bot.get_guild(int(Guild_ID))
print('Fetching {0} emojis to "{1}" folder...'.format(len(Guild.emojis), __description__))
#---#
try: mkdir(__description__)
except FileExistsError: pass
chdir(__description__)
#---#
try: mkdir(Guild.name)
except FileExistsError: pass
chdir(Guild.name)
#---#
for Emoji in Guild.emojis:
if Autocrop_Emojis:
from PIL import Image
if not Emoji.animated:
Em = await Emoji.url_as().read()
Em = Image.open(BytesIO(Em))
Em = Em.crop(Em.getbbox())
Em.save(Emoji.name + ".png")
else:
continue
else:
await Emoji.url_as().save("{0}.{1}".format(Emoji.name, "gif" if Emoji.animated else "png"))
raise SystemExit('Fetched {0} emojis successfully.'.format(len(Guild.emojis)))
Bot.run(Token, bot = False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment