我能';我不能让python中的Discord bot将消息发送到特定的通道 线程2中的异常: 回溯(最近一次呼叫最后一次): 文件“C:\Users\PC0\Anaconda3\lib\threading.py”,第932行,在_bootstrap_inner中 self.run() 文件“C:\Users\PC0\Anaconda3\lib\threading.py”,第870行,正在运行 自我目标(*自我参数,**自我参数) 文件“main\u greetings.py”,第101行,在\u回调之间 循环。运行\u直到\u完成(时间\u消息(args)) 文件“C:\Users\PC0\Anaconda3\lib\asyncio\base\u events.py”,第616行,在运行中直到完成 返回future.result() 文件“C:\Users\PC0\Desktop\h ver 18-03\SmartBot main\core\modules\greetings.py”,第6行,时间信息 bot=commands.bot(命令前缀='。) NameError:未定义名称“commands”

我能';我不能让python中的Discord bot将消息发送到特定的通道 线程2中的异常: 回溯(最近一次呼叫最后一次): 文件“C:\Users\PC0\Anaconda3\lib\threading.py”,第932行,在_bootstrap_inner中 self.run() 文件“C:\Users\PC0\Anaconda3\lib\threading.py”,第870行,正在运行 自我目标(*自我参数,**自我参数) 文件“main\u greetings.py”,第101行,在\u回调之间 循环。运行\u直到\u完成(时间\u消息(args)) 文件“C:\Users\PC0\Anaconda3\lib\asyncio\base\u events.py”,第616行,在运行中直到完成 返回future.result() 文件“C:\Users\PC0\Desktop\h ver 18-03\SmartBot main\core\modules\greetings.py”,第6行,时间信息 bot=commands.bot(命令前缀='。) NameError:未定义名称“commands”,python,python-3.x,class,discord,discord.py,Python,Python 3.x,Class,Discord,Discord.py,我在提到discord机器人时遇到了这个错误,我不太清楚我做错了什么。以下是我对该部分的代码: 导入时间、随机、不一致 从日期时间导入日期时间 异步定义时间消息(参数): bot=commands.bot(命令前缀='。) alarmtime=“16:26” 问候语频道=机器人获取频道(“8142381563962298310”) #通道=bot.get_通道=xxx 尽管如此: lcltime=datetime.now().strftime(“%H:%M”) 如果lcltime==报警时间:

我在提到discord机器人时遇到了这个错误,我不太清楚我做错了什么。以下是我对该部分的代码:

导入时间、随机、不一致
从日期时间导入日期时间
异步定义时间消息(参数):
bot=commands.bot(命令前缀='。)
alarmtime=“16:26”
问候语频道=机器人获取频道(“8142381563962298310”)
#通道=bot.get_通道=xxx
尽管如此:
lcltime=datetime.now().strftime(“%H:%M”)
如果lcltime==报警时间:
#aca pondria el code de detectar canal y enviar
打印(“是时间!”)
random_num=random.randint(1,4)
如果答案_num==1:
等待频道的问候。发送(“Holi!”,como estanchic@s?")
如果答案_num==2:
等待频道的问候。发送(“Holi!,Como va su dia?que me cuentan?”)
如果答案_num==3:
等待频道的问候。发送(“Holi!、Como va su dia?que and an haciendo?”)
elif答案_num==4:
等待问候,通过频道发送(“Holi!,como se Encunteran?”)
等待时间。睡眠(90)
其他:
打印(“尚未”)
等待时间。睡眠(10)
我在main.py中使用以下命令调用此脚本:

导入discord、json、os
导入日期时间、随机、时间
#我的朋友们都很高兴
从core.modules.greetings导入时间
导入线程
导入异步
main\u path=os.path.dirname(\u文件\u)
“”“加载Bot配置”“”
config\u path=os.path.join(主路径,“config.json”)
将open(config_path,“r”)作为jsonfile:
bot_config=json.load(jsonfile)
从core.smartbot导入smartbot
从core.modules.bot_brain导入BotBrain
从core.modules.bot\u操作导入BotActions
bot_模块=[BotBrain,BotActions]
ChatBot=SmartBot(bot\u配置、bot\u模块、主路径)
类BotClient(discord.Client):
@静力学方法
def是DMU通道(消息:str)->bool:
“核实是否存在私人运河的来源”
返回isinstance(message.channel、discord.channel.DMChannel)
def save_log(self,response:str,message:object)->None:
“Guarda el historial de conversacion”
date=datetime.datetime.now()
file_path=os.path.join(主_路径,f“assets/log/{date.strftime(“%d%b%y”)}.txt”)
打开(文件路径“a”,编码=“utf-8”)作为文本文件:
text_file.write(f“{message.content}\n{response}\n”)
def load_内容(自身,名称:str)->dict:
“”“Carga contenido.json de la ru毯嵌入”“”
嵌入路径=os.path.join(主路径,f“assets/embeds/{name}.json”)
将open(embed_path,“r”,encoding=“utf-8”)作为jsonfile:
content=json.load(jsonfile)
返回内容
def create_embed(self,content:dict)->对象:
“在建筑中嵌入建筑材料”
嵌入=不和谐。嵌入(
标题=内容[“标题”],
描述=内容[“描述”],
颜色=整数(内容[“颜色”],16),
)
embed.set_缩略图(url=content[“icon_url”])
对于键,内容[“内容”]中的值。项()
嵌入.add_字段(名称=键,值=值,内联=内容[“内联”])
嵌入.set_页脚(text=content[“footer”])
返回嵌入
def create_响应(自身,消息:对象)->列表:
“在门萨耶的基础上,嵌入一种新的格式”
response=ChatBot(message.content,str(message.author.id))
如果响应!=“#NoText”:
嵌入内容=自加载内容(“消息容器”)
face\u images=self.load\u内容(“图标\u URL”)
state=ChatBot.user_data[str(message.author.id)][“state”]
如果在面部图像中显示状态:
嵌入内容[“图标url”]=面部图像[状态]
其他:
嵌入内容[“icon\u url”]=random.choice(列表(face\u images.values())
嵌入内容[“描述”]=f“{response}”
嵌入=自我。创建嵌入(嵌入内容)
其他:
嵌入=无
返回响应,嵌入
异步def send_响应(self,message:object,is_server=False)->无:
“在门萨耶省的运河里,我们的环境是好的。”
响应,嵌入=self.create\u响应(消息)
如果bot_config[“调试模式”]:
self.save_日志(响应、消息)
打印(f“{message.author}:{message.content}”)
打印(f“@Bot:{response}”)
如果响应和响应!=“#notext”并嵌入:
如果是_服务器:
等待消息。回复(嵌入=嵌入)
其他:
等待message.channel.send(嵌入=嵌入)
def在_回调之间(self,args):
loop=asyncio.new\u event\u loop()
asyncio.set\u event\u循环(循环)
循环。运行\u直到\u完成(时间\u消息(args))
loop.close()
#这是一种自动驾驶的方法
异步def on_ready(self)->无:
打印(“以{0}!格式登录(self.user))
#x=线程。线程(目标=时间消息)#Creo un线程独立于主线程
#x、 开始()
Exception in thread Thread-2:
Trace (most recent recent calls):
  File "C: \ Users \ PC0 \ Anaconda3 \ lib \ threading.py", line 932, in _bootstrap_inner
    self.run ()
  File "C: \ Users \ PC0 \ Anaconda3 \ lib \ threading.py", line 870, running
    self._target (* self._args, ** self._kwargs)
  File "main_greetings.py", line 101, in between_callback
    loop.run_until_complete (time_messege (arguments))
  File "C: \ Users \ PC0 \ Anaconda3 \ lib \ asyncio \ base_events.py", line 616, in run_until_complete
    return future.result ()
  File "C: \ Users \ PC0 \ Desktop \ h ver 18-03 \ SmartBot-main \ core \ modules \ greetings.py", line 36, at time_messege
    sleep timeout (10)
TypeError: NoneType object cannot be used in 'await' expression