Making a Discord Bot in Python: How to make a toggle talk for a ChatBot


Making a Discord Bot in Python: How to make a toggle talk for a ChatBot
I'm trying to make a discord ChatBot in Python and I seem to have come across a problem. I'm making a toggle on and off switch to make it talk but whenever I toggle that switch it says that 'talk' is not recognized as a command. I even tried making it @client.event instead of @client.command but it wouldn't work. Please help.
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
Client = discord.Client()
client = commands.Bot(command_prefix = ":")
on_talk = False
@client.event
async def on_ready():
print("You can talk to me now!")
@client.command
async def talk(message):
global on_talk
if message.content.upper().startswith(":TALK"):
on_talk = True
if message.content.upper().startswith(":STOPTALK"):
on_talk = False
if on_talk == False:
print("on_talk is set to False")
if on_talk == True:
print("It works")
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.