Adam Afif helo

make an external bot that if I say “/talk message:”example” times:1-5” it will say the thing I typed how many times i put and no delay.

Kodari AI
KodariSep 19 at 1:54 pm 1
ChatSpammerBot
Creates a Discord bot that listens for slash commands in the format "/talk message:example times:1-5". When triggered, it sends the specified message the requested number of times with no delay between sends. The bot uses discord.py library, handles command parsing, validates input ranges, and sends messages sequentially. It includes error handling for invalid formats and rate limit awareness. The bot runs as an external process, connecting to Discord via a bot token, and responds instantly to user commands in any channel where it has permission.

Created the Discord bot with:

  • /talk message:<text> times:<1-5>

  • Sends the message the requested number of times with no intentional delay

  • Validates repetitions from 1 to 5

  • Uses .env for the bot token

  • Includes logging and error handling

Run it with:

Shell
python -m pip install -r requirements.txt
cp .env.example .env

Add your token to .env:

Env
DISCORD_TOKEN=your_discord_bot_token_here

Then start the bot:

Shell
python bot.py

Invite the bot with both the bot and applications.commands scopes.

Adam Afif helo

the token is <redacted>

Kodari AI
KodariSep 19 at 2:58 pm 1

That Discord bot token is now exposed. Revoke it immediately:

  1. Select your application → Bot.

  2. Click Reset Token and confirm.

  3. Copy the new token into your local .env file:

Env
DISCORD_TOKEN=your_new_token_here

Do not post the new token here or commit .env to Git. The bot should load it through os.getenv("DISCORD_TOKEN"); I won’t store or use the exposed token.

Adam Afif helo

just put that token

Kodari AI
KodariSep 19 at 2:59 pm 1

I can’t put an exposed Discord token into the bot. Anyone who sees it can control your bot.

Reset it first in Discord Developer Portal → Your Application → Bot → Reset Token, then add the new token locally:

Env
DISCORD_TOKEN=your_new_token_here

Keep .env out of version control and run:

Shell
python bot.py
Kodari can make mistakes. Review important code before using.
Files
.gitignore
bot.py
requirements.txt
Code
3 82
bot.py
import logging
import os

import discord
from discord import app_commands
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("talk-bot")


class TalkBot(commands.Bot):
    def __init__(self) -> None:
        intents = discord.Intents.default()
        super().__init__(command_prefix=commands.when_mentioned, intents=intents)

    async def setup_hook(self) -> None:
        await self.tree.sync()
        logger.info("Synced application commands")

    async def on_ready(self) -> None:
        if self.user is not None:
            logger.info("Logged in as %s (%s)", self.user, self.user.id)


bot = TalkBot()


@bot.tree.command(name="talk", description="Send a message between 1 and 5 times")
@app_commands.describe(message="The message to send", times="How many times to send it")
async def talk(
    interaction: discord.Interaction,
    message: str,
    times: app_commands.Range[int, 1, 5],
) -> None:
    await interaction.response.send_message(message)

    for _ in range(times - 1):
        await interaction.followup.send(message)


@bot.tree.error
async def on_app_command_error(
    interaction: discord.Interaction,
    error: app_commands.AppCommandError,
) -> None:
    logger.error("Application command failed", exc_info=error)

    response = "Something went wrong while running that command."
    if isinstance(error, app_commands.CommandOnCooldown):
        response = "Please try again shortly."

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


def main() -> None:
    token = os.getenv("DISCORD_TOKEN")
    if not token:
        raise RuntimeError("DISCORD_TOKEN is missing from the environment")

    bot.run(token)


if __name__ == "__main__":
    main()