【发布时间】:2019-01-06 04:07:53
【问题描述】:
请记住,我对 Python 有点陌生,对 discord API 也很陌生。我正在尝试在 Discord 中使用 Python 制作一个 ChatBot,我有一个命令,你必须说它才能让机器人与你交谈。该命令称为谈话。要停止与机器人交谈,您必须启用 stoptalk。可悲的是,我编写的启用停止通话的功能不起作用,我不知道如何修复它。请帮忙。
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(pass_context=True)
async def ontalker(message):
global on_talk
if message.content.upper().startswith(":TALK"):
on_talk = True
@client.command(pass_context=True)
async def offtalker(message):
global ontalk
if message.content.upper().startswith(":STOPTALK"):
on_talk = False
@client.command(pass_context=True)
async def stoptalk(ctx):
print("on_talk is False.")
@client.command(pass_context=True)
async def talk(ctx):
@client.event
# Everything I want to do goes here
【问题讨论】:
标签: python function discord discord.py