A Discord bot that converts images to single-frame GIFs, with support for user-installable commands.
- Slash command
/togifthat converts an attached image to a single-frame GIF - Context menu command "Convert to GIF" when right-clicking on messages with images
- User-installable command that can be used in any server or DM
- All responses are ephemeral (only visible to the user who triggered the command)
- Supports PNG, JPG, JPEG, WEBP, and BMP image formats
-
Make sure you have Python 3.8 or higher installed
-
Install the required dependencies:
pip install -r requirements.txtNote: This will install the master branch of discord.py which is required for user-installable commands.
-
Run the bot:
python script.py
- Register your application in the Discord Developer Portal
- Enable the "Message Content Intent" in the Bot section
- In the OAuth2 URL Generator:
- Select scopes:
bot,applications.commands - Select bot permissions:
Send Messages,Attach Files,Use Slash Commands
- Select scopes:
- Use the generated URL to invite the bot to your server
-
Users can install the command to their account by:
- Right-clicking on the bot in a server
- Selecting "Add to Home"
- Following the prompts to install the command
-
Once installed, users can use the bot in two ways:
- Slash Command: Type
/togifand attach an image when prompted - Context Menu: Right-click on any message containing an image and select "Apps" > "Convert to GIF"
- Slash Command: Type
-
The bot will convert the image to a GIF and send it back without any accompanying text. All responses are ephemeral (only visible to you).
The bot token in the script should be kept private. For production use, consider using environment variables to store sensitive information.
- If the bot doesn't respond, make sure it has the necessary permissions in the channel
- For large images, the conversion might take a moment
- If you encounter any errors, they will be displayed in the Discord channel
- If commands aren't showing up for users, make sure you're using the master branch of discord.py and have synced the command tree
If the command doesn't appear in DMs after installation:
-
Restart Discord: Sometimes Discord needs a restart to show newly installed commands in DMs.
-
Check Installation: Make sure you've properly installed the command to your user account:
- Right-click on the bot in a server
- Select "Add to Home"
- Confirm the installation
-
Bot Requirements: The bot must be using the master branch of discord.py (2.3.2 or newer) and have the
@app_commands.allowed_contexts(dms=True)decorator. -
Reinstall: Try removing the bot from your Home and reinstalling it.
-
Discord Limitations: There might be rate limits or other Discord-side limitations affecting command availability.