Last active
August 19, 2025 06:58
-
-
Save castrix/4731d45261db2f47cf94724acd55c5e6 to your computer and use it in GitHub Desktop.
bot dc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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