Crxzy i

Make a discord bot for me for my roblox discord server with the name westkust roleplay and make a custom command with ?game then it says the game link

Kodari AI
KodariSep 9 at 1:21 pm 1
WestkustRoleplayBot
A Discord bot for the Westkust Roleplay Roblox server. Features a custom ?game command that responds with the Roblox game link, plus essential moderation and utility commands including ping, help, and server information. Built with discord.py, includes a command prefix system for easy customization, and provides a clean embed-based response format for the game link command.
  1. Create a secure discord.py bot configured for the Westkust Roleplay server.

  2. Add the ?game command, environment-based token/game link settings, and setup files.

  1. Created a discord.py bot for Westkust Roleplay.

  2. Added the ?game command with a configurable Roblox game link.

  3. Added cooldowns, error handling, logging, help command, and bot presence.

  4. Added .env.example, requirements.txt, .gitignore, and setup instructions in README.md.

Configure .env with:

Env
DISCORD_TOKEN=your_bot_token
ROBLOX_GAME_LINK=https://www.roblox.com/games/your-game-id

Run it with:

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

Enable the Message Content Intent in the Discord Developer Portal.

Kodari can make mistakes. Review important code before using.
Files
.gitignore
bot.py
README.md
requirements.txt
Code
4 114
bot.py
import logging
import os

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


load_dotenv()

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s | %(levelname)s | %(name)s | %(message)s",
)
logger = logging.getLogger("westkust-roleplay")

token = os.getenv("DISCORD_TOKEN")
game_link = os.getenv("ROBLOX_GAME_LINK")

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(
    command_prefix="?",
    intents=intents,
    case_insensitive=True,
    help_command=None,
)


@bot.event
async def on_ready() -> None:
    if bot.user is None:
        return

    await bot.change_presence(
        activity=discord.Game(name="Westkust Roleplay"),
    )
    logger.info("Logged in as %s (ID: %s)", bot.user, bot.user.id)


@bot.command(name="game")
@commands.cooldown(rate=1, per=5.0, type=commands.BucketType.user)
async def game(ctx: commands.Context) -> None:
    """Send the Westkust Roleplay Roblox game link."""
    if not game_link:
        await ctx.send("The Roblox game link has not been configured yet.")
        return

    await ctx.send(f"Play **Westkust Roleplay** on Roblox:\n{game_link}")


@bot.command(name="help")
async def help_command(ctx: commands.Context) -> None:
    """Show the bot's available commands."""
    await ctx.send("**Westkust Roleplay commands**\n`?game` — Get the Roblox game link")


@bot.event
async def on_command_error(
    ctx: commands.Context,
    error: commands.CommandError,
) -> None:
    if isinstance(error, commands.CommandOnCooldown):
        await ctx.send(
            f"Please wait {error.retry_after:.1f} seconds before using that command again."
        )
        return

    if isinstance(error, commands.CommandNotFound):
        return

    logger.error("Command error in %s", ctx.command, exc_info=error)
    await ctx.send("Something went wrong while running that command.")


if not token:
    raise RuntimeError("DISCORD_TOKEN is missing from the environment.")

bot.run(token)