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.")

About this template

A simple Discord Ticketbot for your Discord Support Department. This Template and Bot is fully customizable but already build so that you can use it right away. You need a bot token from https://discord.com/developers/applications for your bot to work. These are the steps needed to get your token: "1. 🌐 Go to the Discord Developer Portal. 🌐\n" + "2. 🆕 Create a new application and navigate to the 'Bot' section. 🤖\n" + "3. 📋 Under the 'TOKEN' section, click 'Reset Token' to get your Discord bot token and confirm by clicking 'Yes, do it'. 🔑\n" + "4. 🤖 If your bot will have any ability to read/reply to messages, then under the 'BOT' section, enable the slider titled 'Message Content Intent' ✅" + "5. 🔐 Set the 'DISCORD_BOT_TOKEN' in the Env Secrets tab with your bot token from step 3. 🔐\n" + "For bot permissions, it's recommended to start with basic permissions and adjust as needed for your app's functionality.🚀") If you encounter any bugs, please tell Lazy to fix them and report them on the Official Lazy AI Discord to @D4vidG4merLP. Credits: @meow - the Discord bot slash command template @mrlazy.notlazy - supporting me And the Biggest Thank you. You for using this template ❤️

Introduction to the Discord Ticketbot Template

Welcome to the step-by-step guide on how to use the Discord Ticketbot 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:

  1. Go to the Discord Developer Portal.
  2. Create a new application and navigate to the 'Bot' section.
  3. Under the 'TOKEN' section, click 'Reset Token' to get your Discord bot token and confirm by clicking 'Yes, do it'.
  4. Enable the slider titled 'Message Content Intent' if your bot will read/reply to messages.
  5. Copy the 'Client ID' from the 'General Information' tab.
  6. 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!

Category
Technology
Last published
June 15, 2024

More templates like this

Discord bot using slash commands in python

Just a cute /ping bot

Discord
Python
Flask

Basic Discord Bot

A Discord bot that does nothing (excellent starting point). Think of it as the plain paper of Discord bots. It does nothing at all and you can turn it into whatever you want. All you need to set is a Discord bot token from your Discord developer portal and boom! You're done.

Discord
Python

ZenQuote Discord Bot

ZenQuoteBot: A Discord bot that sends a quote every 1 day to the server using the Zen quotes API.

Discord
Python
Home
/
Discord Ticketbot Template