Skip to content

Instantly share code, notes, and snippets.

@castrix
Last active August 19, 2025 06:58
Show Gist options
  • Save castrix/4731d45261db2f47cf94724acd55c5e6 to your computer and use it in GitHub Desktop.
Save castrix/4731d45261db2f47cf94724acd55c5e6 to your computer and use it in GitHub Desktop.
bot dc
import os
import discord
TOKEN = "YOUR_DISCORD_BOT_TOKEN" # replace with your bot token
CHANNEL_ID = 123456789012345678 # replace with your channel ID
COMMAND = "!screenshot" # command trigger
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f"✅ Logged in as {client.user}")
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.strip().lower() == COMMAND:
screenshot_path = "/sdcard/screen.png"
# take screenshot
os.system(f"screencap -p {screenshot_path}")
try:
# send screenshot
await message.channel.send(file=discord.File(screenshot_path))
finally:
# delete screenshot after sending
if os.path.exists(screenshot_path):
os.remove(screenshot_path)
client.run(TOKEN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment