alispelare9861

Welcome System: Automatically greet new members with customizable welcome messages and embeds. /say Embed Command: Allows administrators to create and send fully customizable embed messages to any Discord channel.

Self Roles System: Members can assign or remove roles by reacting to a message (or using buttons), with each reaction linked to a specific role. /session Command: A slash command that automatically sends a pre-configured and fully customizable session announcement or embed.

Advanced Ticket System: A professional ticket system with multiple ticket categories, customizable panels, transcripts, ticket logs, staff claim buttons, close/reopen options, and permission management to ensure efficient support.

Kodari AI
KodariJul 14 at 9:28 pm 10
CommunitySupportBot
A feature-rich Discord community bot that welcomes new members with customizable messages and embeds, lets administrators publish branded announcements through the /say command, and provides self-assignable roles with persistent buttons. It includes a configurable /session announcement system plus an advanced ticket workflow with category panels, private channels, staff claims, close and reopen controls, permission management, transcripts, and ticket logging.

</commentary>

Project initialized as CommunitySupportBot.

Configure .env with DISCORD_TOKEN, install dependencies with pip install -r requirements.txt, then run:

Shell
python bot.py
alispelare9861

How do i take it in to my discord server?

Kodari AI
KodariJul 14 at 9:42 pm 1
  1. Create the Discord application

    • Click New Application and name it.

    • Open Bot β†’ Add Bot.

    • Click Reset Token, copy the token, and keep it private.

  2. Enable intents In Bot β†’ Privileged Gateway Intents, enable:

    • Server Members Intent

    • Message Content Intent if the bot uses prefix commands

    Save the changes.

  3. Invite the bot

    • Go to OAuth2 β†’ URL Generator.

    • Select scopes:

      • bot

      • applications.commands

    • Select permissions needed by the bot:

      • View Channels

      • Send Messages

      • Embed Links

      • Read Message History

      • Add Reactions

      • Manage Channels

      • Manage Roles

      • Attach Files

    Copy the generated URL, open it in your browser, select your server, and authorize the bot.

    The bot account must have the Manage Roles permission, and its highest role must be placed above the self-assignable roles.

  4. Configure the token In the project folder, create a file named .env:

    Env
    DISCORD_TOKEN=your_bot_token_here
    

    Never share this token or commit .env to GitHub.

  5. Install and run the bot

    Shell
    pip install -r requirements.txt
    python bot.py
    

    Keep this terminal or server running. If the process stops, the bot goes offline.

  6. Use the slash commands After Discord registers the commands, you can use commands such as:

    Plain Text

/say /session

Plain Text

 Configure the welcome channel, role panel, and ticket panel using the commands provided by the bot. If slash commands do not appear immediately, restart the bot and wait a few minutes for Discord to synchronize them.
alispelare9861

Must i run the bot on my computer can you do it so its active 24/7

Kodari AI
KodariJul 15 at 2:09 pm 2

Noβ€”you don’t have to keep your computer running. The bot needs to run on an always-on hosting service, and I can’t host or operate it directly from this chat.

Recommended options:

  • VPS such as Hetzner, DigitalOcean, or Vultr β€” reliable, usually around $4–$6/month.

  • Railway β€” easy deployment, but usage may cost money.

  • Render β€” simple, but free services may sleep and are not ideal for Discord bots.

  • Your own Linux server β€” works if you already have one.

A typical VPS setup is:

Shell
sudo apt update
sudo apt install python3 python3-pip -y

git clone YOUR_PROJECT_URL
cd YOUR_PROJECT_FOLDER

pip3 install -r requirements.txt
nano .env

Add your token:

Env
DISCORD_TOKEN=your_bot_token_here

Then run it continuously with:

Shell
sudo apt install tmux -y
tmux new -s discordbot
python3 bot.py

Press Ctrl+B, then D to detach while leaving the bot running.

For automatic restarts after crashes or server reboots, use a systemd service instead:

Shell
sudo nano /etc/systemd/system/discordbot.service
Ini
[Unit]
Description=Discord Bot
After=network.target

[Service]
WorkingDirectory=/home/ubuntu/CommunitySupportBot
ExecStart=/usr/bin/python3 /home/ubuntu/CommunitySupportBot/bot.py
Restart=always
User=ubuntu

[Install]
WantedBy=multi-user.target

Enable it:

Shell
sudo systemctl daemon-reload
sudo systemctl enable discordbot
sudo systemctl start discordbot

Check its status:

Shell
sudo systemctl status discordbot

The bot will then remain online 24/7 as long as the hosting server is active. Never upload your .env file or share your Discord token.

alispelare9861

Can u Send me the whole python flask script

Kodari AI
KodariJul 15 at 2:22 pm 9
  1. Add a Flask health-check server for hosting-service uptime checks.

  2. Start it automatically alongside the Discord bot.

  3. Add Flask to the dependency list.

Use this updated project with:

Shell
pip install -r requirements.txt
python bot.py

The Flask endpoint is only a health-check web server; it does not make a bot 24/7 by itself. The bot still needs to run on an always-on host such as a VPS or paid hosting service.

The project now includes:

  • bot.py β€” Discord bot plus Flask health server

  • keep_alive.py β€” Flask web server

  • requirements.txt β€” includes Flask

Run it with:

