Repository navigation
Discord Bot
SORA edited this page Nov 26, 2026
·
1 revision
A small discord.py bot with an operator card command and an animated one.
Keep one Cards for the whole bot, it holds the caches.
import discord
from discord import app_commands
import akef
import akef_cards
intents = discord.Intents.default()
bot = discord.Client(intents=intents)
tree = app_commands.CommandTree(bot)
cards = akef_cards.Cards(max_renders=3)
@tree.command(description="operator card from an Enka UID")
async def card(interaction: discord.Interaction, uid: str, operator: str, dark: bool = False):
await interaction.response.defer()
try:
build = (await cards.enka(uid)).build(operator)
except akef.PlayerNotFound:
return await interaction.followup.send("cant find that UID")
except akef.ShowcaseEmpty:
return await interaction.followup.send("their showcase is empty")
if build is None:
return await interaction.followup.send(f"{operator} isnt in their showcase")
file = await cards.render_bytes(build, template=2 if dark else 1, hidden=True, format="JPEG")
await interaction.followup.send(file=discord.File(file, filename=file.name))
@tree.command(description="operator card with your gif as the art")
async def animated(interaction: discord.Interaction, uid: str, operator: str, gif: discord.Attachment):
await interaction.response.defer()
build = (await cards.enka(uid)).build(operator)
if build is None:
return await interaction.followup.send(f"{operator} isnt in their showcase")
try:
clip = await cards.animated_card(build, await gif.read(), fit="auto", hidden=True)
file = await clip.fit_under(10)
except akef_cards.CardError as e:
return await interaction.followup.send(str(e))
await interaction.followup.send(file=discord.File(file, filename=file.name))
@bot.event
async def on_ready():
await tree.sync()
bot.run("your bot token")-
hidden=Trueblurs the UID, nice for public channels -
format="JPEG"makes still cards a lot smaller to upload - uploads are passed as bytes, so no
allow_local/allow_remoteneeded (see Custom Art) -
fit_under(10)keeps animated cards under the 10 MB upload limit servers get without boosts -
max_rendersstops a burst of commands from eating all your CPU
akef-cards · MIT · not affiliated with Hypergryph or Gryphline
akef-cards
- 🏠 Home
- 🚀 Getting Started
- 🖼️ Card Gallery
- 🎞️ Animated Cards
- 🎨 Custom Art
- 🤖 Discord Bot
- ⚡ Caching and Speed
- ❓ FAQ