by we
EmbedGen Bot
import os
import discord
from discord.ext import commands
from abilities import llm
def generate_oauth_link(client_id):
base_url = "https://discord.com/api/oauth2/authorize"
redirect_uri = "http://localhost"
scope = "bot"
permissions = "8" # Administrator permission for simplicity, adjust as needed.
return f"{base_url}?client_id={client_id}&permissions={permissions}&scope={scope}"
def start_bot(token):
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
bot = commands.Bot(command_prefix='!', intents=intents)
bot.embed_cache = {}
@bot.event
async def on_ready():
print(f'Bot is ready. Logged in as {bot.user}')
@bot.command()
Created: | Last Updated:
Here's a step-by-step guide for using the EmbedGen Bot template:
Introduction to the EmbedGen Bot Template
The EmbedGen Bot is a Discord bot that allows users to generate custom embeds using a simple command. This bot can create visually appealing and informative embeds based on user prompts, making it easier to share information in Discord servers.
Getting Started
-
Click "Start with this Template" to begin using the EmbedGen Bot template in Lazy.
-
Set up the required environment secrets:
- In the Lazy Builder interface, navigate to the Environment Secrets tab.
- Add the following secrets:
CLIENT_ID
: Your Discord application's client IDBOT_TOKEN
: Your Discord bot token
To obtain these values:
- Go to the Discord Developer Portal (https://discord.com/developers/applications)
- Create a new application or select an existing one
- Navigate to the "Bot" section and click "Add Bot" if you haven't already
- Under the "TOKEN" section, click "Copy" to get your BOT_TOKEN
- Go to the "OAuth2" section and copy the "CLIENT ID"
Testing the Bot
-
Click the "Test" button in the Lazy Builder interface to start the deployment process.
-
Once the deployment is complete, you'll see an OAuth link printed in the console. Use this link to invite the bot to your Discord server.
Using the EmbedGen Bot
-
In your Discord server, you can now use the following commands:
-
To create an embed:
!embed [your prompt]
For example:!embed a tweet previewer
-
To reuse a previously created embed:
!grab [message_id]
Replace[message_id]
with the ID of the message containing the embed you want to reuse. -
The bot will generate an embed based on your prompt using AI. The embed will include a title, description, color, and relevant fields.
-
After creating an embed, the bot will provide a message with the embed's ID, which you can use with the
!grab
command to reuse it later.
Integrating the Bot
No additional integration steps are required. Once the bot is invited to your Discord server, it will be ready to use with the commands mentioned above.
Remember to manage the bot's permissions in your Discord server settings to ensure it has the necessary access to read messages and send embeds in the desired channels.