Shell
pip install -r requirements.txt
python bot.py

Set your token in .env:

Env
DISCORD_TOKEN=your_bot_token_here

Flask keeps a web endpoint available at /health, but the bot must still be deployed on an always-on service for 24/7 operation.

alispelare9861

Remove /health

Kodari AI
KodariJul 15 at 2:24 pm 1

Removed the /health route. The root / endpoint remains available.

alispelare9861

Give me the script of the bot

Kodari AI
KodariJul 15 at 2:24 pm 1

Save this as bot.py:

Python
from __future__ import annotations

import logging
import os

import discord
from discord import app_commands
from discord.ext import commands
from dotenv import load_dotenv

from keep_alive import start_keep_alive
from utils.database import Database

load_dotenv()

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
)

intents = discord.Intents.all()

class CommunitySupportBot(commands.Bot):
    def __init__(self):
        super().__init__(
            command_prefix="!",
            intents=intents,
            help_command=None,
        )
        self.db = Database()

    async def setup_hook(self) -> None:
        await self.db.initialize()

        extensions = (
            "cogs.welcome",
            "cogs.admin",
            "cogs.roles",
            "cogs.session",
            "cogs.tickets",
        )

        for extension in extensions:
            await self.load_extension(extension)

        roles_cog = self.get_cog("RolesCog")
        if roles_cog:
            await roles_cog.restore_views()

        tickets_cog = self.get_cog("TicketsCog")
        if tickets_cog:
            await tickets_cog.restore_views()

        await self.tree.sync()

    async def close(self) -> None:
        await self.db.close()
        await super().close()

bot = CommunitySupportBot()

@bot.event
async def on_ready() -> None:
    logging.getLogger("CommunitySupportBot").info(
        "Logged in as %s (%s)",
        bot.user,
        bot.user.id if bot.user else "unknown",
    )

@bot.tree.error
async def on_app_command_error(
    interaction: discord.Interaction,
    error: app_commands.AppCommandError,
) -> None:
    if isinstance(error, app_commands.errors.MissingPermissions):
        message = "You do not have permission to use this command."
    elif isinstance(error, app_commands.errors.CheckFailure):
        message = "You do not meet the requirements for this command."
    else:
        logging.getLogger("CommunitySupportBot").exception(
            "Application command failed",
            exc_info=error,
        )
        message = "Something went wrong while running that command."

    if interaction.response.is_done():
        await interaction.followup.send(message, ephemeral=True)
    else:
        await interaction.response.send_message(message, ephemeral=True)

token = os.getenv("DISCORD_TOKEN")

if not token:
    raise RuntimeError("DISCORD_TOKEN is not set in the environment")

start_keep_alive()
bot.run(token)

This is the main launcher and requires the existing cogs/, utils/, and keep_alive.py files. Create a .env file containing:

Env
DISCORD_TOKEN=your_discord_bot_token

Run it with:

Shell
pip install -r requirements.txt
python bot.py
Kodari can make mistakes. Review important code before using.
Files
cogs
utils
.gitignore
bot.py
keep_alive.py
requirements.txt
Code
13 1,445
bot.py
from __future__ import annotations

import logging
import os

import discord
from discord import app_commands
from discord.ext import commands
from dotenv import load_dotenv

from keep_alive import start_keep_alive
from utils.database import Database

load_dotenv()
logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
)

intents = discord.Intents.all()


class CommunitySupportBot(commands.Bot):
    def __init__(self):
        super().__init__(
            command_prefix="!",
            intents=intents,
            help_command=None,
        )
        self.db = Database()

    async def setup_hook(self) -> None:
        await self.db.initialize()

        extensions = (
            "cogs.welcome",
            "cogs.admin",
            "cogs.roles",
            "cogs.session",
            "cogs.tickets",
        )
        for extension in extensions:
            await self.load_extension(extension)

        roles_cog = self.get_cog("RolesCog")
        if roles_cog:
            await roles_cog.restore_views()

        tickets_cog = self.get_cog("TicketsCog")
        if tickets_cog:
            await tickets_cog.restore_views()

        await self.tree.sync()

    async def close(self) -> None:
        await self.db.close()
        await super().close()


bot = CommunitySupportBot()


@bot.event
async def on_ready() -> None:
    logging.getLogger("CommunitySupportBot").info(
        "Logged in as %s (%s)",
        bot.user,
        bot.user.id if bot.user else "unknown",
    )


@bot.tree.error
async def on_app_command_error(
    interaction: discord.Interaction,
    error: app_commands.AppCommandError,
) -> None:
    if isinstance(error, app_commands.errors.MissingPermissions):
        message = "You do not have permission to use this command."
    elif isinstance(error, app_commands.errors.CheckFailure):
        message = "You do not meet the requirements for this command."
    else:
        logging.getLogger("CommunitySupportBot").exception(
            "Application command failed",
            exc_info=error,
        )
        message = "Something went wrong while running that command."

    if interaction.response.is_done():
        await interaction.followup.send(message, ephemeral=True)
    else:
        await interaction.response.send_message(message, ephemeral=True)


token = os.getenv("DISCORD_TOKEN")
if not token:
    raise RuntimeError("DISCORD_TOKEN is not set in the environment")

start_keep_alive()
bot.run(token)