import os
import discord
from discord.ext import commands

def generate_oauth_link(client_id):
    base_url = ""
    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()
    bot = commands.Bot(command_prefix='!', intents=intents)

    async def on_ready():
        print(f'Bot is ready. Logged in as {bot.user}')

    async def on_message(message):
        # Ignore messages from the bot itself to avoid infinite loops
        if == bot.user:

About this template

GreetingBot: A discord bot that welcomes new members to your server.

Introduction to the GreetingBot Template

Welcome to the GreetingBot template! This template provides you with a pre-built Discord bot that sends a "Hello World" message in response to any message or mention in your Discord server. It's a great starting point for creating a bot that welcomes new members or interacts with users in your community.

Getting Started with the GreetingBot Template

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, paste, or delete any code manually.

Initial Setup: Adding Environment Secrets

Before you can test and deploy your GreetingBot, you'll need to set up a couple of environment secrets within the Lazy Builder. These are the CLIENT_ID and BOT_TOKEN, which are essential for your bot to interact with the Discord API.

  • Go to the Discord Developer Portal and create a new application.
  • Navigate to the 'Bot' section and click 'Add Bot'.
  • Under the 'TOKEN' section, click 'Copy' to get your BOT_TOKEN.
  • Navigate to the 'OAuth2' section, and under 'CLIENT ID', click 'Copy' to get your CLIENT_ID.
  • In the Lazy Builder, go to the Environment Secrets tab and add two new secrets: CLIENT_ID and BOT_TOKEN, pasting the respective values you copied earlier.

Test: Pressing the Test Button

Once you have set up your environment secrets, you can press the "Test" button in the Lazy Builder. This will begin the deployment of your GreetingBot and launch the Lazy CLI. You will not be prompted for any additional user input at this stage, as the necessary information is already provided through the environment secrets.

Using the GreetingBot

After pressing the "Test" button and deploying your bot, you will receive a dedicated server link. Use this link to invite the GreetingBot to your Discord server. Once the bot is in your server, it will automatically respond with "Hello World" to any message or mention, showcasing its functionality.

Integrating the GreetingBot into Your Server

To fully integrate the GreetingBot into your Discord server, follow these steps:

  • Use the OAuth link provided by the Lazy CLI to invite the bot to your server.
  • Select the server you want to add the bot to and grant the necessary permissions.
  • Once the bot is added, it will start interacting with messages as programmed.

Remember, the GreetingBot is just a starting point. You can customize the bot's code to add more features, such as welcoming new members, responding to specific commands, or providing helpful information to your community members.

Enjoy building with the GreetingBot template and making your Discord server more interactive and welcoming!

Last published
April 7, 2024

More templates like this

WhatsApp ChatBot (Twilio, InstantChat)

Build a WhatApp chatbot using Twilio, Discord and LazyAI.


Stock AI Advice

The bot requires certain permissions to function properly. These include the ability to read message history, send messages, and react to messages. The bot will generate stats such as This bot will provide ticker stats, commodity stats, Stock News and other AI Stock Trading Advice Please provide the Discord bot token in the Env Secrets tab under the name 'DISCORD_BOT_TOKEN' and your API Key for the Alpha Advantage


Twitter Announcement Discord Bot

This app tracks the growth of a Discord server and posts updates to Twitter. This app creates a tweet to your twitter account every time another hundred users join your discord server. Make sure you have twitter access tokens created with Read, Write, and Direct Messages permissions to run this app.