Discord Support Ticket Bot Template
import discord
from discord import app_commands
import os
intents = discord.Intents.default()
intents.messages = True
intents.message_content = True
bot = discord.Client(intents=intents, activity = discord.CustomActivity("Example Activity"))
bot_token = os.environ.get('DISCORD_BOT_TOKEN')
tree = app_commands.CommandTree(bot)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
await tree.sync()
client_id = os.environ.get('DISCORD_CLIENT_ID')
if client_id:
invite_link = f"https://discord.com/oauth2/authorize?client_id={client_id}&scope=bot&permissions=8"
print(f"Invite your bot using this link: {invite_link}")
else:
print("DISCORD_CLIENT_ID is not set in the environment variables.")
Created: | Last Updated:
Introduction to the Discord Support Ticket Bot Template
Welcome to the step-by-step guide on how to use the Discord Support Ticket Bot Template on Lazy. This template is designed to help you create a Discord bot that can manage support tickets within your server. It's a fully customizable template that comes pre-built, allowing you to deploy a functional bot with minimal setup.
Getting Started
To begin using this template, simply click on "Start with this Template" on the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy or paste any code manually.
Initial Setup
Before you can test and use your bot, you'll need to set up a few environment secrets within the Lazy Builder. These are necessary for your bot to authenticate and interact with the Discord API.
- DISCORD_BOT_TOKEN: This is the token you receive from Discord when you create a new bot. It's used to authenticate your bot with the Discord servers.
- DISCORD_CLIENT_ID: This is the client ID of your Discord application. It's used to generate the invite link for your bot.
To obtain these values, follow these steps:
- Go to the Discord Developer Portal.
- Create a new application and navigate to the 'Bot' section.
- Under the 'TOKEN' section, click 'Reset Token' to get your Discord bot token and confirm by clicking 'Yes, do it'.
- Enable the slider titled 'Message Content Intent' if your bot will read/reply to messages.
- Copy the 'Client ID' from the 'General Information' tab.
- Set the 'DISCORD_BOT_TOKEN' and 'DISCORD_CLIENT_ID' in the Environment Secrets tab within the Lazy Builder with the values obtained from the previous steps.
Test: Pressing the Test Button
Once you have set up the necessary environment secrets, you can press the "Test" button in the Lazy Builder. This will begin the deployment of your application and launch the Lazy CLI. If the code requires any user input, you will be prompted to provide it through the Lazy CLI.
Using the App
After deploying your bot, you can invite it to your Discord server using the invite link that is printed in the Lazy CLI. Once the bot is in your server, you can use the `/ping` command to check its responsiveness and the `/create-panel` command to start the ticket creation process.
Here's an example of how to use the `/ping` command:
/ping Hello, world!
This will make the bot respond with "Pong: Hello, world!"
And here's how to use the `/create-panel` command:
/create-panel Support
This will create an embed panel with a button to create a support ticket in the "Support" category.
Integrating the App
If you wish to further customize or integrate the bot into your Discord server, you can modify the code within the Lazy Builder. For example, you can add more commands, change the embed messages, or adjust the bot's permissions.
Remember to sync your command tree after making changes to the bot's code by calling `await tree.sync()` within the `on_ready` event.
By following these steps, you should now have a functional Discord Ticketbot running in your server, ready to assist with managing support tickets. Enjoy your new bot, and don't hesitate to customize it to fit your server's needs!