import os
import discord
from discord.ext import commands

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()
    bot = commands.Bot(command_prefix='!', intents=intents)

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

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

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!

Category
Technology
Last published
July 26, 2024

More templates like this

AlphaBot Financial Summary

AlphaBot Financial Summary: A Discord bot that utilizes the Alpha Vantage API to provide AI-generated summaries of income statements, balance sheets, and cash flow for renowned US companies.

Discord

Discord Moderation Bot

The Discord bot monitors all messages in the server. If a message contains profanity, the bot deletes it and sends a warning to the channel. The bot also notifies the host about the deletion via a direct message. Additionally, the bot outputs a helpful error message to a channel if there is a permissions error, guiding the server admin to enable the required permission in the Discord Developer portal.

Discord
Python
Flask

Discord Bot

This powerful app skeleton is a great starting place for a Discord bot

Discord
Home
/
GreetingBot