How to Enable Text-to-Speech (TTS) in Your Python Discord Bot

1. Log In to Your Panel


2. Select the ‘Files’ Tab

Cybrancee Panel in the files page, "Files" tab on the sidebar is highlighted

3. Create Your Main Bot’s File

Create a new file called index.py then paste the following code.

Pterodactyl Panel, Create File dialog. Enter File Name (index.py)

What this code does:

  • Loads your bot token
  • Enables Intents, which Discord now requires
  • Creates a bot with the ! command prefix
  • Adds a !say command
    • When a user types !say, the bot replies with a TTS message
import os
import discord
from discord.ext import commands

TOKEN = 'DISCORD_TOKEN'

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

bot = commands.Bot(command_prefix='!', intents=intents)

@bot.event
async def on_ready():
    print('Bot ready')

@bot.command()
async def say(ctx):
    await ctx.send('Hello from your bot using T T S.', tts=True)

bot.run(TOKEN)

Discord Bot Hosting

Starts at $1.49

External link icon
Was this article helpful?
Please Share Your Feedback
How Can We Improve This Article?
Table of Contents